HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
Lever Machine Help
Hey Forum,
I am in need of big help, I am hoping someone can easily guide me. So first, I want the player to solve a lever machine puzzle. The code I want is up 12 down 12. When the player gets this correct I want an elevator, that was unable to be used before, to start working. The machine and the elevator are on the same map. I am not very good with variables and stuff. Will someone be willing to guide me? Thanks!
EDIT:
Heres a more specific looking code (If the number is red that means the lever is pulled in that direction.)
III___III____ V____ I____ II____ IV
I____V_____IV____ V____ II____ II
(This post was last modified: 07-20-2012, 11:13 AM by HoyChampoy.)
|
|
07-20-2012, 11:01 AM |
|
Kreekakon
Pick a god and pray!
Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation:
124
|
RE: Lever Machine Help
Open up "13_machine_room"'s hps file from the original Amnesia. I recall they had a near identical puzzle in there, so you should be able to get a general idea of what to do from in there.
|
|
07-20-2012, 11:15 AM |
|
HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
RE: Lever Machine Help
(07-20-2012, 11:15 AM)Kreekakon Wrote: Open up "13_machine_room"'s hps file from the original Amnesia. I recall they had a near identical puzzle in there, so you should be able to get a general idea of what to do from in there. Okay i am almost there, but i just can't get the code I want to work which is up 12 down 12.
|
|
07-20-2012, 11:43 AM |
|
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
|
RE: Lever Machine Help
I've done pretty much the same riddle, just with 8 levers.
Anyway, heres the whole script with 6 levers.
void OnStart()
{
for(int i=1;i<7;i++)
{
SetEntityConnectionStateChangeCallback("lever_"+i, "LeverRiddle");
}
}
void LeverRiddle(string &in asEntity, int alState)
{
if(alState == 1){
if(asEntity == "lever_1") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_2") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_3") SetLocalVarInt("up_"+asEntity, 5);
else if(asEntity == "lever_4") SetLocalVarInt("up_"+asEntity, 1);
else if(asEntity == "lever_5") SetLocalVarInt("up_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("up_"+asEntity, 4);
CheckValue(asEntity);
AddDebugMessage("Lever Min & up value: " + GetLocalVarInt("up_value"), false);
}
else if(alState == -1){
if(asEntity == "lever_1") SetLocalVarInt("down_"+asEntity, 1);
else if(asEntity == "lever_2") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_3") SetLocalVarInt("down_"+asEntity, 4);
else if(asEntity == "lever_4") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_5") SetLocalVarInt("down_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("down_"+asEntity, 2);
CheckValue(asEntity);
AddDebugMessage("Lever Max & down value: " + GetLocalVarInt("down_value"), false);
}
else if(alState == 0){
SetLocalVarInt("up_"+asEntity, 0);
SetLocalVarInt("down_"+asEntity, 0);
AddDebugMessage("Lever Mid", false);
}
/*All levers correct
*/
if(GetLocalVarInt("up_value") == 12 && GetLocalVarInt("down_value") == 12)
{
for(int i=1;i<7;i++)
{
SetLeverStuckState("lever_"+i, GetLeverState("lever_"+i), true);
}
}
}
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_lever_"+i));
AddLocalVarInt("down_value", GetLocalVarInt("down_lever_"+i));
}
}
There you go! Have fun
(This post was last modified: 07-20-2012, 01:58 PM by Ongka.)
|
|
07-20-2012, 01:57 PM |
|
HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
RE: Lever Machine Help
(07-20-2012, 01:57 PM)Ongka Wrote: I've done pretty much the same riddle, just with 8 levers.
Anyway, heres the whole script with 6 levers.
void OnStart()
{
for(int i=1;i<7;i++)
{
SetEntityConnectionStateChangeCallback("lever_"+i, "LeverRiddle");
}
}
void LeverRiddle(string &in asEntity, int alState)
{
if(alState == 1){
if(asEntity == "lever_1") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_2") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_3") SetLocalVarInt("up_"+asEntity, 5);
else if(asEntity == "lever_4") SetLocalVarInt("up_"+asEntity, 1);
else if(asEntity == "lever_5") SetLocalVarInt("up_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("up_"+asEntity, 4);
CheckValue(asEntity);
AddDebugMessage("Lever Min & up value: " + GetLocalVarInt("up_value"), false);
}
else if(alState == -1){
if(asEntity == "lever_1") SetLocalVarInt("down_"+asEntity, 1);
else if(asEntity == "lever_2") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_3") SetLocalVarInt("down_"+asEntity, 4);
else if(asEntity == "lever_4") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_5") SetLocalVarInt("down_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("down_"+asEntity, 2);
CheckValue(asEntity);
AddDebugMessage("Lever Max & down value: " + GetLocalVarInt("down_value"), false);
}
else if(alState == 0){
SetLocalVarInt("up_"+asEntity, 0);
SetLocalVarInt("down_"+asEntity, 0);
AddDebugMessage("Lever Mid", false);
}
/*All levers correct
*/
if(GetLocalVarInt("up_value") == 12 && GetLocalVarInt("down_value") == 12)
{
for(int i=1;i<7;i++)
{
SetLeverStuckState("lever_"+i, GetLeverState("lever_"+i), true);
}
}
}
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_lever_"+i));
AddLocalVarInt("down_value", GetLocalVarInt("down_lever_"+i));
}
}
There you go! Have fun
Thanks for helping! but when i put the code in, it only activates when i put in up 6 down 7.
|
|
07-20-2012, 09:29 PM |
|
HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
RE: Lever Machine Help
(07-20-2012, 09:29 PM)HoyChampoy Wrote: (07-20-2012, 01:57 PM)Ongka Wrote: I've done pretty much the same riddle, just with 8 levers.
Anyway, heres the whole script with 6 levers.
void OnStart()
{
for(int i=1;i<7;i++)
{
SetEntityConnectionStateChangeCallback("lever_"+i, "LeverRiddle");
}
}
void LeverRiddle(string &in asEntity, int alState)
{
if(alState == 1){
if(asEntity == "lever_1") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_2") SetLocalVarInt("up_"+asEntity, 3);
else if(asEntity == "lever_3") SetLocalVarInt("up_"+asEntity, 5);
else if(asEntity == "lever_4") SetLocalVarInt("up_"+asEntity, 1);
else if(asEntity == "lever_5") SetLocalVarInt("up_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("up_"+asEntity, 4);
CheckValue(asEntity);
AddDebugMessage("Lever Min & up value: " + GetLocalVarInt("up_value"), false);
}
else if(alState == -1){
if(asEntity == "lever_1") SetLocalVarInt("down_"+asEntity, 1);
else if(asEntity == "lever_2") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_3") SetLocalVarInt("down_"+asEntity, 4);
else if(asEntity == "lever_4") SetLocalVarInt("down_"+asEntity, 5);
else if(asEntity == "lever_5") SetLocalVarInt("down_"+asEntity, 2);
else if(asEntity == "lever_6") SetLocalVarInt("down_"+asEntity, 2);
CheckValue(asEntity);
AddDebugMessage("Lever Max & down value: " + GetLocalVarInt("down_value"), false);
}
else if(alState == 0){
SetLocalVarInt("up_"+asEntity, 0);
SetLocalVarInt("down_"+asEntity, 0);
AddDebugMessage("Lever Mid", false);
}
/*All levers correct
*/
if(GetLocalVarInt("up_value") == 12 && GetLocalVarInt("down_value") == 12)
{
for(int i=1;i<7;i++)
{
SetLeverStuckState("lever_"+i, GetLeverState("lever_"+i), true);
}
}
}
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_lever_"+i));
AddLocalVarInt("down_value", GetLocalVarInt("down_lever_"+i));
}
}
There you go! Have fun
Thanks for helping! but when i put the code in, it only activates when i put in up 6 down 7.
Nevermind it worked
|
|
07-20-2012, 11:15 PM |
|
Ongka
Member
Posts: 225
Threads: 3
Joined: Nov 2010
Reputation:
20
|
RE: Lever Machine Help
Good, what did you change?
|
|
07-20-2012, 11:16 PM |
|
|