[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
[SOLVED]Trouble running lua files.
Hello! Now I know there was a post very similar to this a couple months ago, but it didn't fix my problem. So I am using Goature's tutorial(http://www.youtube.com/watch?v=r0wmvsOI5bw<this part). Okay, since I understand that the code is dated, I downloaded it to see if I missed anything(I missed a line or two in the past parts). Because my version of the code didn't work, I tried the downloaded one. I also got errors. For the downloaded one, I got the error "make sure main.lua is at the top level of the zip". From what I got from the other thread, love2d is case sensitive. The downloaded code's main.lua is actually main(2).lua. When I try to rename them so it is just main.lua I got the other error. Image here: download/file.php?mode=view&id=23054. For my version I got this error:download/file.php?mode=view&id=23055. And when I switch the the lua files from my code to the downloaded code I still get the same error(and when I rename them). Thanks!
Last edited by redhood56_ on Thu Jun 20, 2013 1:43 pm, edited 2 times in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
Well, you're probably not packaging his version right.
In any case, the error is because you're using the wrong syntax for require (he is as well, of course). Instead of require("some/file.lua") it should be require("some.file").
In any case, the error is because you're using the wrong syntax for require (he is as well, of course). Instead of require("some/file.lua") it should be require("some.file").
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
oh so you mean like this?bartbes wrote:Well, you're probably not packaging his version right.
In any case, the error is because you're using the wrong syntax for require (he is as well, of course). Instead of require("some/file.lua") it should be require("some.file").
Code: Select all
require("entities.file")
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
In your case I think you need require("entities"), so basically it's the path, without the file extension, and with any slashes replaced with dots.
-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
Ok I did that,which helped, but got me a new error(lol).The error is this download/file.php?mode=view&id=23053. Earlier in the tutorial we created multiple falling boxes on the screen. I think the error has something to do with this line of code
Btw, I would like to say thanks so much for the help, i am just starting in game development!
Code: Select all
register["box"] = love.filesystem.load( ents.objpath .. "box.file" )
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
Upload your .love. Click the link in my signature to find out how if you don't know.
In the meanwhile, does a file called "entitiesbox.file" exist?
In the meanwhile, does a file called "entitiesbox.file" exist?
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
No, don't put '.file' after everything! That was just my example. In any case, what you probably want then, is to load a file at location "entities/box.lua", right?
This means that the require should be require("entities.box").
This means that the require should be require("entities.box").
Re: Trouble running lua files.
edit: gd, ninja'd. 
It would be easier for us to help when you manage to upload a .love file so we could take a look on what you got so far.
To pack a .love you just have to use a tool like 7-zip or winrar ( on windows ) to pack it to an .zip file and then change the file extension to .love.
more about that - here: Link
Your problem could have a lot of reasons, therefor I would need the source code to tell you what happens.
Basically your error obviously says that the file does not exist, so it isn't already created. If you've started the program thhe first time
it wasn't that hard to fix that:
This make it load just if it is in your game save directory ( in appdata ).
To completly fix the code I would need the source
a tip: If you just started programming without any knowledge about lua / löve / programming syntax at all it might be better start small
with more simple stuff !

Your're welcome, of course.redhood56_ wrote: Btw, I would like to say thanks so much for the help, i am just starting in game development!
It would be easier for us to help when you manage to upload a .love file so we could take a look on what you got so far.
To pack a .love you just have to use a tool like 7-zip or winrar ( on windows ) to pack it to an .zip file and then change the file extension to .love.
more about that - here: Link
Your problem could have a lot of reasons, therefor I would need the source code to tell you what happens.
Basically your error obviously says that the file does not exist, so it isn't already created. If you've started the program thhe first time
it wasn't that hard to fix that:
Code: Select all
if love.filesystem.exists( ents.objpath .. "box" ) then
register["box"] = love.filesystem.load( ents.objpath .. "box" )
end
To completly fix the code I would need the source

a tip: If you just started programming without any knowledge about lua / löve / programming syntax at all it might be better start small
with more simple stuff !

-
- Prole
- Posts: 8
- Joined: Mon Jun 17, 2013 3:21 am
Re: Trouble running lua files.
Here is the source code( I hope I did this right)
@MadByte, the tutorial seemed simple, just changing the screen t different colors, and getting images to move across the screen, etc. If there are any other better resources for lua and love2d, could you please point me toward them.
EDIT: It seemed like I forgot to add the zepp texture, I'll update again when I fixed it.
Edit: Download the first one!
@MadByte, the tutorial seemed simple, just changing the screen t different colors, and getting images to move across the screen, etc. If there are any other better resources for lua and love2d, could you please point me toward them.
EDIT: It seemed like I forgot to add the zepp texture, I'll update again when I fixed it.
Edit: Download the first one!
- Attachments
-
example game.love
- (78.59 KiB) Downloaded 348 times
-
example game.love
- (63.18 KiB) Downloaded 141 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Trouble running lua files.
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).
register["box"] = love.filesystem.load( ents.objpath .. "/box.lua" )
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 14 guests