Frictional Games Forum (read-only)
Script is just... broken? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Script is just... broken? (/thread-5060.html)

Pages: 1 2


Script is just... broken? - Kyle - 10-15-2010

I tried getting these two things in it to work, but it just seems broken. And by the way, I was attempting to replace a "needle" for a "key". I worked with both of these scripts on my other custom story and it work perfectly. Also for some reason, it won't set the lamp oil to 0... Sad

The entities in my game are: CastleDoor, CastleDoor2, and Needle.

Code:

void Onstart()
{
AddUseItemCallback("" , "Needle" , "CastleDoor2" , "UsedNeedleOnDoor" , false);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "Collide01" , true , 1);
SetPlayerLampOil(0);
}
void Collide01(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("CastleDoor" , true , true);
GiveSanityDamage(10 , true);
}
void UsedNeedleOnDoor(string &in asItem , string &in asEntity)
{
PlaySoundAtEntity("UnlockSound" , "unlock_door.snt" , asEntity , 0.0f , false);
SetSwingDoorLocked(asEntity , false , true);
SetLevelDoorLocked(asEntity , false);
}
void OnEnter()
{
}
void OnLeave()
{
}

Code:

<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You awaken in a castle, not knowing of where you are. Some dark presence is following you, yet you cannot stop it.[br][br]You are alone...</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemName_Needle">Sewing Needle</Entry>
<Entry Name="ItemDesc_Needle">A simple needle that could be used to pick a lock.</Entry>
</CATEGORY>
</LANGUAGE>


RE: Script is just... broken? - DamnNoHtml - 10-15-2010

void OnStart ()

Not void Onstart ()

Also, sounds like a wonderfully unoriginal story from that description -_-


RE: Script is just... broken? - Kyle - 10-15-2010

I know, I'm gonna change it later. I just wanted to quickly put something in.... Smile


RE: Script is just... broken? - SLi78 - 10-15-2010

Have you tried

Code:
    SetPlayerLampOil(0.0f);
?


RE: Script is just... broken? - Chilton - 10-15-2010

(10-15-2010, 05:11 PM)SLi78 Wrote: Have you tried

Code:
    SetPlayerLampOil(0.0f);
?
It does not work that way at all...
F segmas represent time, not quantity i believe

Itd be nice if we knew if the issue was resolved though...


RE: Script is just... broken? - Entih - 10-15-2010

No, a number like '0.0f' represents that it is a floating point value, IE uses a decimal. It is the proper notation in C++ when working with float values, and by extension this script, though this script is far less... strict... on the f's usage it seems. I still use it for all float values though.

The lamp oil function does take a float, from 0 to 100 percent, so using 0.0f may actually make it work, though 0 should have worked just as well.

EDIT: Yeah, just tested it, the script is not much of a stickler. The lamp oil function works with just standard old 0 just the same as 0.0f.


RE: Script is just... broken? - Kyle - 10-15-2010

It's okay guys, it worked when I fixed the script.
I also got another problem... I looked in the script functions and couldn't find the right one that made something happen when you, in this case, read a note that you pick up. So I just tried as a last resort to use another scripting callback.

void OnStart()
{
PreloadSound("00_laugh.snt");
AddEntityCollideCallback("Player" , "note_scroll_1" , "Collapse" , true , 1);
AddUseItemCallback("" , "Needle" , "CastleDoor2" , "UsedNeedleOnDoor" , false);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "Collide01" , true , 1);
SetPlayerLampOil(0);
}
void Collide01(string &in asParent , string &in asChild , int alState)
{
SetSwingDoorClosed("CastleDoor" , true , true);
GiveSanityDamage(10 , true);
}
void UsedNeedleOnDoor(string &in asItem , string &in asEntity)
{
PlaySoundAtEntity("UnlockSound" , "unlock_door.snt" , asEntity , 0.0f , false);
SetSwingDoorLocked(asEntity , false , true);
SetLevelDoorLocked(asEntity , false);
}
void Collapse(string &in asParent , string&in asCild , int alState)
{
SetEntityActive("wooden_board01_1" , true);
SetEntityActive("rock_debris01_1" , true);
SetEntityActive("rock_debris03_1" , true);
PlaySoundAtEntity("LaughSound" , "00_laugh.snt" , "Player" , 0 , true);
}
void OnEnter()
{
}
void OnLeave()
{
}


RE: Script is just... broken? - Entih - 10-16-2010

If you want something to trigger when you pick up the note, a standard interact callback should work fine. At least in theory such would work fine, haven't tested.


RE: Script is just... broken? - Kyle - 10-16-2010

(10-16-2010, 02:37 AM)Entih Wrote: If you want something to trigger when you pick up the note, a standard interact callback should work fine. At least in theory such would work fine, haven't tested.

Nope, it wouldn't work. It would require a function to cause the other events... unless if you got any other bright ideas... Tongue


RE: Script is just... broken? - Entih - 10-16-2010

I found a semi-alternative, based on how they did it in the game in the Archives. Use the item 'diary_paper_01'. It has a diary pickup callback, apparently (info on the callback function parameters pop up if you hover the mouse over it).

Sadly, it also appears to be that the diary paper uses a bit of a different methodology for the text and name entries, being "Diary_<TEXTENTRYNAME>_Name<INDEXNUMBER>" and "Diary_..._Text...", with index meaning which numbered 'entry' it was, starting at 1. Have not used the diary versus note especially, myself, I cannot say just how any of this works.