[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

[SOLVED]Trouble running lua files.

Post by redhood56_ »

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!
Attachments
6Dluhe1.png
6Dluhe1.png (80.09 KiB) Viewed 522 times
utCQO9O.png
utCQO9O.png (47.95 KiB) Viewed 522 times
Last edited by redhood56_ on Thu Jun 20, 2013 1:43 pm, edited 2 times in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post by bartbes »

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").
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post by redhood56_ »

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").
oh so you mean like this?

Code: Select all

require("entities.file")
When I do that I still get the error. I also changed all the lines with a ".lua" and the one line with "entities/" too, and it didn't change anything.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post by bartbes »

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.
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post by redhood56_ »

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

Code: Select all

	register["box"] = love.filesystem.load( ents.objpath .. "box.file" )
Btw, I would like to say thanks so much for the help, i am just starting in game development!
Attachments
xpSxkM1.png
xpSxkM1.png (82.64 KiB) Viewed 523 times
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 »

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?
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Trouble running lua files.

Post by bartbes »

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").
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Trouble running lua files.

Post by MadByte »

edit: gd, ninja'd. :D
redhood56_ wrote: Btw, I would like to say thanks so much for the help, i am just starting in game development!
Your're welcome, of course.

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
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 ! ;)
redhood56_
Prole
Posts: 8
Joined: Mon Jun 17, 2013 3:21 am

Re: Trouble running lua files.

Post by redhood56_ »

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!
Attachments
example game.love
(78.59 KiB) Downloaded 125 times
example game.love
(63.18 KiB) Downloaded 133 times
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 »

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" )
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 5 guests