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 Need help to make a lever puzzle
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#11
RE: Need help to make a lever puzzle

(01-15-2012, 11:30 AM)Tripication Wrote:
(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn Tongue)
I did, but did it work?
No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-15-2012, 11:32 AM by Shadowfied.)
01-15-2012, 11:31 AM
Find Reply
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#12
RE: Need help to make a lever puzzle

(01-15-2012, 11:31 AM)Shadowfied Wrote:
(01-15-2012, 11:30 AM)Tripication Wrote:
(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn Tongue)
I did, but did it work?
No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?
That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-15-2012, 11:39 AM
Find Reply
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#13
RE: Need help to make a lever puzzle

(01-15-2012, 11:39 AM)Tripication Wrote:
(01-15-2012, 11:31 AM)Shadowfied Wrote:
(01-15-2012, 11:30 AM)Tripication Wrote:
(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn Tongue)
I did, but did it work?
No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?
That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)
I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?

Edit: Nevermind. They do get stuck..

Edit 2: Ok I saw that Statyk had them getting stuck in up and down states in every func. I removed them and now it works the way I want, they only get stuck once they are all correct.

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-15-2012, 11:46 AM by Shadowfied.)
01-15-2012, 11:43 AM
Find Reply
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#14
RE: Need help to make a lever puzzle

(01-15-2012, 11:43 AM)Shadowfied Wrote:
(01-15-2012, 11:39 AM)Tripication Wrote:
(01-15-2012, 11:31 AM)Shadowfied Wrote:
(01-15-2012, 11:30 AM)Tripication Wrote:
(01-15-2012, 11:28 AM)Shadowfied Wrote: You only added the 4 stuckstate lines at the end? (Just so I learn Tongue)
I did, but did it work?
No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?
That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)
I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?

Edit: Nevermind. They do get stuck..
They shouldn't. Just try it anyway, im sure its nothing you cant undo.

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-15-2012, 11:46 AM
Find Reply
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#15
RE: Need help to make a lever puzzle

(01-15-2012, 11:46 AM)Tripication Wrote:
(01-15-2012, 11:43 AM)Shadowfied Wrote:
(01-15-2012, 11:39 AM)Tripication Wrote:
(01-15-2012, 11:31 AM)Shadowfied Wrote:
(01-15-2012, 11:30 AM)Tripication Wrote: I did, but did it work?
No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?
That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)
I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?

Edit: Nevermind. They do get stuck..
They shouldn't. Just try it anyway, im sure its nothing you cant undo.
Read my edit 2. ^^


Current - Castle Darkuan
Other - F*cked Map
01-15-2012, 11:47 AM
Find Reply
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#16
RE: Need help to make a lever puzzle

(01-15-2012, 11:47 AM)Shadowfied Wrote:
(01-15-2012, 11:46 AM)Tripication Wrote:
(01-15-2012, 11:43 AM)Shadowfied Wrote:
(01-15-2012, 11:39 AM)Tripication Wrote:
(01-15-2012, 11:31 AM)Shadowfied Wrote: No, it didn't. =/ Didn't make any noticeable difference.

Edit: I think I know why though, Statyk told me to check the box "InteractionDisablesStuck"
That's probably it...right?
That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)
I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?

Edit: Nevermind. They do get stuck..
They shouldn't. Just try it anyway, im sure its nothing you cant undo.
Read my edit 2. ^^
Oh, that sucks, hang on, i've just had a brillian stroke of genius...
Next post...



[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-15-2012, 11:49 AM
Find Reply
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#17
RE: Need help to make a lever puzzle

(01-15-2012, 11:49 AM)Tripication Wrote:
(01-15-2012, 11:47 AM)Shadowfied Wrote:
(01-15-2012, 11:46 AM)Tripication Wrote:
(01-15-2012, 11:43 AM)Shadowfied Wrote:
(01-15-2012, 11:39 AM)Tripication Wrote: That could possible be it, although its probably better to wait for him to help you out. ive it a shot if you want, but once again, i dont have too much experience with this kinda thing, so i wouldn't be sure.
(The levers should only get stuck once the puzzle is complete, i put the SetLeverStuckState lines in the last function, and statyk does say...

custom function called each time a lever is correctly in place. when all are in place, the function continues.

So assuming that the boxes are unticked, it should work. But i dont EXACTLY know what the boxes do so be sure that you can fix it if it does stuff up)
I don't really understand why I shall have that box ticked. The levers don't get stuck anyway..do they?

Edit: Nevermind. They do get stuck..
They shouldn't. Just try it anyway, im sure its nothing you cant undo.
Read my edit 2. ^^
Oh, that sucks, hang on, i've just had a brillian stroke of genius...
Next post...
Well, thanks for your help. =)


Current - Castle Darkuan
Other - F*cked Map
01-15-2012, 11:50 AM
Find Reply
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#18
RE: Need help to make a lever puzzle

Try Duplicating the levers and deactivating the duplicates, turn the InteractionDisablesStuck off on the Inactive duplicates and do this


void OnStart()
{
SetEntityConnectionStateChangeCallback("LEVER1", "lever1func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER2", "lever2func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER3", "lever3func"); //levercallback
SetEntityConnectionStateChangeCallback("LEVER4", "lever4func"); //levercallback

SetLocalVarInt("lever1bank", 0); //'dem banks!
SetLocalVarInt("lever2bank", 0); //'dem banks!
SetLocalVarInt("lever3bank", 0); //'dem banks!
SetLocalVarInt("lever4bank", 0); //'dem banks!
}


