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 SOLVED - Levers Script
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Levers Script

I'm testing out some stuff now with local vars. If I come up with a solution, I'll let you know, and I'll try to keep the code as simple as possible!

EDIT: Got it (at least, I believe I have. Posting it now below here, editing this post.



In this description, I am assuming you named the callbacks in the level editor. I have named these switches differently in my example, but the only one that really makes any difference is the main_switch1.

Okay, I won't lie, without being mean, the code is a bit too extensive.

I decided to replicate your map by using a test map, in which I used eight switches. The first seven from left to right are the ones needing to be stuck in order to get the main one (the far right) to not be a static physic object.

[Image: 642fli.jpg]

Basically I took your code, shortened it, and did what I could to reproduce the appropriate output. To do so, I told each of the first seven levers to callback your code called LeverPuzzle, and similarly with the main switch to call MainSwitch1 (however these functions work differently in the actual code I had).

[Image: ejx4pc.jpg]

Then I called the code as below.
PHP Code: (Select All)
void OnStart()
{
    
//SetPropStaticPhysics("main", true);                Enabled this through Level Editor
    
SetLocalVarInt("switches"0);                            //Create a localvar 
}

void LeverPuzzle(string &in asEntityint LeverState)
{
    if(
LeverState == -1)                                      //Lever is all the way up
    
{
        
SetLeverStuckState(asEntity, -1false);       //asEntity makes either lever become stuck
        
AddLocalVarInt("switches"1);                //Increment Var
    
}
    if(
GetLocalVarInt("switches") == 7)                  //All switches are up
    
{
        
SetPropStaticPhysics("main"false);        //Main switch can be used
    
}
}

void MainSwitch1(string &in asEntityint LeverState)
{
    if(
LeverState == -1)                                      //Check if main switch is up
    
{
        
SetLeverStuckState(asEntity, -1false);  //Stick main switch to up position
        //Put what you want to happen after you trigger main switch here :-)
                //For example, I unlocked the door in that example room :D
    
}


And... well that was it really xD

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 03-31-2014, 11:43 AM by Romulator.)
03-31-2014, 11:10 AM
Find


Messages In This Thread
SOLVED - Levers Script - by MsHannerBananer - 03-31-2014, 07:49 AM
RE: Levers Script - by Mudbill - 03-31-2014, 09:26 AM
RE: Levers Script - by MsHannerBananer - 03-31-2014, 10:41 AM
RE: Levers Script - by Romulator - 03-31-2014, 11:10 AM
RE: Levers Script - by Mudbill - 03-31-2014, 01:42 PM
RE: Levers Script - by Romulator - 03-31-2014, 02:03 PM
RE: Levers Script - by MsHannerBananer - 03-31-2014, 08:15 PM
RE: Levers Script - by Mudbill - 03-31-2014, 02:15 PM
RE: Levers Script - by Mudbill - 03-31-2014, 10:44 PM
RE: Levers Script - by MsHannerBananer - 04-01-2014, 12:04 AM
RE: Levers Script - by MsHannerBananer - 04-01-2014, 04:01 AM



Users browsing this thread: 1 Guest(s)