Jump to content

context menu option always executes


gladys45

Recommended Posts

hi everyone,

 

i have recently been trying to get to grips with the world context menu.

i can add an option if conditions are met, player clicks on ground outside and is grass/soil.

the menu option displays, however the function i have linked to the menu option (a timed action) is always executed.

i'm probably missing something very very simple however i keep looking at my code and it looks fine (well it looks terrible... but...)

 

TL:DR context menu shows my option but always calls the function i have linked to it.

function contextMenu(_player, _context, _worldObjects)	if test then return ISWorldObjectContextMenu.setTest() end		testVar = false;		local player = getSpecificPlayer(_player);	local square = nil;    for i,v in ipairs(_worldObjects) do			square = v:getSquare();		        for t = 0, square:getObjects():size() - 1 do					local item = square:getObjects():get(t);					if item:getTextureName() and (luautils.stringStarts(item:getTextureName(), "floors_exterior_natural") or luautils.stringStarts(item:getTextureName(), "blends_natural")) then								testVar = true;											end		end    end	if testVar then		if test then return ISWorldObjectContextMenu.setTest() end		_context:addOption("My Menu", _worldObjects, testfunc(player,"woop woop"), testVar, _player);	end	endfunction testfunc(player, msg)	print(msg);	ISTimedActionQueue.add(ISslowPoke:new(player, msg, 50));endEvents.OnFillWorldObjectContextMenu.Add(contextMenu)
Link to comment
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
×
×
  • Create New...