Frictional Games Forum (read-only)

Full Version: this is a n00b question!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
void OnStart()
{
*Insert as many functions as you like here. For example
Function 1;
Function 2;
etc*
}
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");
}
}
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
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.
(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
you my friend are a feeking genius!!! Thanks for the help.
Glad i could be of assistance