Search code examples
lualove2d

main:lua attempt to call box2d_init a nil value, why?


EDIT: obviously I didnt install the library correctly? (my version of love is 11.4). perhaps i should rename the question to how do i properly install this library. but maybe there are more truths to be found as to what causes this error(i've been stuck at it for 2 days and i can't figure out why the author would just leave this bug out of the open)

the library in question https://github.com/karai17/Simple-Tiled-Implementation/tree/master/sti

i have it on the same directory as my main.lua with the exact same file structure as in the git

local push = require "push"
local fsm = require 'statemachine'
local sti = require 'sti'
function love.load() 
push:setupScreen(common_res[3][1], common_res[3][2], my_w, my_h, {fullscreen = false})
map = sti("untitled.lua")
local layer = map:addCustomLayer("Sprites", 4);
local player 
for k, object in pairs(map.objects) do      
    if object.name == "player" then         
        player = object
        break
    end 
end
love.physics.setMeter(32);
world = love.physics.newWorld(0,0)
map:box2d_init(world);

Solution

  • map = sti("untitled.lua", {"box2d"})