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
Machine Lever Problem...
sasukeroxxx Offline
Junior Member

Posts: 39
Threads: 5
Joined: Sep 2011
Reputation: 0
#1
Exclamation  Machine Lever Problem...

Hi, im Brazilian, sorry for bad english :3

so,

I'm trying to run a combination of levers on the machine, I tried but could not find tutorials,and I was improvising and comparing with others to see if it worked, but I can not at all.Here is my script out, what's wrong with it? D: the levers are: L1, 2,3,4,5,6 ... I wanted the combination would be: up, up, down, up, down, up. that the machine would be the sum, 11up and 8 down. Help please '-'


void OnStart(){
}

void Levers(string &in asEntity, int alState){    /*Set values depending on up/down postion or 0 for middle     */    if(alState == -1){        if(asEntity == "L1") SetLocalVarInt("up_"+asEntity, 3);        else if(asEntity == "L2") SetLocalVarInt("up_"+asEntity, 3);        else if(asEntity == "L3") SetLocalVarInt("up_"+asEntity, 5);        else if(asEntity == "L4") SetLocalVarInt("up_"+asEntity, 1);        else if(asEntity == "L5") SetLocalVarInt("up_"+asEntity, 2);        else if(asEntity == "L6") SetLocalVarInt("up_"+asEntity, 4);                CheckValue(asEntity);            }    else if(alState == 1){        if(asEntity == "L1") SetLocalVarInt("down_"+asEntity, 1);        else if(asEntity == "L2") SetLocalVarInt("down_"+asEntity, 5);        else if(asEntity == "L3") SetLocalVarInt("down_"+asEntity, 6);        else if(asEntity == "L4") SetLocalVarInt("down_"+asEntity, 5);        else if(asEntity == "L5") SetLocalVarInt("down_"+asEntity, 2);        else if(asEntity == "L6") SetLocalVarInt("down_"+asEntity, 2);                CheckValue(asEntity);    }            else if(alState == 0){        SetLocalVarInt("up_"+asEntity, 0);        SetLocalVarInt("down_"+asEntity, 0);        }            if(GetLocalVarInt("up_value") == 11 && GetLocalVarInt("down_value") == 8){        SetEntityActive("ShardDoor", false);        GiveSanityBoost();        PlayMusic("02_puzzle.ogg", false, 0.7f, 0, 10, false);        PlaySoundAtEntity("door_safety_open", "door_safety_open.snt", "Player", 0.0f, false);        }}
void CheckValue(string sEntity){    PlaySoundAtEntity("s"+sEntity, "lever_mech_min_max", sEntity, 0.0f, false);
    SetLocalVarInt("up_value", 0);    SetLocalVarInt("down_value", 0);            for(int i=1;i<=6;i++){        AddLocalVarInt("up_value", GetLocalVarInt("up_L"+i));        AddLocalVarInt("down_value", GetLocalVarInt("down_L"+i));    }}

void OnEnter(){    PlayMusic("18_amb.ogg", true, 1, 2.0f, 0, false);    }
void OnLeave(){    StopMusic(2,0);}


Hallucination

Constantine - in Construction
(This post was last modified: 12-07-2011, 04:44 AM by sasukeroxxx.)
11-29-2011, 11:57 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: Machine Lever Problem...

Could you space out your hps file?

11-30-2011, 01:56 AM
Find
GreyFox Offline
Member

Posts: 162
Threads: 23
Joined: Jul 2011
Reputation: 2
#3
RE: Machine Lever Problem...

Not sure if I set up correctly, but I didn't change anything just tryed to sort it out.

Hopefully you can help him now falmez3

void OnStart()
{

}

void Levers(string &in asEntity, int alState)
{  
    /*Set values depending on up/down postion or 0 for middle     */    if(alState == -1)    
    if(asEntity == "L1") SetLocalVarInt("up_"+asEntity, 3);        
     else if(asEntity == "L2") SetLocalVarInt("up_"+asEntity, 3);  
     else if(asEntity == "L3") SetLocalVarInt("up_"+asEntity, 5);        
     else if(asEntity == "L4") SetLocalVarInt("up_"+asEntity, 1);        
     else if(asEntity == "L5") SetLocalVarInt("up_"+asEntity, 2);        
     else if(asEntity == "L6") SetLocalVarInt("up_"+asEntity, 4);                
     CheckValue(asEntity);            
}    

