So when I replaced my original line with that one I get "main.lua:3: attempt to index global 'register' (a nil value)Robin wrote:love.filesystem.load works differently than require, mainly in these three ways:This fixes the first one, I was too lazy to look further:
- 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).
register["box"] = love.filesystem.load( ents.objpath .. "/box.lua" )
[SOLVED]Trouble running lua files.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
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.
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
So when I did that I got the error"entities.lua:11: File entitieszepp.lua does not exist"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.
I could have also made a typo somewhere, so I will look further into that too. Thanks

- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
I guess you're missing a / there before zepp.lua. 

Help us help you: attach a .love.
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
*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
but that still gets me the same error except with a / before .lua. Thanks 
Code: Select all
return love.filesystem.load( ents.objpath .. name .. "/.lua" )()

- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
Well, you don't have a file called ".lua", do you?
You probably want
You probably want
Code: Select all
return love.filesystem.load( ents.objpath .. "/" .. name .. ".lua" )()
Help us help you: attach a .love.
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
It is now working! Thanks sooo much! 

Who is online
Users browsing this forum: Ahrefs [Bot], mml and 12 guests