Problem with LoadString at runtime
Monkey Forums/Monkey Programming/Problem with LoadString at runtime
| ||
Hello, I load my level from an xml file and everything works as expected the first time. Then I want change a value in the xml-file, save it and use the LoadString() command to reload the file. monkey code Import mojo Class MyGame Extends App Field text:String Method OnCreate() SetUpdateRate 60 text = LoadString("file.xml") End Method OnUpdate() If KeyHit(KEY_1) text = LoadString("untitled.xml") Print text End End Method OnRender() DrawText text, 0,0 End End Function Main() New MyGame End file.xml <this> <x>30</x> </this> Try to change something in the xml file, save it and press 1 in game. Nothing will change. Monkey will not reload the value until you completely restart your game. Is this the wanted behaviour? |
| ||
Do you change the right XML file? The one in data folder is not the one that is loaded at runtime. |
| ||
are you building an HTML5? if you are, you won't see any changes until you reload the page. |
| ||
Is this the wanted behaviour? Yes, becouse some targets embed text files into the source code, so a recompilation is needed. |
| ||
@anawiki: Thanks, totally forgot that. Yes, becouse some targets embed text files into the source code, so a recompilation is needed. I heard that ios doesn't allow scripting languages. But that doesn't mean you can't write your own (not native) scripting language? |
| ||
Reloading at runtime in glfw works ... you just have to use this path instead of the data folder (on OSX): projectname/projectname.build/glfw/xcode/build/Debug/MonkeyGame.app/Contents/Resources/data In html5 as ziggy mentioned I think the data is embedded into the source file. |
| ||
ios does allow scripting langauges, it was something they reversed. Many other cross platform development systems, like Corona SDK, use a scripting language. Apple just has a vendetta against flash for some reason. |
| ||
Its good to know that in order to load a text file the file ending of the text file must be .txt Ive being breaking my head yet for another hour just to figure that out err what a waist |
| ||
file ending of the text file must be .txt Also xml and json works. /docs/modules/index.html#/mojo.app/LoadString Monkey will only load files that end with the following file extensions: .txt, .xml, .json. Like all game data, text files must be saved in your project's .data folder or one of its sub-folders. |
| ||
good to know tnx |