/////////////////////////////////////////////////////////


void lever1func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER1", 1, true); //sets it stuck
SetLocalVarInt("lever1bank", 1); //add dat cash munay
CheckFunction(); //follows function at the bottom, which activates the completed puzzle
}
if(alState == -1)
{
SetLeverStuckState("LEVER1", -1, true);
SetLocalVarInt("lever1bank", 0);
}
}

//////////////////////////////////////////////////////////////////////

void lever2func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER2", 1, true);
SetLocalVarInt("lever2bank", 1);
CheckFunction();
}
if(alState == -1)
{
SetLeverStuckState("LEVER2", -1, true);
SetLocalVarInt("lever2bank", 0);
}
}

//////////////////////////////////////////////////////////////////////

void lever3func(string &in asEntity, int alState) //follows a different "if" statement, making it opposite from the rest or... Down rather than Up.
{
if(alState == 1)
{
SetLeverStuckState("LEVER3", 1, true);
SetLocalVarInt("lever3bank", 0);
}
if(alState == -1)
{
SetLeverStuckState("LEVER3", -1, true);
SetLocalVarInt("lever3bank", 1);
CheckFunction();
}
}

//////////////////////////////////////////////////////////////////////

void lever4func(string &in asEntity, int alState)
{
if(alState == 1)
{
SetLeverStuckState("LEVER4", 1, true);
SetLocalVarInt("lever4bank", 1);
CheckFunction();
}
if(alState == -1)
{
SetLeverStuckState("LEVER4", -1, true);
SetLocalVarInt("lever4bank", 0);
}
}

//////////////////////////

void CheckFunction() //custom function called each time a lever is correctly in place. when all are in place, the function continues.
{
if(GetLocalVarInt("lever1bank") == 1 && GetLocalVarInt("lever2bank") == 1 && GetLocalVarInt("lever3bank") == 1 && GetLocalVarInt("lever4bank") == 1)
{
SetEntityActive("LEVER1", false);
SetEntityActive("LEVER2", false);
SetEntityActive("LEVER3", false);
SetEntityActive("LEVER4", false);
SetEntityActive("LEVER1_1", true);
SetEntityActive("LEVER2_1", true);
SetEntityActive("LEVER3_1", true);
SetEntityActive("LEVER4_1", true);
SetLeverStuckState("LEVER1_1", 1, false);
SetLeverStuckState("LEVER2_1", 1, false);
SetLeverStuckState("LEVER3_1", -1, false);
SetLeverStuckState("LEVER4_1", 1, false);

GiveSanityBoost();
SetSwingDoorLocked("LEVERDOOR", false, true);
}
}






I'm assuming the Duplicates will have a _1 at the end of the original name.


Ya dig?
(NOTE:May not be Genius...BACKUPS BEFORE COMPLAINING)

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-15-2012, 11:53 AM
Find Reply
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#19
RE: Need help to make a lever puzzle

Uhm..I thought I already told you I solved it?

Statyk had put "SetLeverStuckState("LEVER4", 1, true);" in every function, removing all of those and adding your "SetLeverStuckState" scripts at the end solved it. There was no reason (not that I understand anyway) to make them stuck all the time and using the InteractDisablesStuck checkbox for this situation.

Current - Castle Darkuan
Other - F*cked Map
01-15-2012, 11:55 AM
Find Reply
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#20
RE: Need help to make a lever puzzle

Here's a more efficient way of doing it (though entirely untested).

PHP Code: (Select All)
const string[] lever_names = {"LEVER1""LEVER2""LEVER3""LEVER4"}
const 
int[] desired_lever_states = {11, -11}

/******************************************************************************/

void OnStart()
{
    
SetEntityConnectionStateChangeCallback("LEVER1""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER2""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER3""lever_func");
    
SetEntityConnectionStateChangeCallback("LEVER4""lever_func");

    
SetLocalVarInt("LEVER1"0);
    
SetLocalVarInt("LEVER2"0);
    
SetLocalVarInt("LEVER3"0);
    
SetLocalVarInt("LEVER4"0);
}

/******************************************************************************/

void lever_func(string &in asEntityint alState)
{
    if (
GetLocalVarInt("LEVER_PUZZLE_COMPLETE") == 1)
        return;

    
SetLocalVarInt(asEntityalState);    
    
CheckFunction();
}

/******************************************************************************/

void CheckFunction()
{
    for (
int i 0lever_names.length(); ++i)
    {
        if (
GetLocalVarInt(lever_names[i]) != desired_lever_states[i])
            return;
        else
        {
            
SetLeverStuckState(lever_names[i], desired_lever_states[i], true);
            
SetEntityConnectionStateChangeCallback(lever_names[i], "");
        }
    }
    
    
GiveSanityBoost();
    
SetSwingDoorLocked("LEVERDOOR"falsetrue);
    
SetLocalVarInt("LEVER_PUZZLE_COMPLETE"1);


Tutorials: From Noob to Pro
01-15-2012, 11:56 AM
Website Find Reply




Users browsing this thread: 1 Guest(s)