else if(alState == 1)
{    
    if(asEntity == "L1") SetLocalVarInt("down_"+asEntity, 1);        
    else if(asEntity == "L2") SetLocalVarInt("down_"+asEntity, 5);        
     else if(asEntity == "L3") SetLocalVarInt("down_"+asEntity, 6);        
     else if(asEntity == "L4") SetLocalVarInt("down_"+asEntity, 5);        
     else if(asEntity == "L5") SetLocalVarInt("down_"+asEntity, 2);        
     else if(asEntity == "L6") SetLocalVarInt("down_"+asEntity, 2);                
     CheckValue(asEntity);    
}            

else if(alState == 0)
{    
    SetLocalVarInt("up_"+asEntity, 0);        
    SetLocalVarInt("down_"+asEntity, 0);        
}            
if(GetLocalVarInt("up_value") == 11 && GetLocalVarInt("down_value") == 8)
{    
    SetEntityActive("ShardDoor", false);        
    GiveSanityBoost();        
    PlayMusic("02_puzzle.ogg", false, 0.7f, 0, 10, false);        
    PlaySoundAtEntity("door_safety_open", "door_safety_open.snt", "Player", 0.0f, false);        
}
void CheckValue(string sEntity)
{    
    PlaySoundAtEntity("s"+sEntity, "lever_mech_min_max", sEntity, 0.0f, false);
    SetLocalVarInt("up_value", 0);    
    SetLocalVarInt("down_value", 0);            
    for(int i=1;i<=6;i++)
{        
    AddLocalVarInt("up_value", GetLocalVarInt("up_L"+i));        
    AddLocalVarInt("down_value", GetLocalVarInt("down_L"+i));    }
}

void OnEnter()
{    
    PlayMusic("18_amb.ogg", true, 1, 2.0f, 0, false);    
}
void OnLeave()
{    
    StopMusic(2,0);
}


Current Project
Forgotten
11-30-2011, 03:55 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#4
RE: Machine Lever Problem...

(11-30-2011, 03:55 AM)GreyFox Wrote: Not sure if I set up correctly, but I didn't change anything just tryed to sort it out.

Hopefully you can help him now falmez3

void OnStart()
{

}

void Levers(string &in asEntity, int alState)
{  
    /*Set values depending on up/down postion or 0 for middle     */    if(alState == -1)    
    if(asEntity == "L1") SetLocalVarInt("up_"+asEntity, 3);        
     else if(asEntity == "L2") SetLocalVarInt("up_"+asEntity, 3);  
     else if(asEntity == "L3") SetLocalVarInt("up_"+asEntity, 5);        
     else if(asEntity == "L4") SetLocalVarInt("up_"+asEntity, 1);        
     else if(asEntity == "L5") SetLocalVarInt("up_"+asEntity, 2);        
     else if(asEntity == "L6") SetLocalVarInt("up_"+asEntity, 4);                
     CheckValue(asEntity);            
}    

else if(alState == 1)
{    
    if(asEntity == "L1") SetLocalVarInt("down_"+asEntity, 1);        
    else if(asEntity == "L2") SetLocalVarInt("down_"+asEntity, 5);        
     else if(asEntity == "L3") SetLocalVarInt("down_"+asEntity, 6);        
     else if(asEntity == "L4") SetLocalVarInt("down_"+asEntity, 5);        
     else if(asEntity == "L5") SetLocalVarInt("down_"+asEntity, 2);        
     else if(asEntity == "L6") SetLocalVarInt("down_"+asEntity, 2);                
     CheckValue(asEntity);    
}            

