CC: Tweaked

CC: Tweaked

57M Downloads

__ipairs metamethod not getting called

Saftur opened this issue ยท 1 comments

commented

Minecraft Version

1.18.x

Version

1.101.0

Details

local mt = {}
local tbl = setmetatable({}, mt)
function mt.__ipairs(tbl)
  return "test"
end
print(ipairs(tbl))

Expected result: prints "test"
Actual result: prints standard result of ipairs(tbl), ignoring __ipairs() metamethod

This is only for ipairs(). If I have the same code, but replace both instances of ipairs with pairs, then it works entirely as expected.

Other CC related mods I have installed (not sure if it matters, but I'm including them just in case):
Advanced Peripherals, CC:C Bridge

logs.zip

commented

This is expected. __ipairs was only added in 5.2 (and then later removed again in Lua 5.3), while CC largely still targets Lua 5.1. See this table on the main documentation