Index systems from the end like string.sub.

This commit is contained in:
bakpakin
2015-08-22 22:45:07 -04:00
parent f0e6ce7880
commit a5af4b6ecd
+7 -1
View File
@@ -696,11 +696,17 @@ end
--- Sets the index of a System in the World, and returns the old index. Changes
-- the order in which they Systems processed, because lower indexed Systems are
-- processed first. Returns the old system.index.
-- processed first. If 'index' < 0, then sets 'index' relative to the last index
-- in the World; -1 is the index of the last System, -2 is the second to last,
-- and so on. Returns the old system.index.
function tiny.setSystemIndex(world, system, index)
local oldIndex = system.index
local systems = world.systems
if index < 0 then
index = tiny.getSystemCount(world) + 1 + index
end
tremove(systems, oldIndex)
tinsert(systems, index, system)