I have set up an entities file for all of my projects objects, and have them loaded into the game when needed. Like the tutorial, I made a box object, suitably calling it 'box.lua' and giving it some properties.
part of main.lua
Code: Select all
function love.load()
require ('entities')
love.graphics.setBackgroundColor( 198,241,255 ) -- Red / Green / Blue
imagePlayer = love.graphics.newImage("sprites/mero1.png")
imageTiles = love.graphics.newImage("tiles/testtiles.png")
local boxEnt = ents.Create( "box", 128, 128)
end
part of entities.lua
Code: Select all
ents = {}
ents.objects = {}
ents.objpath = "objects."
local register = {}
local id = 0
function ents.Startup()
register["box"] = love.filesystem.load( "objects.box.lua" )
end
function ents.Derive(name)
return love.filesystem.load( ents.objpath .. name .. ".lua" ) ()
end
I have checked my filenames, directory names and everything and I just can't seem to figure this out.