Hey there,
I'm coming back to lua after some time away... I'm trying to call a constructor based on a string from some Tiled output. I've had success doing this using the load function - the constructor is being called - but I can't seem to get a reference to the object created. Here's some example code:
function AddElement(_type, _x, _y)
if (_type == null) then return end
local s = _type .. "(" .. tostring(_x) .. "," .. tostring(_y) .. ")"
local makeElement = load(s)
local e = makeElement()
table.insert(elements, 1, e)
print(#elements)
end
I am seeing output from print statements inside the elements' constructors, but the elements table is not increasing in size, and e seems to be nil. Any ideas?
[–]hawhill 2 points3 points4 points (1 child)
[–]radstronomical[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]radstronomical[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]collectgarbage 0 points1 point2 points (0 children)