Files
cacaus-arcade/data/switches.lua
2026-03-28 21:08:45 +01:00

58 lines
1.8 KiB
Lua

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 = coords.world_to_tile(x, y)
local tile_idx = (hx+hy*mapa_room_cols)+1
-- mapa_set_tile_by_index(hab,tile_idx,57)
arc_set_tile(x, y, editor_to_map_tile(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
local hab= switches.current_list[1]-1
local tile_idx= switches.current_list[switches.current_index]+1
-- print(hab.." ("..tile_x..", "..tile_y..")")
-- local tile_x, tile_y = coords.room_index_to_xy ( hab, tile_idx )
-- local world_x, world_y = coords.room_to_world(hab, tile_x, tile_y)
-- arc_set_tile(world_x, world_y, 256)
arc_set_tile_by_index(hab,tile_idx,mapa_empty_tile)
-- 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