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 Lock opened with armor puzzle
Ermu Offline
Member

Posts: 86
Threads: 13
Joined: Jan 2012
Reputation: 2
#1
Lock opened with armor puzzle

Hey!

So, my problem is that i've been making a puzzle, where you need to find 2 armor heads and place them to 2 helmetless armors, to unlock the door. My problem is at the point that there should be the both armor heads placed to unlock the door, but the door will unlock even if there is one helmet only placed, and as i said, it shouldn't unlock until both have been placed.

The reason why i placed "else"s at the point it checks for the other armor, is because i thought that would work since it didn't work without it.

SCRIPT:

void OnStart()
{
AddEntityCollideCallback("upstairs_doorhead_2", "upstairs_doorarea_2", "upstairsdoor2", true, 1);
AddEntityCollideCallback("upstairs_doorhead_1", "upstairs_doorarea_1", "upstairsdoor1", true, 1);
}

void upstairsdoor1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("upstairs_doorhead_1", false);
SetEntityActive("upstairs_doorheadless_1", false);
SetEntityActive("upstairs_doorarmor_1", true);
if(GetEntityExists("upstairs_doorheadless_2") == true)
{
SetSwingDoorLocked("upstairs_door", false, false);
}
else
{
SetSwingDoorLocked("upstairs_door", false, true);
}
}

void upstairsdoor2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("upstairs_doorhead_2", false);
SetEntityActive("upstairs_doorheadless_2", false);
SetEntityActive("upstairs_doorarmor_2", true);
if(GetEntityExists("upstairs_doorheadless_1") == true)
{
SetSwingDoorLocked("upstairs_door", false, false);
}
else
{
SetSwingDoorLocked("upstairs_door", false, true);
}
}

Thanks for your help, Ermu.
(This post was last modified: 02-16-2012, 05:05 PM by Ermu.)
02-16-2012, 05:04 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#2
RE: Lock opened with armor puzzle

Use LocalVarInt and then when the LocalVarInt is 2 then that opens the door Smile


02-16-2012, 05:54 PM
Find
Ermu Offline
Member

Posts: 86
Threads: 13
Joined: Jan 2012
Reputation: 2
#3
RE: Lock opened with armor puzzle

(02-16-2012, 05:54 PM)SilentStriker Wrote: Use LocalVarInt and then when the LocalVarInt is 2 then that opens the door Smile
Not familiar with that, can you give me example/put it in the script?
02-16-2012, 08:24 PM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#4
RE: Lock opened with armor puzzle

Something like this:

//____________________________


void OnStart()
{

SetLocalVarInt("armorbank", 0); //sets a "bank" for integers to be added and be called later

AddEntityCollideCallback("upstairs_doorhead_2", "upstairs_doorarea_2", "upstairsdoor2", true, 1);
AddEntityCollideCallback("upstairs_doorhead_1", "upstairs_doorarea_1", "upstairsdoor1", true, 1);
}

void upstairsdoor1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("upstairs_doorhead_1", false);
SetEntityActive("upstairs_doorheadless_1", false);
SetEntityActive("upstairs_doorarmor_1", true);


AddLocalVarInt("armorbank", 1); //Adds ONE to the "armorbank"
CHECKHEADS(); //Calls the function below. Saves space
}

void upstairsdoor2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("upstairs_doorhead_2", false);
SetEntityActive("upstairs_doorheadless_2", false);
SetEntityActive("upstairs_doorarmor_2", true);


AddLocalVarInt("armorbank", 1); //Adds ONE to the "armorbank"
CHECKHEADS(); //Calls the function below. Saves space
}


void CHECKHEADS()
{
if(GetLocalVarInt("armorbank") == 2) //checks the bank. If it has 2, it continues.
{
SetSwingDoorLocked("upstairs_door", false, true);
}
}
(This post was last modified: 02-16-2012, 09:22 PM by Statyk.)
02-16-2012, 09:21 PM
Find
Ermu Offline
Member

Posts: 86
Threads: 13
Joined: Jan 2012
Reputation: 2
#5
RE: Lock opened with armor puzzle

Thanks! Works now!

Also, i've been wondering, how do you get that blue splash on your screen with the "swoosh" sound when you ie. unlock a door or correctly solve a puzzle.
02-16-2012, 09:58 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#6
RE: Lock opened with armor puzzle

GiveSanityBoost(); or GiveSanityBoostSmall();

AddPlayerSanity(float afSanity);

Smile

(This post was last modified: 02-16-2012, 10:22 PM by SilentStriker.)
02-16-2012, 10:21 PM
Find




Users browsing this thread: 1 Guest(s)