something.lvl

Blitz3D Forums/Blitz3D Programming/something.lvl

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Seems like you are trying to write multiple Lines to a file, as seen in PHP or Pearl. In Blitz this doesn't work, Especially not with writeInt. WriteInt writes a single 32 Bit Number value to a file. That's why it says Bracket problem, you got 3 Brackets on one line, but the number of brackets always needs to be even and there need to be as many opening brackets as closing brackets,
like a = ((( b+2 )))

Anyway, if you really want to write Blitz Code to a file, then you'll need to include it in a sourcecode later. You would then have to do it this way:

areas = WriteFile("areas.kio") 
Writeline areas, "dine=LoadMesh( "+chr$(34)+"dine.3ds"+chr$(34)+")"
Writeline areas, "ScaleEntity dine,3,3,3 "
Writeline areas, "PositionEntity dine,0,0.2,0 "
Writeline areas, "EntityAutoFade dine,70,140" 

Writeline areas, "hall=LoadMesh( "+chr$(34)+"hall.3ds"+chr$(34)+" )"
Writeline areas, "ScaleEntity hall,3,3,3"
Writeline areas, "PositionEntity hall,0,0.2,0"
Writeline areas, "EntityAutoFade hall,70,140"


CloseFile( areas ) 


as you can see, the strings you want to write to a file need to be enclosed by "". When there is a " inside a string you want to save, you need to encode it this way:
"+chr$(34)+"

But as far as I see, you lvl File should serve an other purpose, you want to load a level, right? So maybe you better only save the parameters of the commands, and not the commands.

Instead of writing the loading and scaling rigth into the code, you maybe better make an editor that can open a fileselector, then loads a mesh and lets you position and scale it. Then you can add a function that will save all mesh filepaths, locations, scaling values etc. to a file. Then you can create a loader that is reading that file and restores the world as you have saved it. Creating a loader from a saver is pretty simple, mainly just alter the WriteLine to ReadLine.