As it happens, Lark didn't read this page, and posted multiple broken scripts to this forum. In the case of this script, all of the variables are "global" to the script entity so as soon as they are assigned they become permanent fields. Which, of course, will break saving since it includes an unserializable variable: a GameObject reference.
Here is a fixed version.
Code: Select all
do
local num = 0
local bad = 2
while bad > 0 do
num = num + 1
local obj = findEntity("dungeon_wall_lantern_" .. num)
if obj ~= nil then
local val = obj:getWorldPosition()
val[2] = val[2] + .7
local ix = (3 - (obj.facing % 2) * 2)
local dx, dy = getForward(obj.facing)
val[ix] = val[ix] + .21 * (dx - dy)
obj:setWorldPosition(val)
else
bad = bad - 1
end
end
end