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
|
2012-01-09 01:43:36 +01:00
|
|
|
-- check for open in new window
|
2012-01-03 23:27:31 +01:00
|
|
|
menu:addOption('Open', function() print('open') end)
|
|
|
|
else
|
2012-01-04 14:02:35 +01:00
|
|
|
if useThing:isMultiUse() then
|
2012-01-03 23:27:31 +01:00
|
|
|
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)
|
2012-01-03 23:27:31 +01:00
|
|
|
end
|
|
|
|
end
|
2012-01-04 14:02:35 +01:00
|
|
|
|
|
|
|
if useThing:isRotateable() then
|
|
|
|
menu:addOption('Rotate', function() Game.rotate(useThing) end)
|
2012-01-03 23:27:31 +01:00
|
|
|
end
|
2012-01-09 01:43:36 +01:00
|
|
|
|
|
|
|
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
|
2012-01-09 01:43:36 +01:00
|
|
|
|
|
|
|
-- check for move up
|
2012-01-03 23:27:31 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if creatureThing then
|
2012-01-03 23:27:31 +01:00
|
|
|
menu:addSeparator()
|
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if creatureThing:asLocalPlayer() then
|
2012-01-03 23:27:31 +01:00
|
|
|
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
|
2012-01-03 23:27:31 +01:00
|
|
|
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)
|
2012-01-03 23:27:31 +01:00
|
|
|
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 23:27:31 +01:00
|
|
|
|
2012-01-03 21:41:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
menu:display(menuPosition)
|
|
|
|
end
|