excon Posted September 3, 2023 Share Posted September 3, 2023 (edited) hi i have a list of items i can use for recipe input but to return the right empty version after use i need to find out what item was used to trigger found this in a post but need some help thanks -- We iterate through the table of clicked items. We have -- to seperate between single items, stacks and expanded -- stacks. for i1 = 1, #itemTable do local item = itemTable[i1]; if instanceof(item, "InventoryItem") and instanceof(item, "InventoryContainer") then Edited September 3, 2023 by excon Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted September 3, 2023 Share Posted September 3, 2023 If you make the ingredients be of type Drainable, you can then use the ReplaceOnDeplete value to set what they become when they have been used. If the items are all to hold a single use, then just set the UseDelta to 1. Link to comment Share on other sites More sharing options...
excon Posted September 7, 2023 Author Share Posted September 7, 2023 (edited) hi - i cannot do that as the items need type food to have the alcohol kicker. something so i can if fork it would be the best if player item used is whiskey add item to inventory whiskey empty i foul=nd this here where we take the right click item function objectRightClicked(player, context, worldObjects, test) print("Objects right clicked"); -- Not sure but it's all around production code so probably -- important if test and ISWorldObjectContextMenu.Test then return true end -- Pick first object in worldObjects as refference one local firstObject; for _,o in ipairs(worldObjects) do if not firstObject then firstObject = o; end end -- the square this object is in is the clicked square local square = firstObject:getSquare() -- and all objects on that square will be affected local worldObjects = square:getObjects(); -- Loop over objects on square for i=0,worldObjects:size()-1 do local object = worldObjects:get(i); print("Clicked object!"); print(" Name:"..(object:getName() or "")); print(" Object:"..(object:getObjectName() or "")); print(" Sprite:"..(object:getSpriteName() or "")); print(" Texture:"..(object:getTextureName() or "")); end end Events.OnFillWorldObjectContextMenu.Add(objectRightClicked); Edited September 7, 2023 by excon 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