[SOLVED]Trouble running lua files.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post 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)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post 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.
Help us help you: attach a .love.
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post 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 :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post by Robin »

I guess you're missing a / there before zepp.lua. ;)
Help us help you: attach a .love.
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post 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 :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post 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" )()
Help us help you: attach a .love.
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post by redhood56_ »

It is now working! Thanks sooo much! :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests