Skip to content

Commit

Permalink
properly hit portal.globals for pairs / ipairs overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
nikki93 committed Nov 24, 2018
1 parent cfb3ed2 commit de0f1e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion state.lua
Expand Up @@ -40,14 +40,15 @@ local Methods = {}
local proxies = setmetatable({}, { __mode = 'k' })


-- `pairs`, `ipairs` wrappers for nodes
-- `pairs`, `ipairs` wrappers for nodes -- also set in `portal.globals` for ghost / castle engine

local oldPairs = pairs
function pairs(t)
local proxy = proxies[t]
if not proxy then return oldPairs(t) end
return oldPairs(proxy.children)
end
if portal then portal.globals.pairs = pairs end
local pairs = oldPairs

local oldIPairs = ipairs
Expand All @@ -56,6 +57,7 @@ function ipairs(t)
if not proxy then return oldIPairs(t) end
return oldIPairs(proxy.children)
end
if portal then portal.globals.ipairs = ipairs end
local ipairs = oldIPairs


Expand Down

0 comments on commit de0f1e0

Please sign in to comment.