including a variable

Blitz3D Forums/Blitz3D Beginners Area/including a variable

"Include" is a static thing done at compile time, not a dynamic change at run time. To load separate levels during the game, define all the setup information for your levels in some sort of data file (the simplest would be a text file that lists the level mesh and the locations of all the enemies) and have a function load that data file and place all the meshes and what not according to that data (lookup ReadLine.) Then pass a variable to that function to define exactly which level file to load.

Something like:
LoadLevel("Level"+levelnum+".lvl")

Function LoadLevel(filename$)
  ClearWorld
  file=OpenFile filename
  level$=ReadLine file
  LoadMesh(level+".b3d")
;repeat previous two lines for rest of data
  CloseFile file
End Function