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


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting Answers
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: Scripting Answers

(07-26-2011, 11:14 AM)Saffire192 Wrote: Ok so this will start off being totally off topic but, i teach drums and i do session recording for a living, as a hobby i script and do level design using the UDK, ive got the hang of HPL and the script, i am trying to figure out the , for, if, else, else if, statements, so far this has told me what they mean, but your examples lack allot of elaboration, example: you have given examples but they lack context to me, like if i was teaching a student drums and i would play a drumbeat really fast and expect them to understand it, i would like to ask what are these statements used for?

it needs more explanation other then just examples, im not having a go i just think you need to elaborate on the context is all.

"if" statements are used in the same way people question things. If 1 + 1 = 2, then unlock a door. To make that a little more involved, I'll say that once the player collides with "Area1" and "Area2", then "Door1" is unlocked.

void OnStart()
{
     SetLocalVarInt("Var01", 0);
     AddEntityCollideCallback("Player", "Area1", "Func01", true, 1);
     AddEntityCollideCallback("Player", "Area2", "Func01", true, 1);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     AddLocalVarInt("Var01", 1);
     Func02();
}
void Func02()
{
     if (GetLocalVarInt("Var01") == 2)
     {
          SetSwingDoorLocked("Door1", false, true);
          PlaySoundAtEntity("", "unlock_door.snt", "Door1", 0, false);
     }
}

I'll try a more "numberized" code. You also have to remember when putting the equal sign in an "if" statement, you need double equal signs ( == ).

void OnStart()
{
     int x = 1, y = 2, z = 3;
     if (x + y == 2)
     {
          x = x + 1;
     }
     else if (y - x + z == 1)
     {
          y = y + 2;
     }
     else
     {
          z = z - 1;
     }
}

If I follow this correctly based on their value, x + y = 3, so the first statement is skipped, so it moves on to the second. y - x + z = 4, so the "else if" statement is wrong. Now we move on the "else" statement. Since the variables didn't equal correctly the way the "if" and "else if" statements were, it is forced to do what is in the "else" statement. So z = 2 now.

I hope this helps at least somewhat. Smile

07-26-2011, 12:23 PM
Find


Messages In This Thread
Scripting Answers - by Kyle - 05-10-2011, 07:03 PM
RE: Scripting Answers - by Simpanra - 05-10-2011, 07:21 PM
RE: Scripting Answers - by Kyle - 05-10-2011, 07:38 PM
RE: Scripting Answers - by Simpanra - 05-10-2011, 07:58 PM
RE: Scripting Answers - by Tesseract - 07-26-2011, 11:14 AM
RE: Scripting Answers - by Kyle - 07-26-2011, 12:23 PM
RE: Scripting Answers - by Tesseract - 07-26-2011, 01:06 PM
RE: Scripting Answers - by HumiliatioN - 07-26-2011, 01:12 PM
RE: Scripting Answers - by Tesseract - 07-26-2011, 01:16 PM
RE: Scripting Answers - by Kyle - 07-26-2011, 01:34 PM
RE: Scripting Answers - by HumiliatioN - 07-26-2011, 01:35 PM



Users browsing this thread: 1 Guest(s)