- [NEW] Afegida funció per a que un actor vaja a una posició concreta

This commit is contained in:
2024-02-15 17:51:45 +01:00
parent d3fe7feff4
commit 042e071ef2
2 changed files with 20 additions and 8 deletions

View File

@@ -105,6 +105,19 @@ actors={
end
end,
moveto=function(name,dx,dy)
local actor = actors.search(name)
if actor.x==dx and actor.y==dy then
actor.path=nil
return
end
actor.path={pos=0,route=""}
if (actor.x<dx) then for i=1,dx-actor.x do actor.path.route=actor.path.route.."r" end end
if (actor.x>dx) then for i=1,actor.x-dx do actor.path.route=actor.path.route.."l" end end
if (actor.y<dy) then for i=1,dy-actor.y do actor.path.route=actor.path.route.."d" end end
if (actor.y>dy) then for i=1,actor.y-dy do actor.path.route=actor.path.route.."u" end end
end,
update=function()
if actors.updating then return end
actors.updating=true
@@ -118,7 +131,6 @@ actors={
v.path=nil
game.update()
if in_scene then scene.cont() end
v.keys=nil
if v.name == actors.main.name then
local switch = switches.search(v.x,v.y)
if switch then