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 .
ReFreezed
Party member
Posts: 612 Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:
Post
by ReFreezed » Wed Jul 14, 2021 10:29 pm
(Excuse the double posting.)
I noticed another unrelated problem in the code.
The module name format isn't good. This will try to load 'PathToProject///Classes/Mob.lua', which I guess accidentally works on Windows because Windows seems to accept multiple directory separators in a row. It should be like this:
Code: Select all
Mob = require "Classes.Mob" -- Use dot as the directory separator.
I think the Lua manual isn't good at describing this.
applebappu
Prole
Posts: 37 Joined: Thu Jun 24, 2021 5:49 pm
Post
by applebappu » Wed Jul 14, 2021 11:13 pm
Hm! It works just fine on my Mint system, that's where I'm doing most of my dev work.
ReFreezed
Party member
Posts: 612 Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:
Post
by ReFreezed » Thu Jul 15, 2021 12:43 am
I guess it accidentally works on Mint too. It might work in all places LÖVE supports, but if you put this at the top of the module you should see the weird path that the module was loaded from:
Code: Select all
print(debug.getinfo(1).source) -- Will probably print @//Classes/Mob.lua
(Ignore the @ sign.)
It's more evident if you call require"./././Classes/Mob".
pgimeno
Party member
Posts: 3674 Joined: Sun Oct 18, 2015 2:58 pm
Post
by pgimeno » Thu Jul 15, 2021 11:01 am
Also if you don't use a canonical path, you risk loading the same required file more than once. E.g. if you have this in req.lua:
and you require it differently in more than one place:
you will get "required" printed twice, meaning the file will have been loaded and executed more than once.
The canonical path uses dots for path separators, is relative to the directory where main.lua is, and uses the same letter case as the filenames.
applebappu
Prole
Posts: 37 Joined: Thu Jun 24, 2021 5:49 pm
Post
by applebappu » Thu Jul 15, 2021 5:11 pm
Interesting!
(for the record, I took your advice, thank you)
juankax
Prole
Posts: 3 Joined: Mon Jun 20, 2022 3:53 pm
Post
by juankax » Mon Jun 20, 2022 4:16 pm
Hi applebappu,
I have a doubt, answer me when you can to the PM
Thanks
Users browsing this forum: Ahrefs [Bot] , Bing [Bot] and 3 guests