gladys45 Posted February 12, 2015 Share Posted February 12, 2015 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 More sharing options...
EasyPickins Posted February 13, 2015 Share Posted February 13, 2015 You're calling the test function in this line:_context:addOption("My Menu", _worldObjects, testfunc(player,"woop woop"), testVar, _player);Something like this instead:_context:addOption("My Menu", _worldObjects, testfunc, _player, "woop woop"); gladys45 1 Link to comment Share on other sites More sharing options...
gladys45 Posted February 18, 2015 Author Share Posted February 18, 2015 thankyou sweet prince! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now