delete post
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 16
- Joined: Wed Feb 20, 2013 7:16 pm
delete post
delete post
Last edited by jajasuperman on Mon Feb 05, 2018 12:53 pm, edited 3 times in total.
Re: [Problem] How I use dofile?
You should use require (don't write .lua, "require('level1')) or love.filesystem.load (you'll have to call what it returns: level1 = lf.load('level1.lua'); level1()) instead
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 16
- Joined: Wed Feb 20, 2013 7:16 pm
delete post
delete post
Last edited by jajasuperman on Mon Feb 05, 2018 12:53 pm, edited 1 time in total.
Re: [Problem] How I use dofile?
The problem is that player is a variable that doesn't exist yet in line 33 of level1.lua, according to the message; if you posted some other code we'd be able to tell you what's the problem exactly
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 16
- Joined: Wed Feb 20, 2013 7:16 pm
delete post
delete post
Last edited by jajasuperman on Mon Feb 05, 2018 12:53 pm, edited 1 time in total.
Re: [Problem] How I use dofile?
You define the callbacks twice, you should never do that; when you load level1.lua the callbacks inside it overwrite the ones defined inside main.lua, and level1.lua's love.load doesn't ever get called
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: [Problem] How I use dofile?
I know that this isn't the point of the post, but I noticed your love.draw function was slightly redundant.
It is currently this:
It can be simplified down to this
Just my two cents though. Have fun löving!
It is currently this:
Code: Select all
function love.draw()
if menu == 1 then
love.graphics.setColor(255, 0, 0)
love.graphics.print("Jugar", 100, 100, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
love.graphics.print("Opciones", 100, 200, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
love.graphics.print("Salir", 100, 300, 0, 2, 2)
end
if menu == 2 then
love.graphics.setColor(0, 0, 255)
love.graphics.print("Jugar", 100, 100, 0, 2, 2)
love.graphics.setColor(255, 0, 0)
love.graphics.print("Opciones", 100, 200, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
love.graphics.print("Salir", 100, 300, 0, 2, 2)
end
if menu == 3 then
love.graphics.setColor(0, 0, 255)
love.graphics.print("Jugar", 100, 100, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
love.graphics.print("Opciones", 100, 200, 0, 2, 2)
love.graphics.setColor(255, 0, 0)
love.graphics.print("Salir", 100, 300, 0, 2, 2)
end
end
Code: Select all
function love.draw()
love.graphics.setColor(0, 0, 255)
if menu == 1 then
love.graphics.setColor(255, 0, 0)
end
love.graphics.print("Jugar", 100, 100, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
if menu == 2 then
love.graphics.setColor(255, 0, 0)
end
love.graphics.print("Opciones", 100, 200, 0, 2, 2)
love.graphics.setColor(0, 0, 255)
if menu == 3 then
love.graphics.setColor(255, 0, 0)
end
love.graphics.print("Salir", 100, 300, 0, 2, 2)
end
end
Re: [Problem] How I use dofile?
I was struggling with that too, finally require("filename") works for me, but without the lua extension, e.g.: require("level1").
experimental art since 13.75 gigayears
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
Who is online
Users browsing this forum: No registered users and 10 guests