function love.load()
require("collisions")
require("moveplayer")
player = {}
player.x = 0
player.y = 0
player.xSize = 32
player.ySize = 32
end
function love.update(dt)
if dt < 1/60 then
love.timer.sleep(1/60 - dt)
end
end
function love.draw()
love.graphics.rectangle("line", player.x, player.y, player.xSize, player.ySize)
end
Inside the moveplayer.lua I have it set up to use the WASD keys and the players move. In the collisions, I just only print the player's position for now.
BUT, it only uses the first require function and skips over the one that comes second, and I cannot get it to work at all. If I put the moveplayer first, I am able to move the player, but I will not get the player's position printed. If I put collisions first, I will not be able to move the player, but the player's position would print. Can somebody help me?
Multiple Require Functions Not Working
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Multiple Require Functions Not Working
From your description, it sounds like the problem is in the files themselves. Could you perhaps attach a minimal .love file that can be checked by others and exhibits the problem?
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Multiple Require Functions Not Working
Hi and welcome to the forums!
As pgimeno said, the problem might be you defining global variables with the same name in both files, as one will overwrite the other.
Or it might not be, hence why an example should be provided.
As pgimeno said, the problem might be you defining global variables with the same name in both files, as one will overwrite the other.
Or it might not be, hence why an example should be provided.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: No registered users and 4 guests