Data

Monkey Forums/Monkey Programming/Data

smilertoo(Posted 2012) [#1]
I've searched the docs but i cant seem to find details about how monkey does Data statements, is it doing them under a new name?


Xaron(Posted 2012) [#2]
Monkey does not have a Data statement.


Gerry Quinn(Posted 2012) [#3]
Data is not even a reserved keyword, and there are no labels or Read statements in Monkey either. So I'm guessing no chance it will come.

Here is one way you might do something equivalent in Monkey:

levels:LevelData[] = New LevelData[ 100 ]
levels[ 0 ] = New LevelData( 40, 7.5, ALIEN_SCOUT, "We will destroy all humans!" )
levels[ 1 ] = New LevelData( 60, 8.0, ALIEN_SOLDIER, "Prepare to die!" )
'...more levels

' New level at runtime
level = New Level( levels[ currentLevel ] )


LevelData is just a simple class with four fields and the constructor used above. And Level has a constructor (or initialiser) that takes a LevelData parameter.