Just a n00b question

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Just a n00b question

Post by Runt »

Why are those "{" and "}" Needed in scripts ?
blue60007
General
Posts: 1247
Joined: Sun Mar 07, 2004 11:44 pm

Post by blue60007 »

They are containers.

Say you have an if statement:

Code: Select all


if(level.somevar==1)
{
//do this
//then that
//and finally this
}
Put code in them following something like that, this way the engine knows what code goes with it.

I'm not sure if the Q3 engine works like this or not, but if you have one line of code with it you can do:

Code: Select all

if(level.somevar==1)
//dothis
Somethings that works on, others it doesn't. The script is based on C++, and that works in C++, but I'm not 100% sure if it works in MOHAA script.
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

A lot of commands ( like if, while and for ) decides what happens to the next statement... and it you do not use { & } the next statement is the next line... if you want any of these control statements to controle more than one line, you need to enclose the lines with a { & a }....
Admin .MAP Forums
Image
Head above heels.
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

ok thx for helping :wink:

*edit* oh forgot to ask :

Why are these :: in scripts?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

when you call an exec or thread statement from anotehr script off from the one you're writing, like so

exec global/ai.scr

sometimes you need to only cal a specific thread. so to spawn something the easy way...

thread global/ai.scr::spawnset 1
1 2 3

1. the command, only calls oen thread.
2. the path for the script. global is the generic path.
3. the thread in the ai.scr to call.

:)
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

But why it doesn't work like this:

thread global/ai.scr spawnset 1
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

it's all syntax mate. don't question it, compilers and computer language need keywords and stuff. we don't make the rules. :wink:
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

lol ok :D
Post Reply