display.iconImage = SafeloadImage( "objects.png" )This now needs to be changed to.
display.iconImage = 0and the loading takes place within the outer if/elseif loop of the LoadObjectData() function.
if getFileExists( thisTextName$ ) and thisImageName$ <> "" // Both data files exist display.iconImage = SafeloadImage( thisImageName$ ) // Prepare temp array dim tempArray[ 1000 ] as stringThis uses the variable thisImageName$ rather than an absolute name.
We are almost ready to be able to see the loaded object in the game, there is just one more thing to add.
Since we are storing the groups in the same array as the standard objects, we need a quick way to identify them. This saves having to search the array each time we want an object group.
These can be stored in the same way group members are stored, as a string of Base96 Codes, and as with the group members, this needs to be done after the object array is set up so that the indexes are correct.
The group list is stored in a string field of the gameType UDT.
type GameType state level topObject groupObject$ endtypeIt has the usual return function.
function GameGroups() endfunction game.groupObject$And is set up in the Initialise() function.
game.groupObject$ = ""AND in the LoadObjectData() function.
// Group Memberships game.groupObject$ = "" for i=1 to topObject()All pretty familiar stuff by now.
Just inside the if ObjectIsGroup( i ) > 0 block, we put the line which adds the group to the list.
if ObjectIsGroup( i ) > 0 and ObjectDetail( i ) <> "" game.groupObject$ = game.groupObject$ + Base96Encode( i )This means that only groups which contain objects will be included in the group list.
After the for/next loop has completed, near the end of the function, the final list is sorted.
next i game.groupObject$ = Base96Sort( GameGroups() ) endif endfunction thisArraySizeNow we not only have a list of groups, but we know that they are only the groups with member objects.
No comments:
Post a Comment