Storfigge
Member
Posts: 101
Threads: 31
Joined: Sep 2012
Reputation:
0
|
Change lever function?
I wonder if it's possible to change the function of a lever? What I want is that the first time you use the lever you end up in one map but when you use the same lever a second time I want it to move to another map.
You're suppose to go down an elevator and the first time it leads to a dream, after the dream you end up in a dungeon and from this map you can take the elevator back to the first map. Once your back in the first map you can again if you missed something take the elevator, this time the dream wont happen so you just return to the dungeons, hope it's not confusing :S
My original idea was that I could SetEntityActive False on the first lever and SetEntityActive True on another lever that will lead to the dungeons. But I wonder if there is an easier way.
(This post was last modified: 05-23-2013, 03:57 PM by Storfigge.)
|
|
05-23-2013, 03:51 PM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Change lever function?
You can use local var int's.
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverName", "ElevatorUse");
SetLocalVarInt("Dream", 1);
}
void ElevatorUse(string &in asEntity, int alState)
{
if(GetLocalVarInt("Dream") == 1) //Dream occur!
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
}
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
05-23-2013, 04:14 PM |
|
Bridge
Posting Freak
Posts: 1,971
Threads: 25
Joined: May 2012
Reputation:
128
|
RE: Change lever function?
(05-23-2013, 04:14 PM)JustAnotherPlayer Wrote: You can use local var int's.
void OnStart()
{
SetEntityConnectionStateChangeCallback("LeverName", "ElevatorUse");
SetLocalVarInt("Dream", 1);
}
void ElevatorUse(string &in asEntity, int alState)
{
if(GetLocalVarInt("Dream") == 1) //Dream occur!
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{
ChangeMap("MapName", "PlayerStartAreaInTheMap", "SoundPlayedWhenTheChangeOccurs", "SoundPlayedWhenNewMapIsLoaded");
}
}
In case you didn't know, int is short for integer. They are not normally (or ever, I'd say) referred to as "ints".
|
|
05-23-2013, 08:34 PM |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
RE: Change lever function?
(05-23-2013, 04:14 PM)JustAnotherPlayer Wrote: else //Dream over. I'm gonna wait for Tomato Cat to fix this.
{
I *suppose* you could use an else statement. Unless you wanted states 0 and -1 to do something specific.
(This post was last modified: 05-23-2013, 10:20 PM by Tomato Cat.)
|
|
05-23-2013, 10:10 PM |
|
|