Page 2 of 2

Re: Trouble running lua files.

Posted: Tue Jun 18, 2013 1:10 pm
by redhood56_
Robin wrote:love.filesystem.load works differently than require, mainly in these three ways:
  • The argument it gets is a file path, not a module name. (So "dir/mod.lua" instead of "dir.mod".)
  • It doesn't "cache" like require does. With require, if you try to load the same thing twice, it does nothing the second time.
  • It returns an executable "chunk" that runs the file, rather than run the file and return what the module returns (which is what require does).
This fixes the first one, I was too lazy to look further:
register["box"] = love.filesystem.load( ents.objpath .. "/box.lua" )
So when I replaced my original line with that one I get "main.lua:3: attempt to index global 'register' (a nil value)

Re: Trouble running lua files.

Posted: Tue Jun 18, 2013 11:52 pm
by Robin
We're getting somewhere. This means you're missing a register = {} above that line. (Either that, or you made a typo somewhere.) In Lua, names point to nil until you bind them to some other value. With the line register = {} you bind the name "register" to a new table value.

Re: Trouble running lua files.

Posted: Wed Jun 19, 2013 8:43 pm
by redhood56_
Robin wrote:We're getting somewhere. This means you're missing a register = {} above that line. (Either that, or you made a typo somewhere.) In Lua, names point to nil until you bind them to some other value. With the line register = {} you bind the name "register" to a new table value.
So when I did that I got the error"entities.lua:11: File entitieszepp.lua does not exist"
I could have also made a typo somewhere, so I will look further into that too. Thanks :)

Re: Trouble running lua files.

Posted: Wed Jun 19, 2013 8:50 pm
by Robin
I guess you're missing a / there before zepp.lua. ;)

Re: Trouble running lua files.

Posted: Wed Jun 19, 2013 11:12 pm
by redhood56_
*facepalm* how did I forget that! But I have another problem, I got a new error which says "entities.lua:15: File entitesbase.lua does not exist" now I added a / to the line

Code: Select all

return love.filesystem.load( ents.objpath .. name .. "/.lua" )()
but that still gets me the same error except with a / before .lua. Thanks :)

Re: Trouble running lua files.

Posted: Thu Jun 20, 2013 8:09 am
by Robin
Well, you don't have a file called ".lua", do you?

You probably want

Code: Select all

return love.filesystem.load( ents.objpath .. "/" .. name .. ".lua" )()

Re: Trouble running lua files.

Posted: Thu Jun 20, 2013 1:42 pm
by redhood56_
It is now working! Thanks sooo much! :)