Why can i only work with the main.lua

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
Taraji-Productions
Prole
Posts: 5
Joined: Sat Aug 29, 2015 11:10 pm

Why can i only work with the main.lua

Post 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 !
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

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

Post by airstruck »

It's my fault. I'm sorry.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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.
Taraji-Productions
Prole
Posts: 5
Joined: Sat Aug 29, 2015 11:10 pm

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

Post by Taraji-Productions »

Thank you very much this !!!
it worked finally !!
it was really easy , and i thought I tried everything :p thank you
User avatar
NightKawata
Party member
Posts: 294
Joined: Tue Jan 01, 2013 9:18 pm
Location: Cyberspace, Room 6502
Contact:

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

Post by NightKawata »

Image
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Taraji-Productions
Prole
Posts: 5
Joined: Sat Aug 29, 2015 11:10 pm

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

Post by Taraji-Productions »

NightKawata wrote:Image
Hahahahaha lool
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 8 guests