Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
this is a n00b question!
Padster Offline
Junior Member

Posts: 11
Threads: 1
Joined: Dec 2010
Reputation: 0
#1
this is a n00b question!

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.
12-02-2010, 03:43 AM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#2
RE: this is a n00b question!

void OnStart()
{
*Insert as many functions as you like here. For example
Function 1;
Function 2;
etc*
}
(This post was last modified: 12-02-2010, 03:46 AM by Chilton.)
12-02-2010, 03:46 AM
Find
Padster Offline
Junior Member

Posts: 11
Threads: 1
Joined: Dec 2010
Reputation: 0
#3
RE: this is a n00b question!

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");
}
}
12-02-2010, 03:55 AM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#4
RE: this is a n00b question!

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
(This post was last modified: 12-02-2010, 04:01 AM by Chilton.)
12-02-2010, 04:00 AM
Find
Padster Offline
Junior Member

Posts: 11
Threads: 1
Joined: Dec 2010
Reputation: 0
#5
RE: this is a n00b question!

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
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#6
RE: this is a n00b question!

(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
12-02-2010, 04:15 AM
Find
Padster Offline
Junior Member

Posts: 11
Threads: 1
Joined: Dec 2010
Reputation: 0
#7
RE: this is a n00b question!

you my friend are a feeking genius!!! Thanks for the help.
12-02-2010, 04:23 AM
Find
Chilton Offline
Member

Posts: 138
Threads: 9
Joined: Sep 2010
Reputation: 0
#8
RE: this is a n00b question!

Glad i could be of assistance
12-02-2010, 04:24 AM
Find




Users browsing this thread: 1 Guest(s)