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
Adding multiple scripts together?
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#7
RE: Adding multiple scripts together?

(06-25-2012, 07:00 PM)Damascus Wrote: Hmm. Maybe this will clear some things up.

void OnStart () ///this is a function, every script inside the brackets runs off this function
{
SetMapDisplayNameEntry("library"); ///these are scripts
AddTimer("ChairThrow", 0.0f, "ChairThrow");
AddUseItemCallback("", "key_laboratory_1", "mansion_7", "unlock", true); ///this script calls a new function, which will start with "void" and get a new pair of brackets
}

void unlock(string &in asItem, string &in asEntity) ///many functions need syntax like this when triggered by a callback
{
SetSwingDoorLocked("mansion_7", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_7", 0, false);
RemoveItem("key_laboratory_1");
}

In the example above, every script in the first function runs as soon as you start the map. Every script in the second function runs when it is triggered. It is callbacks that prepares a trigger to execute scripts.
Lemme see if I've gotten this right then..
Everytime you write ´void´ you give it a new pair of brackets? Is that it?
Here's a bit of one of the scripts my friend did for me:


void OnStart()
{
AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);
AddEntityCollideCallback("Player", "jumpscare_2", "Jump2", true, 1);
AddUseItemCallback("", "key_01", "locked_door2", "UsedKeyOnDoor", true);
SetEntityPlayerInteractCallback("key_01", "Key_01", true);
AddUseItemCallback("", "torture_key_1", "torture_door_1", "UsedKeyOnDoor2", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door2", 0, false);
RemoveItem("key_01");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("torture_door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "torture_door_1", 0, false);
RemoveItem("torture_key_1");
}
void Jump1(string &in asParent, string &in asChild, int alState)
{

Now I accually see it! Brackets surrounding the void-commands?? Is that the only thing you need to think about when putting different functions together in the same file?
(This post was last modified: 06-25-2012, 07:36 PM by Wrathborn771.)
06-25-2012, 07:35 PM
Find


Messages In This Thread
RE: Adding multiple scripts together? - by Wrathborn771 - 06-25-2012, 07:35 PM



Users browsing this thread: 1 Guest(s)