I agree with zeroSlave, and IanM's Matrix1 Utils are fatastic. You don't need Matrix1 Utils, the internal commands are pretty much all you need.
I'll give you a few examples of both loading and saving data to a level file. I use some specific naming conventions which are a very good idea. For example, placable objects like furniture are called Props. Players and Enemies are called Actors. Entities that control things like the operation of explosions, particles, opening of doors, etc. are called Effects. And so on...
The general idea shown below is that we take all the Props in the game and save the needed information into a file and later reload to rebuild the whole list.
All prop types have a file where all the details about what they do or look like are stored. That includes pathnames to all textures and 3D Objects.
The level file does not store this information. It stores the path to this file, where the prop is positioned, and 2 extra strings so the level editor can link doors and etc.
Saving All Props Here:
`Figure out how many props there are by finding the highest used index
PropLimit# = -1
For i = 0 to 999
If Master_StrCompare(Prop_List$(i,0),"") = 0 then PropLimit# = i
Next i
`Save Number of Props so we know how many to load
Write Float 1, PropLimit#
For i = 0 to Int(PropLimit#)
`Save the pathname to the Prop file (contains the props data)
Prop$ = Prop_List$(i,0)
Write String 1, Prop$
`Gather position and angle of Prop
pX# = 0
pY# = 0
pZ# = 0
aX# = 0
aY# = 0
aZ# = 0
If Object Exist(9000 + i)
pX# = Object Position X(9000 + i)
pY# = Object Position Y(9000 + i)
pZ# = Object Position Z(9000 + i)
aX# = Object Angle X(9000 + i)
aY# = Object Angle Y(9000 + i)
aZ# = Object Angle Z(9000 + i)
EndIf
`Save Position, Angle, and Tag Data
Write Float 1, pX#
Write Float 1, pY#
Write Float 1, pZ#
Write Float 1, aX#
Write Float 1, aY#
Write Float 1, aZ#
Write String 1, Prop_List$(i, 8)
Write String 1, Prop_List$(i, 9)
Next i
Now Loading All Props Here:
`Read variable that tells how many props to load.
Read Float 1, PropLimit#
For i = 0 to Int(PropLimit#)
`Update Screen with load progress info
Hud_LoadProgress("Loading World Objects - " + Str$(i) + " of " + Str$(PropLimit#) , 80)
`Load Information for the Prop at index i
Read String 1, Prop$
Read Float 1, pX#
Read Float 1, pY#
Read Float 1, pZ#
Read Float 1, aX#
Read Float 1, aY#
Read Float 1, aZ#
`Store Pathname to prop file in the prop list.
Prop_List$(i, 0) = Prop$
`create prop, i is the list index and the rest are position and angle.
Master_LoadProp(i, pX#, pY#, pZ#, aX#, aY#, aZ#)
MyObject = 9000 + i
`Add Effect for Respawn Generator
If Prop_List$(i, 1) = "14" and Object Exist(MyObject)
Position Object MyObject, pX#, pY#, pZ#
If VFX_CreateRespawn(MyObject, i, Prop_List$(i, 8), Val(Prop_List$(i, 9))) > -1 Then Actor_DeleteObject(MyObject)
EndIf
Next i
Edit:
I should mention that you need to use the "Open File" command in either situation.