As a part of a mod I am working on, I would like to modify media\lua\client\ISUI\ISInventoryPaneContextMenu.lua to allow you to write in journals with colored pens and crayons.
I've tried temporarily making the modification (adding extra conditions when defining the local variable "editable") in the actual game file, and that worked.
I've tried creating a lua file in my mod with these contents, but I'm not getting the desired results.
ISInventoryPaneContextMenu.createMenu = function(player, isInPlayerInventory, items, x, y, origin)
if canBeWrite then
local editable = getSpecificPlayer(player):getInventory():contains("Pencil") or getSpecificPlayer(player):getInventory():contains("Pen") or getSpecificPlayer(player):getInventory():contains("RedPen") or getSpecificPlayer(player):getInventory():contains("BluePen") or getSpecificPlayer(player):getInventory():contains("Crayons")
if canBeWrite:getLockedBy() and canBeWrite:getLockedBy() ~= getSpecificPlayer(player):getUsername() then
editable = false
end
if not editable then
context:addOption(getText("ContextMenu_Read_Note") .. canBeWrite:getName(), canBeWrite, ISInventoryPaneContextMenu.onWriteSomething, false, player);
else
context:addOption(getText("ContextMenu_Write_Note") .. canBeWrite:getName(), canBeWrite, ISInventoryPaneContextMenu.onWriteSomething, true, player);
end
end
-- use the event (as you would 'OnTick' etc) to add items to context menu without mod conflicts.
triggerEvent("OnFillInventoryObjectContextMenu", player, context, items);
return context;
end
Can anyone show me how to make this actually work in a mod? What am doing wrong?