HDictus / breezefield

a physics library wrapper for love2d
MIT License
76 stars 4 forks source link

Consider providing a single "breezefield.lua" for simplifying installation #9

Closed suzumiyasmith closed 2 years ago

suzumiyasmith commented 3 years ago

Currently, it's not quite comfort to install this module on my own love2d project. Simply git clone and copy do not work, which ends in Error: lib/breezefield/init.lua:13: module 'breezefield/collider' not found: I have to import collider and world separately if I locate breezefield in a deeper dir.

Hence, I'd be really appreciated if an all-in-one file could be provided. I

PartyLich commented 2 years ago

Perhaps this is a different request, but an alternative approach to resolving the error presented is to use something like the current_folder pattern. Changes like:

local Collider = require(... .. '/collider')
local World = require(... .. '/world')

in init.lua or

local current_folder = (...):gsub('%.[^%.]+$', '')
local Collider = require(current_folder .. "/breezefield/collider")
local set_funcs, lp, lg, COLLIDER_TYPES = unpack(require(current_folder .. "/breezefield/utils"))

in world.lua allow for proper relative path resolution with the library in a subdirectory, without updating lua path or making other special accommodations for this lib. That said, I'm not experienced enough with lua to know of any downsides to this approach.

HDictus commented 2 years ago

Thanks for bringing this to my attention! I'm sorry I took so long to get to this, I completely lost track of my emails around that time. I like @PartyLich 's solution (which is a neat trick by the way, good find!)

PartyLich commented 2 years ago

It's been long enough that I don't even remember writing it, but I'm glad it helped!