Jump to content

Recommended Posts

Posted

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?

Posted

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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.

Posted

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.

Posted

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...