Switches funcionant

This commit is contained in:
2026-03-22 20:10:18 +01:00
parent 5314f13d81
commit cb03264568
5 changed files with 62 additions and 3 deletions

47
data/switches.lua Normal file
View File

@@ -0,0 +1,47 @@
switches={
cooldown=0,
wait=0,
current_list=nil,
current_index=-1,
[1]={[0]={20, 53,41}},
[11]={[21]={11, 57,45}},
[35]={[14]={32, 50,38,26,53,41,29}},
[53]={[14]={72, 42,30}},
[61]={[14]={54, 54,42}},
[76]={[19]={77, 50,38,26},
[22]={57, 53,41}},
[80]={[18]={36, 56,44}},
[39]={[27]={39, 62,63}}
}
--switches[11]={[21]={11, 57,45}}
--switches[11][21]={11, 57,45}
function switches.start(x, y)
if switches.cooldown>0 then return end
local hab, hx, hy = arc_mapa_get_map_coords(x, y)
local tile_idx = (hx+hy*mapa_room_cols)+1
print("Switch > "..x..", "..y.." / "..hab..", "..hx..", "..hy.." T="..tile_idx)
mapa_set_tile_by_index(hab,tile_idx,57)
switches.current_list=switches[hab+1][tile_idx]
switches.current_index=2
switches.wait=0
switches.cooldown=60
sound.play(audio_switch)
end
function switches.update()
if switches.cooldown>0 then switches.cooldown=switches.cooldown-1 end
if switches.current_list==nil then return end
--cls(4)
switches.wait=switches.wait+1
if switches.wait>=6 then
switches.wait=0
mapa_set_tile_by_index(switches.current_list[1]-1,switches.current_list[switches.current_index]+1,256)
switches.current_index=switches.current_index+1
if switches.current_index>#switches.current_list then
switches.current_list=nil
end
end
end