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
Nublette Requires Assistance with Scripting and Puzzles
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#25
RE: The Nublette Needs Help With Everything

(01-14-2013, 01:52 AM)Kiandra Wrote: Is it possible to have an action on one map, let's say pulling a lever is the action, effect another map, opening a secret door?

Yes, and it's actually quite simple: all you need to do is set a global variable in one map, and check it's value in another.

These are the (predefined) script functions that you need to use:
PHP Code: (Select All)
void SetGlobalVarInt(stringvarNameint value);
int GetGlobalVarInt(stringvarName); 

Basically, in map1, inside your lever-callback simply check the position of the lever, and encode that position in a global variable using the SetGlobalVarInt() function. (Global variables are visible across maps.)

PHP Code: (Select All)
void OnLeverStateChanged(string &in entityIDint state)
{
    
// The state parameter indicates the position of the lever;
    // it can be  -1 = off, 0 = between, 1 = on 

    
SetGlobalVarInt("lever.map1"state);  // just pass the 'state' parameter along


Note: "lever.map1" just identifies the global variable, you can replace it with anything you want.

Then, in map2, you inside check he variable's value inside the OnEnter() function:

PHP Code: (Select All)
void OnEnter()
{
    if(
GetGlobalVarInt("lever.map1") == 1)  // remember, 1 means "on"
    
{
        
// put the code to unlock/open the door (or whatever) here
    
}

    
// the rest of the OnEnter() code goes here

(This post was last modified: 01-14-2013, 10:19 PM by TheGreatCthulhu.)
01-14-2013, 10:18 PM
Find


Messages In This Thread
RE: The Nublette Needs Help With Everything - by TheGreatCthulhu - 01-14-2013, 10:18 PM



Users browsing this thread: 1 Guest(s)