Tutorial: Scripting ( all of it )
Moderator: Moderators
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
FforrestGump
- Lance Corporal
- Posts: 17
- Joined: Fri May 23, 2003 1:15 pm
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
...there ARE examples... what more exactly do you need exemplified? Be specific please.Jagdtiger wrote:However, you might want to include an "example script" and show where each part of your tutorial fits into it, for people like me who are cluelesswhen it come to scripting.
Not really shure what you mean by thisJagdtiger wrote:Lastly, a list of all the exec global commands and what they do would be most helpful(PLEASE![]()
![]()
![]()
).
Do you mean like exec global/DMprecache.scr?
You can execute ANY script like this... thake a look in the standard *.pk3 files to see all the shipped scripts.
But I guess you want to know what it DOES, right? Well... learn the scripting language and you will be able to read what they do for your self...
- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
Ok, you lost me with array examples right here:
local.n[variableOne][variableTwo][5] = 23
local.a = local.n[variableOne]
local.b = local.a[variableTwo]
println local.b[5] // prints 23
I don't quite understand the function here. Are the second and third lines defining variableOne and variableTwo, or are they referencing them within local.n ? I also can't wrap around my head why println local.b[5] would display 23 unless the previous two lines are something like if statements... actually, I just don't know what's going on there. yeah...
local.n[variableOne][variableTwo][5] = 23
local.a = local.n[variableOne]
local.b = local.a[variableTwo]
println local.b[5] // prints 23
I don't quite understand the function here. Are the second and third lines defining variableOne and variableTwo, or are they referencing them within local.n ? I also can't wrap around my head why println local.b[5] would display 23 unless the previous two lines are something like if statements... actually, I just don't know what's going on there. yeah...
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
This is a hairy example... and if someone would actually use code like tis in a script, they have probably just learned scripting and are showing off....chris_in_cali wrote:Ok, you lost me with array examples right here:
local.n[variableOne][variableTwo][5] = 23
local.a = local.n[variableOne]
local.b = local.a[variableTwo]
println local.b[5] // prints 23
I don't quite understand the function here. Are the second and third lines defining variableOne and variableTwo, or are they referencing them within local.n ? I also can't wrap around my head why println local.b[5] would display 23 unless the previous two lines are something like if statements... actually, I just don't know what's going on there. yeah...
Here is what happens:
saying local.n[3][1][7] = 35 is saying local.n is an array, give me the variable at index 3
The variable at index 3 is also an array, give me the variable at index 1
The variable at index 1 is also an array, give me the variable at index 7
Set the variable at index 7 to the value 35
In the example above this is done in separate steps:
// Get way in there and set the variable to 23
local.n[variableOne][variableTwo][5] = 23
// Get one step in, and save the variable at index variableOne in local.a...
local.a = local.n[variableOne]
// Get one step in, and save the variable at index variableTwoin local.b...
local.b = local.a[variableTwo]
// Get one step in, and get the variable at index 5, and send it as a parameter to the println command.
println local.b[5]
A smarter and faster way to print it would be:
println local.n[variableOne][variableTwo][5]
Any clearer? If not, don't worry. Extreme arrays like this is seldom used... the only practical use of an array like this that I could imagine would be to store objects sorted in 3D space... but it would be a bad way to store them in most cases as it would use a very large piece of the memory...


