Fix syntax errors.
This also saves a few tokens and cycles by turning level:tug_crate into a free function. It's not _pretty_ but it's the least bad option.
This commit is contained in:
parent
78f0a96529
commit
cb36faac23
@ -655,14 +655,16 @@ function level:can_move(
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- argument is a rope operation:
|
-- argument is a rope operation:
|
||||||
-- array of [mx0,my0,dmx,dmy]
|
-- array of [mx0,my0,dmx,dmy]
|
||||||
function level:tug_crate(t)
|
-- must be a free function
|
||||||
|
-- to use as a foreach target
|
||||||
|
function level_tug_crate(t)
|
||||||
local mx0,my0,dmx,dmy=unpack(t)
|
local mx0,my0,dmx,dmy=unpack(t)
|
||||||
local mxy0=_mix{mx0,my0}
|
local mxy0=_mix{mx0,my0}
|
||||||
local existing=self._crates[mxy0]
|
local existing=self._crates[mxy0]
|
||||||
if (not existing) return
|
if (not existing) return
|
||||||
|
|
||||||
self._crates[mxy0]=nil
|
level._crates[mxy0]=nil
|
||||||
local mx1,my1=mx0+dmx,my0+dmy
|
local mx1,my1=mx0+dmx,my0+dmy
|
||||||
local px1,py1=mx1*8,my1*8
|
local px1,py1=mx1*8,my1*8
|
||||||
existing.todo={
|
existing.todo={
|
||||||
@ -673,7 +675,7 @@ function level:tug_crate(t)
|
|||||||
{px=px1,py=py1}
|
{px=px1,py=py1}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._crates[_mix{mx1,my1}]=existing
|
level._crates[_mix{mx1,my1}]=existing
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
@ -1557,7 +1559,7 @@ function rope:_tug(hypothetically)
|
|||||||
|
|
||||||
if #ops>0 then
|
if #ops>0 then
|
||||||
if (hypothetically) return ancs,i-1,ops,blocks
|
if (hypothetically) return ancs,i-1,ops,blocks
|
||||||
foreach(ops, level:tug_crate)
|
foreach(ops, level_tug_crate)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1610,7 +1612,7 @@ function rope:_tug(hypothetically)
|
|||||||
if level:can_move(false,mv,1,0) then
|
if level:can_move(false,mv,1,0) then
|
||||||
if (hypothetically) return ancs,0,{mv},blocks
|
if (hypothetically) return ancs,0,{mv},blocks
|
||||||
|
|
||||||
level:tug_crate(mv)
|
level_tug_crate(mv)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
add(blocks, mv)
|
add(blocks, mv)
|
||||||
@ -1691,8 +1693,8 @@ function rope:_calc_push(
|
|||||||
local ops2,blocked={},{}
|
local ops2,blocked={},{}
|
||||||
for o in all(ops) do
|
for o in all(ops) do
|
||||||
local mx,my=unpack(o)
|
local mx,my=unpack(o)
|
||||||
if level:mcoll(mx,my)
|
if level:mcoll(mx,my) then
|
||||||
if not (level:get_crate(mx, my)) break
|
if (not level:get_crate(mx, my)) break
|
||||||
if not level:can_move(false,o,0,0) then
|
if not level:can_move(false,o,0,0) then
|
||||||
add(blocked,o)
|
add(blocked,o)
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user