Posted 15 September 2014 - 11:59 AM
I am working on a very basic "physics engine" and it will work by the user creating objects and giving objects attributes. However in my 'run' function I am having trouble detecting if an object has a attribute. At the moment it says there are no attributes when there are attributes.
-- Physics Engine
local table = { }
new = function(object)
table[object] = { }
end
attribute = function(object, type, value)
if table[object] then
table[object][type] = value
else
error("That Object doesn't Exist.")
end
end
run = function(object)
if table[object] then
if table[object][1] then
else
error("That Object has no Attributes.")
end
else
error("That Object doesn't Exist.")
end
end
new("obj")
attribute("obj", "velocity", 1)
print(textutils.serialize(table))
run("obj")