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
Script Help Global Varint With Lever
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#1
Global Varint With Lever

Hi Forum.
I'm very confused using the Global Varint script. I'm making a script where the player interacts with a lever that unlock something at another map. I spent an hour how to use this script and still have no idea how to use the script. Help ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
01-25-2013, 01:51 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#2
RE: Global Varint With Lever

In the first map, you'll want a line in OnStart like ...
SetGlobalVarInt("OtherMapDoorUnlocked", 0);

Then, when the player uses the lever to unlock, you'll want
SetGlobalVarInt("OtherMapDoorUnlocked", 1);
(assuming 0 is locked and 1 is unlocked)

Now when the player goes over to the other map, in OnEnter, you have a line like

if (GetGlobalVarInt("OtherMapDoorUnlocked")==1) // if the door has been unlocked
{
      SetSwingDoorLocked("DoorName", false, true);
}

Change names where appropriate

01-25-2013, 02:01 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#3
RE: Global Varint With Lever

Of course:

It should be like this:

Map with lever
void OnStart()
{
SetEntityConnectionChangeStateCallback("Lever", "Func");
}

void Func (string &in asEntity, int alState)
{
if (alState == 1)
{
AddGlobalVarInt("Var", 1);
//You may put some sounds if you wish
}
}

Map where the lever takes effect:

void OnEnter()
{
if (GetGlobalVarInt("Var" == 1))
{
//Unlock your thing
}
}

EDIT: Ninja'd by Adrianis. Although I explain myself better.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 01-25-2013, 02:02 PM by The chaser.)
01-25-2013, 02:02 PM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#4
RE: Global Varint With Lever

Important, this only works if you play the game like you would normally, that is you play the level with the lever, then continue to the other level using a level door or changemap script. If you use the debug menu to directly load a new level, then that is like starting a new game. Meaning if you play the lever level, pull the lever and have the variable set, then use debug menu to load the next level to test if the variable has the correct value it will always fail.
(This post was last modified: 01-25-2013, 02:07 PM by jens.)
01-25-2013, 02:06 PM
Website Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#5
RE: Global Varint With Lever

Thanks for the reply guys. I'll try this later when I finished making the map.

[Image: the-cabin-in-the-woods-masked-people.jpg]
01-26-2013, 07:43 AM
Find




Users browsing this thread: 1 Guest(s)