Abrir Portas
Abra a porta ao tentar passar por ela ao caminhar no WASD.
Autor:
local wsadWalking = modules.game_walking.wsadWalking
local doorsIds = { 1631, 1629, 1632, 5129 }
function checkForDoors(pos)
local tile = g_map.getTile(pos)
if tile then
local useThing = tile:getTopUseThing()
if useThing and table.find(doorsIds, useThing:getId()) then
g_game.use(useThing)
end
end
end
onKeyPress(function(keys)
local pos = player:getPosition()
if keys == 'Up' or (wsadWalking and keys == 'W') then
pos.y = pos.y - 1
elseif keys == 'Down' or (wsadWalking and keys == 'S') then
pos.y = pos.y + 1
elseif keys == 'Left' or (wsadWalking and keys == 'A') then
pos.x = pos.x - 1
elseif keys == 'Right' or (wsadWalking and keys == 'D') then
pos.x = pos.x + 1
end
checkForDoors(pos)
end)