tibia-client/modules/game/thing.lua

74 lines
2.4 KiB
Lua
Raw Normal View History

2012-01-03 21:41:00 +01:00
-- public functions
2012-01-04 14:02:35 +01:00
function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
2012-01-03 21:41:00 +01:00
local menu = createWidget('PopupMenu')
2012-01-04 14:02:35 +01:00
if lookThing then
menu:addOption('Look', function() Game.look(lookThing) end)
end
2012-01-03 21:41:00 +01:00
-- Open or Use, depending if thing is a container
2012-01-04 14:02:35 +01:00
if useThing then
if useThing:isContainer() then
-- check for open in new window
menu:addOption('Open', function() print('open') end)
else
2012-01-04 14:02:35 +01:00
if useThing:isMultiUse() then
menu:addOption('Use with ...', function() print('use with...') end)
else
2012-01-04 14:02:35 +01:00
menu:addOption('Use', function() Game.use(useThing) end)
end
end
2012-01-04 14:02:35 +01:00
if useThing:isRotateable() then
menu:addOption('Rotate', function() Game.rotate(useThing) end)
end
end
if lookThing and not lookThing:asCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
menu:addSeparator()
menu:addOption('Trade with ...', function() print('trade with') end)
2012-01-04 14:02:35 +01:00
end
-- check for move up
2012-01-04 14:02:35 +01:00
if creatureThing then
menu:addSeparator()
2012-01-04 14:02:35 +01:00
if creatureThing:asLocalPlayer() then
menu:addOption('Set Outfit', function() Game.openOutfitWindow() end)
else
2012-01-07 23:24:29 +01:00
local localPlayer = Game.getLocalPlayer()
if localPlayer then
if localPlayer:getAttackingCreature() ~= creatureThing then
menu:addOption('Attack', function() Game.attack(creatureThing) end)
else
menu:addOption('Stop Attack', function() Game.cancelAttack() end)
end
if localPlayer:getFollowingCreature() ~= creatureThing then
menu:addOption('Follow', function() Game.follow(creatureThing) end)
else
menu:addOption('Stop Follow', function() Game.cancelFollow() end)
end
2012-01-05 15:24:38 +01:00
end
2012-01-04 14:02:35 +01:00
if creatureThing:asPlayer() then
menu:addSeparator()
2012-01-04 14:02:35 +01:00
menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
2012-01-04 15:30:28 +01:00
menu:addOption('Add to VIP list', function() Game.addVip(creatureThing:getName()) end)
2012-01-04 14:02:35 +01:00
menu:addOption('Ignore ' .. creatureThing:getName(), function() print('ignore') end)
2012-01-05 13:48:10 +01:00
menu:addOption('Invite to Party', function() Game.inviteToParty(creatureThing:getId()) end)
end
end
menu:addSeparator()
2012-01-05 13:48:10 +01:00
menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end)
2012-01-03 21:41:00 +01:00
end
menu:display(menuPosition)
end