Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Lua loadfile() not working with Zip files


Recommended Posts

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?

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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...