Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if & else URGENT! PLZ!
X4anco Offline
Member

Posts: 157
Threads: 66
Joined: Apr 2011
Reputation: 0
#1
if & else URGENT! PLZ!

Hello peoples,

I wanted to know is there such features in angle script (the one to code Amnesia and custom stories) like 'if' and 'else' because I was going to do a bit in my level where you pull a lever and if a variable = 0 then a message will appear otherwise a door will unlock.

How would I set my script to detect if my var is 0 and show a message or 1 and unlock a door?

I hope that you can help Big Grin

EDIT:
void used1(string &in asParent, string &in asChild, int alState)
{
    if
    AddLocalVarInt("door1", 0);
    SetMessage("Message", "used1", 3);
    
    else
    //Something
    
}

...
(This post was last modified: 05-21-2011, 10:38 AM by X4anco.)
05-21-2011, 09:58 AM
Find
Karai16 Offline
Member

Posts: 164
Threads: 24
Joined: Apr 2011
Reputation: 0
#2
RE: if & else URGENT! PLZ!

void OnStart(){
    SetLocalVarInt("Lev", 1);
    SetEntityConnectionStateChangeCallback("Lever1", "L1");
    SetEntityConnectionStateChangeCallback("Lever2", "L2");
}

void L1(string &in asEntity, int alState)
{
     if (GetLeverState("Lever1") == 1)
     {
    SetEntityActive("ScriptArea_6", true);
    SetEntityActive("ScriptArea_4", true);
    SetLeverStuckState("Lever1", 1, true);
     }
}

void L2(string &in asEntity, int alState)
{
     if (GetLeverState("Lever2") == 1)
     {
          SetSwingDoorLocked("KeyStudyDoor", false, true);
      SetEntityActive("PrisonDoor", false);
          SetLeverStuckState("Lever2", 1, true);
     }
}
This is the code I used in my custom story to get my levers to work. I hope you'll be able to use it. If you want it to show the other message, I think you'll have to add something like this.

void L2(string &in asEntity, int alState)
{
     if (GetLeverState("Lever2") == 1)
     {
          SetSwingDoorLocked("KeyStudyDoor", false, true);
      SetEntityActive("PrisonDoor", false);
          SetLeverStuckState("Lever2", 1, true);
     }
     else {
         if (GetLeverState("Lever2")==0)
         {
             SetMessage("Message", "used1", 3);
          }
     }
}

Custom stories:
Her Games (100% Complete)
Her Games, All Bugs Fixed (100% Complete)
(This post was last modified: 05-21-2011, 11:13 AM by Karai16.)
05-21-2011, 11:05 AM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#3
RE: if & else URGENT! PLZ!

If the lever is pulled, have the interaction call back set a global variable to 1.

SetGlobalVarInt(string& asName, int alVal);

Then have the callback area, timer, etc to check the global variable.

GetLocalVarInt(string& asName);

Example for checking the global variable from an area


void Checking(string &in asParent, string &in asChild, int alState)
{
     if(GetGlobalVarInt("Variable")==1
     {
     //Insert commands here if variable = 1
     }

     else
     {
     //Insert commands here if variable does not = 1
     }
}

Someone correct me if I'm wrong.

05-21-2011, 11:10 AM
Find
X4anco Offline
Member

Posts: 157
Threads: 66
Joined: Apr 2011
Reputation: 0
#4
RE: if & else URGENT! PLZ!

Never mind it was my script

...
(This post was last modified: 05-21-2011, 11:55 AM by X4anco.)
05-21-2011, 11:44 AM
Find




Users browsing this thread: 1 Guest(s)