Monkey can't understand some os command

Monkey Forums/Monkey Programming/Monkey can't understand some os command

Zurrr(Posted 2012) [#1]
Could you tell me why I got this error

Compile Error
Identifier 'SaveString' not found.


My code is
[monkeycode]
Import mojo
Import os
Class TestSaveData Extends App

Field data:String

Method OnCreate()
SetUpdateRate 60

'Loading data from file if available
data=LoadString("datafile")
If data=""
data="newdata"
Endif

'Saving data to a file
SaveString(data,"datafile")
ExitApp(0)

End

Method OnUpdate()
End

Method OnRender()
End
End

Function Main()
New TestSaveData
End
[/monkeycode]


Jesse(Posted 2012) [#2]
there is no SaveString, use LoadState/SaveState.


Cygnus(Posted 2012) [#3]
There is SaveString- just use "os.SaveString" - but this is only valid on GLFW and one other (stdcpp?) platform.


Zurrr(Posted 2012) [#4]
I m new to monkey

Where should we keep our level data?
And ho do we read it? Tnks


Volker(Posted 2012) [#5]
I m new to monkey

Welcome aboard.
Where should we keep our level data?

Take a look at SaveState()
And ho do we read it?

Look at LoadState()

Cross platform you can only use this commands.
You have to encode all your data to one string to save it.

There is a complete faked filesystem here:
http://www.monkeycoder.co.nz/Community/post.php?topic=1395&post=14840
It's although included in diddy.


Jesse(Posted 2012) [#6]
if you want to keep everything to to work on all platforms your data should be kept in the standard data folder where you have your media etc. example: <game name>.data "<game name>" is the name of your main game file name.


Zurrr(Posted 2012) [#7]
Now I understand about SaveState/LoadState. Thanks.
SaveState() saving what happen on the game after running and LoadState() can load it again another time.

The one that I want to load is my level data. Its my preset text info. I can use it to create a game puzzle on level by level basis. I can't use LoadState() because it not there yet unless I put it there using SaveState() but I need to load that data first in order for me to put it there using SaveState() lol

Btw.. I can still put that data in my string. It just nice if I can put it on file and load it whenever I want andI can design my game level using that text file only.


Cygnus(Posted 2012) [#8]
I just tackled this problem myself:

http://www.monkeycoder.co.nz/Community/posts.php?topic=3319#34803

It's based off the fake filesystem but this will allow you to read files you've put in your data folder.

Remember to edit config.txt so that your data files are in the file filters, otherwise they will not be copied to the build!


Volker(Posted 2012) [#9]
You can use LoadString() cross platform to load
your textfiles. Not the one from the os module, but
that from mojo. Just import mojo.
The textfiles have to be in your .data folder.