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
I need help with creating more than 1 scripts for my custom story
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#12
RE: I need help with creating more than 1 scripts for my custom story

yes, notice how all the collide callbacks are given in the OnStart? This is where you set up scripts. Anything that is called from those scripts is placed outside. For example:
Spoiler below!

void OnStart()
{
AddUseItemCallback("", "key_1", "level_wood_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "Scary_1", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Scary_2", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "Scary_3", true, 1);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
/functions
}

void Scary_1(string &in asParent, string &in asChild, int alState)
{
//functions
}

void Scary_2(string &in asParent, string &in asChild, int alState)
{
//functions
}

void Scary_3(string &in asParent, string &in asChild, int alState)
{
//functions
}



Notice how the callbacks are given when the player walks into a script area or uses a key on a door, and are preset in the OnStart? For example, in a sentence, it would read something like this:

"When the game starts ( void OnStart() ), add a collide callback (AddEntityCollideCallback) so when the player walks into ScriptArea_1 (AddEntityCollideCallback("Player", "ScriptArea_1", ...), it will run THIS function (..."Scary_1")."

Then true says the callback will be removed, so this function will not happen again after it happens once, and the 1 stands for being activated when the player walks into the area. -1 is leaving, and 0 is both. When the player walks into ScriptArea_1, void Scary_1 will activate and the functions inside Scary_1 will run.
(This post was last modified: 09-28-2012, 05:41 AM by Statyk.)
09-28-2012, 05:39 AM
Find


Messages In This Thread
RE: I need help with creating more than 1 scripts for my custom story - by Statyk - 09-28-2012, 05:39 AM



Users browsing this thread: 1 Guest(s)