Page 1 of 2
Scripting Manual
Posted: Mon Jul 22, 2002 12:50 am
by Mirek
Hi All,
Here is an idea following on the Texture browser idea in the mapping forum.
How about a scripting version???
What I mean is to start an online manual for the scripting language where the raw basics are layed out.
i.e. operators & functions with explanation and example of use.
My aim is to build mostly single player maps and I have spent hours going through the .scr files in the original MOHAA maps and although I am starting to slowly understand things and I can "copy" ideas into my own maps, I lack the basic understanding of the syntax and operators to write my own scripts.
Not having much programming expierience I am sure that with a few more months of endless testing and experimanation I'll eventually get it but it takes long enough to create the visual side of the map if you aim for quality....
I belive something like I propose here would no doubt benefit people with little programming expierience and let all get along quicker with completing and sharing maps instead of spending months working out how to do things only to find that by the time their finished no one is interested anymore.
More maps to share = more fun.
It would also give this site something no one else has got.
WHAT DO YOU THINK???
Cheers
Mirek
Hmmm...
Posted: Mon Jul 22, 2002 3:55 am
by tltrude
It would be nice to have, but I don't think it will happen. Programing this stuff takes more than a list syntax words. People go to school for years to learn it. It is almost an art form in its complexity. Although we amateurs can learn enough to copy and paste what is needed into our scripts, we will never master it completely without formal education of some kind.
True but ......
Posted: Mon Jul 22, 2002 4:22 am
by Mirek
I'm sure it's complex but I do belive an effort can be made so that us Plebs can get something out if it.
Cheers
Mirek
Posted: Mon Jul 22, 2002 6:34 am
by NathanielPT
There is a file that comes with the SDK that explains the basic operators and program flow keywords. I believe it is called Script Files.txt. It is in the docs folder where you installed radiant. If you don't have it I can email it to you, it is only 18K unzipped. It is of some help, especially to those of use who program in Basic type languages and have trouble remembering how to things in C type languages. It should help a little. I have started a HTML tutorial that explains how to use some basic scripting commands to do things like: music, changing background sound, moving brushes, things like that. But it is slow work. Hope this was of some help.
Headache
Posted: Mon Jul 22, 2002 8:16 am
by tltrude
Oh yeah, that file gives me a headache big time. If it were only written in english!!!
Ok, here is a question:
Does "!= inequality (outputs 0 or 1)" mean "does not equal"? Also, what does "++" do, add one to the number?
Example
-------
local.n = 1 // This creates variable n, I think
while (local.n <= 10) // might be a countdown
{
println local.n // I guess this prints the current number
local.n++ //?
}
Posted: Mon Jul 22, 2002 9:55 am
by Surgeon
!= does mean does not equal i.e
if local.n != 1
println local.n
If local.n is not equal to 1 print the value of local.n
The second part - yes its basically a countdown
Example
-------
local.n = 1 // This creates variable n, and sets its value to 1.
while (local.n <= 10) // Whiile local.n is less than / equal 10
{
println local.n // print local.n
local.n++ // Add 1 to local.n.
}
This is a basic while loop - it will continue to print local.n and adding 1 to local.n until local.n is 11.
cool
Posted: Wed Jul 24, 2002 12:33 am
by tltrude
Cool, I guessed right!! Ok, now can you explain how the "while" statement is used in the objective map scripts. I mean, how does the script keep checking to see if the bomb is exploded? Does the "while" just run automattically without a loop? Hopefully, you can shed some light on "level" and "local" as well.
Example from obj_team3
-------
//*** --------------------------------------------
//*** "Axis Victory"
//*** --------------------------------------------
axis_win_timer:
level waittill axiswin // prevents the game from ending until the timer runs out.
end
//*** --------------------------------------------
//*** "Allied Victory"
//*** --------------------------------------------
allies_win_bomb local.bomb1 local.bomb2: //why were $bomb1 and $bomb2 assigned these new names just as the game started?
while (local.bomb1.exploded != 1)
waitframe // why are there no brackets?
while (local.bomb2.exploded != 1)
waitframe
teamwin allies
end
//*** --------------------------------------------
//*** "Bomb 1 Exploded"
//*** --------------------------------------------
bomb1_exploded local.bomb1:
while (local.bomb1.exploded != 1)
wait .1 // checks bomb every .1 seconds?
iprintlnbold "Allies have destroyed the Western Cannon!"
$spawn_axis2 disablespawn // these are cool
$spawn_axis3 enablespawn // they move axis spawning spots closer if $bomb1 has gone off.
end
//*** --------------------------------------------
//*** "Bomb 2 Exploded"
//*** --------------------------------------------
bomb2_exploded local.bomb2:
while (local.bomb2.exploded != 1)
wait .1
iprintlnbold "Allies have destroyed the Eastern Cannon!"
$spawn_axis2 disablespawn
$spawn_axis4 enablespawn
end
Posted: Wed Jul 24, 2002 6:37 pm
by Wombat
allies_win_bomb local.bomb1 local.bomb2: //why were $bomb1 and $bomb2 assigned these new names just as the game started?
These are the parameters the thread needs to run. they are given local.bomb1 tags, and are totally independent of other local.bomb1 tags in other threads.
If they were level.bomb1 then that is a global variable, and is accessable from any thread
when the thread is called the parameters are passed
ie
allies_win_bomb $bomb1 $bomb2
if the entity is before the threadname, then the thread can refer to that object as 'self'
ie
$bomb1 thread global/obj_dm.scr::bomb_thinker
Thee are no curly brackets around the while () loop as it only has one line of code, ( i think ), followed by a blank line.
$
Posted: Wed Jul 24, 2002 9:33 pm
by tltrude
Sorry to keep bugging you, but I'm learning so much!!!
So, "$" is the same as "level"?
$name = global map entity
level.name = global script entity
local.name = independent script entity
self = name used if more than one entity can use the thread
If I'm right, "self.exploded = 1" must be in the obj_dm.scr somewhere... Yep, it was there all along. Wow, that helps a lot!!!
Thanks
Yo !!!!
Posted: Thu Jul 25, 2002 1:14 am
by Mirek
This is sort of what I was thinking about
I am aware of the file (Script Files.txt) and I too get a headache - If anything I was just thinking of starting something online that will extend on that file and grows to something that may be used as a good refrence guide to describe usage and show examples.
Cheers
Mirek
Posted: Sat Jul 27, 2002 4:55 pm
by Wombat
So, "$" is the same as "level"?
No. $myname means access an entity in the bsp whose targetname is myname
level.name = global script variable. accessible from any thread in the script.
local.name = thread local script variable, only accessible from THE thread
self = name used if more than one entity can use the thread
YES! makes the script, multipurpose....
Just worked out the glue command
Use it to stick entity's together, so they move as one.
ie a trigger for an elevator. in the elevator car.
ai to drive truck etc....
usage
( stick this ) glue ( to this )
ie
$trigger glue $elevator
i used it to attach a deathzone to a script_model (rock), so when it hits you, you die...( for exploders )
rock
Posted: Sun Jul 28, 2002 6:14 am
by tltrude
That sounds really cool Wambat--now we have to dodge rocks, ha ha! Guess you need to make a "Beware of Falling Rocks" sign now.
That glue thing is in the m3 Ohmaha map for glueing frendlies into the higgens boat. There is also a thing in that script that glues the player to his spot in the boat until the door drops--kind of neat too. But I have been using "bind" a lot ( stitch this targetname) bind ( to this entity).
Posted: Sun Jul 28, 2002 6:16 pm
by NathanielPT
So what is the difference between glue and bind? I use bind to attach entities together, mainly script_objects. But it doesn't work for the player. Maybe glue is like bind for the player and ai. But, if it will work for entities too then why have both of them?
Posted: Mon Jul 29, 2002 4:05 am
by Wombat
bind probably works for brushs to brushs ( script_object to script_object)
glue works for brushs to entitys ( triggers to script_objects/models )
attachmodel works for model to model ( script_model to model )
unglue
Posted: Mon Jul 29, 2002 4:57 am
by tltrude
Bind works with anything that has a targetname (triggers too). Here are the lines from m3L1a:
//*** glue the player to the higgins boat
$player glue $higgins1_playerspot 0
$player physics_off
and further down:
//*** release the player
$player unglue
$player physics_on
This is kind of cool, they use moving clip brushes to force the player out of the boat:
//*** bind the playerspot to higgins1
$higgins1_playerspot bind $higgins1_clip
//*** bind the player pusher to higgins1
$higgins1_clip_player bind $higgins1_clip
//*** start the player pusher
$higgins1_clip_player time 3
$higgins1_clip_player movenorth 340
$higgins1_clip_player move
There is also an "unbind" command. I think the glue command is just for players and AI, but I guess it can work for other entities as well.
Hey, I just found this and it looks useful:
$shingle_ranger1 turnto $higgins1_clip