I have my tilemap editor loading and saving maps perfectly.
The thing is it's only perfect if I pick the correct file.
Take a look at this code. This is part of the mapfile loading.
I store the maps in a type and assign an ID "number from 0 and above".
The offending bit of code is here.
Basically I store what GetChar gets in Line$.
I then use an eachin loop to detect if line = f.id.
If it equals f.id it loads the correct map according to what number was input. When I add an...
else
end
it quits even if the correct f.id was picked.
Why is it doing this?
The thing is it's only perfect if I pick the correct file.
Take a look at this code. This is part of the mapfile loading.
Function SelectMap() If TFile.DoneLoadingMaps = 1 Local Line$ Local MapIdSelected:Int = 0 Local LoadTheMap:Int = 0 Local f2:TStream Local File:String Local f:String Repeat Cls For Local f:TFile = EachIn TFile.FList f.DrawMapName Next If KeyHit(KEY_ESCAPE) TFile.DoLoadMap = 0 For Local f:TFile = EachIn TFile.FList f.id = 0 Next TFile.FList = Null TFile.TempID = 0 TFile.TempY = 100 TFile.DoneLoadingMaps = 0 Exit End If Local OutputText:String = " Enter Map Number to Load : " + Line$ DrawText OutputText, 280, 500 If MilliSecs() mod 800 < 400 Then DrawRect(280 + TextWidth(OutputText), 500, 2, TextHeight("|")) Flip Local char:Int = GetChar() If char<>0 Then 'Print char 'Debug porpouses, check for spetial characters not being displayed in the BM window becouse of a incomplet default font. Select True Case char >= 32 Line$ :+ Chr(char) Case char = 8 ' backspace Line$ = Line$[..Line$.length - 1] Case (char = 27) ' or (char = 13) ' escape and enter Line$ = Null Case (char = 13) MapIdselected = 1 Exit End Select EndIf Forever If MapIdSelected = 1 'TTile2.MapClearMap Print "2" For Local f:TFile = EachIn TFile.FList Print "3" If Line$ = f.id Print "4" File = f.MapName f2 = ReadFile("usermaps/" + File) For Local y:Int = 0 Until FMHeight For Local x:Int = 0 Until FMWIDTH FactoryMap[x, y].id = Readint(f2) Next Next Print "Yay - Loaded" Else End EndIf Next If MapIdSelected = 1 CloseFile(f2) MapIdSelected = 0 TFile.DoLoadMap = 0 For Local f:TFile = EachIn TFile.FList f.id = 0 Next TFile.FList = Null TFile.TempID = 0 TFile.TempY = 100 TFile.DoneLoadingMaps = 0 EndIf End If EndIf End Function End Type
I store the maps in a type and assign an ID "number from 0 and above".
The offending bit of code is here.
If MapIdSelected = 1 'TTile2.MapClearMap Print "2" For Local f:TFile = EachIn TFile.FList Print "3" If Line$ = f.id Print "4" File = f.MapName f2 = ReadFile("usermaps/" + File) For Local y:Int = 0 Until FMHeight For Local x:Int = 0 Until FMWIDTH FactoryMap[x, y].id = Readint(f2) Next Next Print "Yay - Loaded" Else End EndIf Next
Basically I store what GetChar gets in Line$.
I then use an eachin loop to detect if line = f.id.
If it equals f.id it loads the correct map according to what number was input. When I add an...
else
end
it quits even if the correct f.id was picked.
Why is it doing this?