Creating an object list with game scope

davidburden
In order to try and produce some reasonably neat code I want to set up my object lists once at the beginning of the game and then access them from functions and scripts as required.

For variables it seems simple, I just create an attribute for the game object and then access them as game.name. There also appears to be an option in the dropdown to create a StringList as an object/room attribute, but not an object list. If I create the objectlist using NewObjectList in a script in the game start script then I can appear to be able to assign it values using new list game.objectlistname from a function elsewhere in the game (or at least it doesn't throw an error), but if I try and access the list using ObjectListItem(game.objectlistname, dice) then it throws an error of Function Not Found ObjectListItem(Object, Int32). Likewise if I move the list value assignment into the start script. If however I put the objectlist creation and assignment and ObjectListItem all into the same function (which isn't really what I want) then it all works fine.

Am I missing something? Get the same problem on 5.0 and 5.1.

Otherwise great programme.

Alex
The Editor doesn't currently support editing object lists or object dictionaries, so they don't appear on the attribute drop-down. So creating these in your game start script is probably the best way to go.

Object lists are accessed by index, which is why you're getting the "function not found" error - the second parameter needs to be an integer, not a string or object.

I'm not sure what you're trying to do with the "ObjectListItem(game.objectlistname, dice)" - if you were trying to get the "dice" object, you don't need to fetch it from a list in the first place?

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums