Fix position comparison in Lua