Fixed a little typo and systems not behaving correctly when added to a Instance multiple times.

This commit is contained in:
Justin van der Leij 2018-03-24 00:15:42 +01:00
parent acd77fafa5
commit 2b377bea24

View file

@ -77,8 +77,8 @@ end
-- @param enabled If the system is enabled. Defaults to true
-- @return self
function Instance:addSystem(system, eventName, callback, enabled)
if system.__instance then
error("System already in instance '" ..system.__instance.."'")
if system.__instance and system.__instance ~= self then
error("System already in instance '" ..tostring(system.__instance).."'")
end
if not self.systems:has(system) then
@ -133,8 +133,8 @@ function Instance:setSystem(system, eventName, callback, enable)
for i = 1, #listeners do
local listener = listeners[i]
if listerner.callback == callback then
listerner.enabled = enable
if listener.callback == callback then
listener.enabled = enable
break
end
end