Multiple Require Functions Not Working

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.
Post Reply
Kaister93
Prole
Posts: 6
Joined: Wed Jan 31, 2018 11:34 am

Multiple Require Functions Not Working

Post by Kaister93 »

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?
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Multiple Require Functions Not Working

Post by pgimeno »

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?
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Multiple Require Functions Not Working

Post by zorg »

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. :3
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests