Search the Community
Showing results for tags 'right click menu'.
-
Hi everyone. Please, can you help me with the context menu for my custom pills? I cant understad how work a "Take Pill" action for vanilla Painkillers... This is code of my item item AspirinBottle { Weight = 0.1, Type = Drainable, UseDelta = 0.02, DisplayName = Bottle of aspirin pills, Icon = OZMoreMeds_Aspirin500mg, Tooltip = Tooltip_Painkillers, UseWhileEquipped = FALSE, } I tried to make a custom context menu but my lua script still not working...
- 6 replies
-
- context menu
- right click menu
-
(and 2 more)
Tagged with:
-
So, here is the next code sniplet! We all know the menu that pops up when you right click an item. This is how you add options to it, for specific items! yourContextMenuObjectName = {}; -- Change "yourContextMenuObjectName" to the name you want, it needs to be different in every file.yourContextMenuObjectName.doMenu = function(player, context, items) for i,v in ipairs(items) do local item = v; if not instanceof(v, "InventoryItem") then item = v.items[1]; end if item:getType() then -- this is where you put your code! if item:getType() == "MyItemID" then -- Change MyItemsID to the ID you used in your items.txt file. (so for base.Axe this would be Axe) context:addOption("Do the thing with the thing", item, yourContextMenuObjectName.onTheThingWithTheThing, player); end -- this is where you put your code! end endendyourContextMenuObjectName.onTheThingWithTheThing = function(item, player) -- This is where the code goes for when someone clicks the option in the menu local playerObj = getSpecificPlayer(player); playerObj:Say("Doing the thing with " .. item:getName()); -- This is where the code goes for when someone clicks the option in the menuend-- The link to the right click menu evenEvents.OnFillInventoryObjectContextMenu.Add(yourContextMenuObjectName.doMenu);This lua file goes into the media/lua/client/ folder of your mod. If you have any questions, just ask! Hope it helps! <3