Page 1 of 1

Why can i only work with the main.lua

Posted: Sun Aug 30, 2015 10:50 am
by Taraji-Productions
No matter I try , it doesn't work .
I create a main.lua file .
and then I create another lua file for example player.lua , and it crashes saying that file i put is not found !!
please help me this issue got over my patient :(
this is main.lua file .

Code: Select all

require "player.lua"

function love.load()

end
function love.update(dt)

end
function love.draw()

end
this is the player.ua file

Code: Select all

player.lua = {}
player.x = 500
player.y = 300

function player.draw()

end
function player.update(dt)

end
Please tell me if it's a bug or it's your fault !

Re: Why can i only work with the main.lua

Posted: Sun Aug 30, 2015 11:49 am
by airstruck
It's my fault. I'm sorry.

Re: Why can i only work with the main.lua

Posted: Sun Aug 30, 2015 11:58 am
by bartbes
The require function does not take file names. It takes module names, which can in turn be translated into filenames by replacing all dots with slashes, and appending ".lua". So in your case, calling require with "player.lua" searches for a file "player/lua.lua", so instead, you want to require "player".

With regards to your player.lua file, you probably want to start it with "player = {}" instead, considering that's what you're using elsewhere, and you can't even assign "player.lua" before "player" exists.

Re: Why can i only work with the main.lua

Posted: Mon Aug 31, 2015 6:03 am
by Taraji-Productions
Thank you very much this !!!
it worked finally !!
it was really easy , and i thought I tried everything :p thank you

Re: Why can i only work with the main.lua

Posted: Mon Aug 31, 2015 7:04 am
by NightKawata
Image

Re: Why can i only work with the main.lua

Posted: Mon Aug 31, 2015 10:04 am
by Taraji-Productions
NightKawata wrote:Image
Hahahahaha lool