canary/data/scripts/actions/objects/windows.lua

56 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2021-04-26 21:04:01 -03:00
local windowId = {}
for index, value in ipairs(windowTable) do
if not table.contains(windowId, value.openWindow) then
table.insert(windowId, value.openWindow)
end
if not table.contains(windowId, value.closedWindow) then
table.insert(windowId, value.closedWindow)
end
2021-04-26 21:04:01 -03:00
end
local windows = Action()
function windows.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(fromPosition)
2021-04-26 21:04:01 -03:00
local house = tile and tile:getHouse()
if not house then
fromPosition.y = fromPosition.y - 1
tile = Tile(fromPosition)
2021-04-26 21:04:01 -03:00
house = tile and tile:getHouse()
if not house then
fromPosition.y = fromPosition.y + 1
fromPosition.x = fromPosition.x - 1
tile = Tile(fromPosition)
2021-04-26 21:04:01 -03:00
house = tile and tile:getHouse()
end
end
2021-04-26 21:04:01 -03:00
if house then
if Tile(fromPosition):getHouse() ~= house and player:getAccountType() < ACCOUNT_TYPE_GAMEMASTER then
2021-04-26 21:04:01 -03:00
return false
end
end
for index, value in ipairs(windowTable) do
if value.closedWindow == item.itemid then
item:transform(value.openWindow)
return true
end
end
for index, value in ipairs(windowTable) do
2021-04-26 21:04:01 -03:00
if value.openWindow == item.itemid then
item:transform(value.closedWindow)
end
end
return true
end
for index, value in ipairs(windowId) do
windows:id(value)
2021-04-26 21:04:01 -03:00
end
windows:register()