After dealing with copy/pasting very simple lines of code jsut to get multiple AI to do something all at the same time, i really want to know how to create an array of AI. or an array in MOH period.
i tried
level.array[] = { ... )
i tried
level.array = { .. }
and all that, but it isn't working.
it'd be a lot easier if there was a way to store AI in an array.
Array of AI?
Moderator: Moderators
Array of AI?
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
Read script files.txt
Arrays
======
Standard usage
--------------
nonident_prim_expr [ expr ]
nonident_prim_expr is a non-identify primitive expression and expr is an arbitrary expression.
nonident_prim_expr [ expr ] interprets nonident_prim_expr as an array and accesses the element at the position at which expr evaluates to.
Indexing of arrays can be by integers or strings.
Types of arrays
---------------
1) Constant array
Created by expression of the form entry_1::entry_2::entry_3:: ... :: entry_n
Constant arrays start their indexing at 1.
Once created a constant array can not be changed but it can be read for its values.
2) Hash table array
Unitialised entries evaluate to NIL. Any new entry can be set.
3) Targetname array
Created by the $ targetname operator if more than one entity exists for that targetname.
For example, $player is an array if more than one player is in the game.
Targetname arrays start their indexing at 1.
Examples
--------
println local.n[10] // prints the element at position 10 of the local.n array
local.n[1][3] = 10 // sets the element at position (1, 3) of the local.n array equal to 10 (Hash table array)
local.n = hello::world::this::is:
:test::123 // consant array
println local.n[1] // prints hello
println local.n[7] // prints 123
println local.n[8] // results in Script Error: const array index '8' out of range
println local.n[hello] // results in Script Error: const array index '0' out of range
local.n[hello][world][5] = 23
local.a = local.n[hello]
local.b = local.a[world]
println local.b[5] // prints 23
for (local.n = 1; local.n <= 10; local.n++)
println game.stats[game.stats_name[local.n]] // print out element in game.stats array at position game.stats_name[local.n]
local.a = (a::b)::c
println local.a[1][1] // prints a
println local.a[1][2] // prints b
println local.a[2] // prints c
Vector Examples
---------------
Vectors are accessed like arrays in the indices 0, 1, 2.
A vector could be set like
local.my_vector = (10 -2 60.1)
Then this vector could be accessed like:
println local.n[2]
which would print 60.1 to the console.
Example
-------
$player.origin += (5 6 7) // offset the player's origin by (5 6 7).
Make Array Example
------------------
local.Path1 = makeArray
t1 300 10 200
t2
t3
t4
t5
t6
t7 NIL 10 200
t8
t9
t10
t11
t12
t13
t14 0 10 200
endArray
println local.Path1[1][2]
println local.Path1[1][3]
println local.Path1[1][4]
println local.Path1[1][5]
println local.Path1[14][1]
println local.Path1[15][1]
end
results in:
300
10
200
NIL
t14
NIL
printed to console.
Arrays
======
Standard usage
--------------
nonident_prim_expr [ expr ]
nonident_prim_expr is a non-identify primitive expression and expr is an arbitrary expression.
nonident_prim_expr [ expr ] interprets nonident_prim_expr as an array and accesses the element at the position at which expr evaluates to.
Indexing of arrays can be by integers or strings.
Types of arrays
---------------
1) Constant array
Created by expression of the form entry_1::entry_2::entry_3:: ... :: entry_n
Constant arrays start their indexing at 1.
Once created a constant array can not be changed but it can be read for its values.
2) Hash table array
Unitialised entries evaluate to NIL. Any new entry can be set.
3) Targetname array
Created by the $ targetname operator if more than one entity exists for that targetname.
For example, $player is an array if more than one player is in the game.
Targetname arrays start their indexing at 1.
Examples
--------
println local.n[10] // prints the element at position 10 of the local.n array
local.n[1][3] = 10 // sets the element at position (1, 3) of the local.n array equal to 10 (Hash table array)
local.n = hello::world::this::is:
println local.n[1] // prints hello
println local.n[7] // prints 123
println local.n[8] // results in Script Error: const array index '8' out of range
println local.n[hello] // results in Script Error: const array index '0' out of range
local.n[hello][world][5] = 23
local.a = local.n[hello]
local.b = local.a[world]
println local.b[5] // prints 23
for (local.n = 1; local.n <= 10; local.n++)
println game.stats[game.stats_name[local.n]] // print out element in game.stats array at position game.stats_name[local.n]
local.a = (a::b)::c
println local.a[1][1] // prints a
println local.a[1][2] // prints b
println local.a[2] // prints c
Vector Examples
---------------
Vectors are accessed like arrays in the indices 0, 1, 2.
A vector could be set like
local.my_vector = (10 -2 60.1)
Then this vector could be accessed like:
println local.n[2]
which would print 60.1 to the console.
Example
-------
$player.origin += (5 6 7) // offset the player's origin by (5 6 7).
Make Array Example
------------------
local.Path1 = makeArray
t1 300 10 200
t2
t3
t4
t5
t6
t7 NIL 10 200
t8
t9
t10
t11
t12
t13
t14 0 10 200
endArray
println local.Path1[1][2]
println local.Path1[1][3]
println local.Path1[1][4]
println local.Path1[1][5]
println local.Path1[14][1]
println local.Path1[15][1]
end
results in:
300
10
200
NIL
t14
NIL
printed to console.
Well you don't have to actually init it, you can use it right away:
level.array[1] = level.friendly1
level.array[2] = level.friendly2
level.array[3]= $german5
You can use any integer or string index, doesn't have to be in order and you could skip entries.
Or, you could do:
level.array = level.friendly1::level.friendly2::$german5
Which has a fixed size, indexing starts at 1.

level.array[1] = level.friendly1
level.array[2] = level.friendly2
level.array[3]= $german5
You can use any integer or string index, doesn't have to be in order and you could skip entries.
Or, you could do:
level.array = level.friendly1::level.friendly2::$german5
Which has a fixed size, indexing starts at 1.
