What I would call strange is if you were treating local.ai itself as an array by doing say 'local.ai[local.ai.index]["sequence"]', since local.ai is of type Actor, not "two-dimensional array".
To confirm my theory that doing something like '$player[local.player_index][local.some_other_index]' is not possible, I used the following code:
Code: Select all
for (local.i = 1; local.i <= $player.size; local.i++) {
local.player = $player[local.i]
// test 1: access a normal field of the Player object
iprintln_noloc "Player " local.i " health is " local.player.health
// test 2: treat the Player object as an array and try and set the value of the first element of the array
local.player[1] = 123
iprintln_noloc "...value of testing_array_index " local.player[1]
// create a constant array and make local.const_array refer to it
local.const_array = 1::2::3
// make local.var_array refer to a variable array
local.var_array[1] = 1
local.var_array[2] = 2
// test 3: treat local.const_array as an object
iprintln_noloc "Accessing classname of const array: " local.const_array.classname
// test 4: treat local.var_array as an object
iprintln_noloc "Accessing classname of var array: " local.var_array.classnameCode: Select all
Player 1 health is 100.000Code: Select all
...value of testing_array_index player
Accessing classname of const array: NIL
Accessing classname of var array: NIL
local.player[1] = 123 (maps/obj/obj_team4.scr, 71)
local.player^
^~^~^ Script Error: [] applied to invalid type 'listener'
iprintln_noloc "Accessing classname of const array: " local.const_array.classname (maps/obj/obj_team4.scr, 77)
iprintln_noloc "Accessing classname of const array: " local.const_array^
^~^~^ Script Error: Cannot cast 'const array' to listener
iprintln_noloc "Accessing classname of var array: " local.var_array.classname (maps/obj/obj_team4.scr, 78)
iprintln_noloc "Accessing classname of var array: " local.var_array^
^~^~^ Script Error: Cannot cast 'array' to listenerTest 2: You can see that when I tried to set local.player[1] it said that [] should not be applied to a 'listener', or object, since it's meant to be applied to an array.
Test 3: Here you can see that I couldn't get the classname of the constant array because it's of type 'const array', not 'listener'.
Test 4: Similarly you can see I couldn't get the classname because it's of type 'array'.
So, I am happy to say that these results prove that MOH's scripting language has a conventional type system where a variable is of a particular type and cannot be simultaneously of two different types (i.e. an array and an object). I would have been freaked out otherwise
Regards,
David
