Frictional Games Forum (read-only)
this is a n00b question! - 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: this is a n00b question! (/thread-5597.html)



this is a n00b question! - Padster - 12-02-2010

how do i put more than one script function withing a Void OnStart()?
I'm asking because it wont let me script multiple OnStart()s.


RE: this is a n00b question! - Chilton - 12-02-2010

void OnStart()
{
*Insert as many functions as you like here. For example
Function 1;
Function 2;
etc*
}


RE: this is a n00b question! - Padster - 12-02-2010

here is what i have coded for my first OnStart and the game is giveing me a FATAL ERROR and saying that the ERR is :Expectide '(' haha i have no idea what that means!
void OnStart()
{
{
AddUseItemCallback("", "DoorKey_1", "Door_3", "UseKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_3", false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
RemoveItem("DoorKey_1");
}
{
AddEntityCollideCallback ("Player", "doorslam_1","Collidedoorslam", true, -1);
}
void Collidedoorslam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("Room_2", true, true);
PlaySoundAtEntity("", "amb_hunt01", "Player", 0, false);
}


{
AddEntityCollideCallback("Player", "Unlock_1","Room2Unlock", true, 1);
}
void Room2Unlock(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("Room_2", true, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
}

}
////////////////////////////
// Run when entering map
void OnEnter()
// this is the lamp for debug
{
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");

for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
}


RE: this is a n00b question! - Chilton - 12-02-2010

Lots of mistakes - Try this

void OnStart()
{
AddUseItemCallback("", "DoorKey_1", "Door_3", "UseKeyOnDoor", true);
AddEntityCollideCallback("Player", "doorslam_1","Collidedoorslam", true, -1);
AddEntityCollideCallback("Player", "Unlock_1","Room2Unlock", true, 1);
}


void OnEnter() // Im not sure what your trying to do here, so i cant really troubleshoot it.
{
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
}

void OnLeave()
{
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_3", false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
RemoveItem("DoorKey_1");
}

void Collidedoorslam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("Room_2", true, true);
PlaySoundAtEntity("", "amb_hunt01", "Player", 0, false);
}

void Room2Unlock(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("Room_2", true, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
}

If that doesnt work, its likely a typo i missed, a syntax error, or whatever the hell you were trying to do in OnEnter


RE: this is a n00b question! - Padster - 12-02-2010

haha i dont really know what im doing anywhere! Like what is the deference between on enter and on exit? I assumed it meant the level.


RE: this is a n00b question! - Chilton - 12-02-2010

(12-02-2010, 04:07 AM)Padster Wrote: haha i dont really know what im doing anywhere! Like what is the deference between on enter and on exit? I assumed it meant the level.

OnStart is when you start the level for the first time, OnEnter is every time you enter the level, OnExit is every time you leave the level.

Learn from experience, and perhaps just start off small. Make a room, light it up, and try to make things happen in it. When you get used to individual functions, make multiple. When that gets easy, make more complicated scripts.

Dont just try to dive in headfirst, until you have an idea of how XML works


RE: this is a n00b question! - Padster - 12-02-2010

you my friend are a feeking genius!!! Thanks for the help.


RE: this is a n00b question! - Chilton - 12-02-2010

Glad i could be of assistance