else if(alState == 0)
{    
    SetLocalVarInt("up_"+asEntity, 0);        
    SetLocalVarInt("down_"+asEntity, 0);        
}            
if(GetLocalVarInt("up_value") == 11 && GetLocalVarInt("down_value") == 8)
{    
    SetEntityActive("ShardDoor", false);        
    GiveSanityBoost();        
    PlayMusic("02_puzzle.ogg", false, 0.7f, 0, 10, false);        
    PlaySoundAtEntity("door_safety_open", "door_safety_open.snt", "Player", 0.0f, false);        
}
void CheckValue(string sEntity)
{    
    PlaySoundAtEntity("s"+sEntity, "lever_mech_min_max", sEntity, 0.0f, false);
    SetLocalVarInt("up_value", 0);    
    SetLocalVarInt("down_value", 0);            
    for(int i=1;i<=6;i++)
{        
    AddLocalVarInt("up_value", GetLocalVarInt("up_L"+i));        
    AddLocalVarInt("down_value", GetLocalVarInt("down_L"+i));    }
}

void OnEnter()
{    
    PlayMusic("18_amb.ogg", true, 1, 2.0f, 0, false);    
}
void OnLeave()
{    
    StopMusic(2,0);
}


Thanks for that Big Grin, OP; do you want it so there's a specific order for the levers to go down (eg. lever 3 cant go down until level 1 and 2 are in their correct position) or you want it so they can go down in any order but some have to go up and some have to go down?

11-30-2011, 04:44 AM
Find
sasukeroxxx Offline
Junior Member

Posts: 39
Threads: 5
Joined: Sep 2011
Reputation: 0
#5
RE: Machine Lever Problem...

in any order...


Hallucination

Constantine - in Construction
12-05-2011, 08:48 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#6
RE: Machine Lever Problem...

Do this:

void OnStart
{
SetLocalVarInt("Var1", 0);
SetEntityConnectionStateChangeCallback("L1", "lever_func1");
SetEntityConnectionStateChangeCallback("L2", "lever_func2");
SetEntityConnectionStateChangeCallback("L3", "lever_func3");
SetEntityConnectionStateChangeCallback("L4", "lever_func4");

SetEntityConnectionStateChangeCallback("L5", "lever_func5");
SetEntityConnectionStateChangeCallback("L6", "lever_func6");
}


void lever_func1(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}


void lever_func2(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}


void lever_func3(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}


void lever_func4(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}


void lever_func5(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}



void lever_func6(string &in asEntity, int alState)
{
if (alState == 1) //up
{
AddLocalVarInt("Var1", 1);
func01();
}
}

void func01()
{
if(GetLocalVarInt("Var1") == 6)
{
what you want to happen here
}
}

I'm not sure whether -1= drag up and 1 = drag down so test this before :3

12-06-2011, 03:49 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: Machine Lever Problem...

Here's one way of doing it (warning: this code is untested):

PHP Code: (Select All)
// up, up, down, up, down, up
const int[] complex_lever_states = {-1, -11, -11, -1};

void OnStart()
{
    for (
int i 17; ++i)
        
SetEntityConnectionStateChangeCallback("L"+i"ComplexLeverPuzzle");
}

void ComplexLeverPuzzle(string &in entityint state)
{
    
SetLocalVarInt("ComplexLever_"+entitystate);
    
CheckComplexLeverStates();
}

void CheckComplexLeverStates()
{
    for (
int i 17; ++i)
    {
        if (
GetLocalVarInt("ComplexLever_L"+i) != complex_lever_states[i-1])
            return;
    }

    
SetEntityActive("ShardDoor"false);
    
GiveSanityBoost();
    
PlayMusic("02_puzzle.ogg"false0.7f010false);
    
PlaySoundAtEntity("door_safety_open""door_safety_open.snt""Player"0.0ffalse);


Tutorials: From Noob to Pro
12-06-2011, 04:29 AM
Website Find
sasukeroxxx Offline
Junior Member

Posts: 39
Threads: 5
Joined: Sep 2011
Reputation: 0
#8
RE: Machine Lever Problem...

Oh god, works. I was really stuck on this :X and had no idea how to make it work. hehe thank you all for this Smile i am nearly to finish my custom map Big Grin


Hallucination

Constantine - in Construction
12-07-2011, 04:42 AM
Find




Users browsing this thread: 1 Guest(s)