Modify existing LUA for Context Menus
0

1 post in this topic

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
		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? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
0