Jump to content
Sign in to follow this  

Modify existing LUA for Context Menus

Recommended Posts

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
		if not editable then
			context:addOption(getText("ContextMenu_Read_Note") .. canBeWrite:getName(), canBeWrite, ISInventoryPaneContextMenu.onWriteSomething, false, player);
			context:addOption(getText("ContextMenu_Write_Note") .. canBeWrite:getName(), canBeWrite, ISInventoryPaneContextMenu.onWriteSomething, true, player);
    -- use the event (as you would 'OnTick' etc) to add items to context menu without mod conflicts.
    triggerEvent("OnFillInventoryObjectContextMenu", player, context, items);

    return context;


Can anyone show me how to make this actually work in a mod? What am doing wrong? 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...