beo6 Posted August 24, 2015 Share Posted August 24, 2015 Hello, lxFirebal69xl pointed out that the loadfile() function i used in the Notes.lua crashes the application. I tested it and it looks like loadfile can only load files that are placed normally in the game directory and not inside a zip-file. is this a bug or a feature? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 24, 2015 Share Posted August 24, 2015 loadfile() is a Lua function and it doesn't recognize any special file systems like the zip archives. There is a Leadwerks command Interpreter::ExecuteFile(filename) which will run a script. Use Import(filename) if you just want to execute the script once. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
beo6 Posted August 24, 2015 Author Share Posted August 24, 2015 thanks. i already thought so. i now changed it to use import(). My problem first was that import only gets executed once. But now i just add every loaded note into a table so i can read them later from there. not sure about memory usage there but i guess its not that bad for text only files. Quote Link to comment Share on other sites More sharing options...
reepblue Posted August 24, 2015 Share Posted August 24, 2015 You use import if you have collision defines or functions you wish to use throughout your code. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
beo6 Posted August 24, 2015 Author Share Posted August 24, 2015 i know. but since loadfile is not possible and io is not allowed in sandbox i am a bit out of better options here. Quote Link to comment Share on other sites More sharing options...
Josh Posted August 25, 2015 Share Posted August 25, 2015 Interpreter::ExecuteFile should work. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
beo6 Posted August 25, 2015 Author Share Posted August 25, 2015 interesting. yes that executes every time. one thing i liked about loadfile though is that i was able to load the note into a local variable. local luaFile = loadfile(documentPath) self.text = luaFile() i can't think about a way to only use local variables with the other approaches. ( using self.text = {"the text in the file"} ) ends in an error "attempt to index global 'self'" but as long as there is no variablename conflict it should be no problem. Quote Link to comment Share on other sites More sharing options...
Einlander Posted August 25, 2015 Share Posted August 25, 2015 I'm in the same position as be06. I would like to be able to use some of the Leadwerks read functions in the lua sandbox. If FileSystem:ReadFile and Stream:ReadString() was available in sandbox, I would have the PERFECT work around for loadfile. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.