Nebula Posted December 21, 2019 Share Posted December 21, 2019 (edited) I need to get the item name display. How to do it right? It gives me an error: Callframe at: PerformMakeItem Object tried to call nil in recipe_ recipe name I have this code: item WorkItem1 { Type = Normal, DisplayName = WorkItem1, Icon = WorkItem1, Weight = 0.1, } recipe WorkItemExample { WоrkItem1,WorkItem2,WorkItem3,WorkItem4,WorkItem5 destroy WorkItemqqq, Result:WorkItemResult, Time:30.0, NeedToBeLearn:false, OnCreate:recipe_WorkExampleCreat, } --------------------------------------------------------- function recipe_WorkExampleCreat(items, result, player) WorkItemName = getPlayer():getInventory():getModData():getDisplayName(getText("IGUI_WorkItem1")); end IGUI_WorkItem is recorded in the IGUI_EN table You need to iterate over the names from the first list in the recipe. And save in the variable WorkItemName the name of the IGUI of the object that was used when crafting ... You need to get the name that I indicated in IGUI_EN Edited December 21, 2019 by Nebula ATPHHe 1 Link to comment Share on other sites More sharing options...
ATPHHe Posted March 18, 2020 Share Posted March 18, 2020 (edited) You must iterate through the list of items that are participating in the craft from the "items" ArrayList<InventoryItem>. This for loop will iterate through each single item that is participating in the craft. The if statements will make sure to only give the correct DisplayName that you need for the "WorkItemName" varaible. I do not know which name you need so you'll have to play with this until you get a desired outcome. function recipe_WorkExampleCreat(items, result, player) for i=0, items:size()-1 do local item = items:get(i) local itemDisplayName = item:getDisplayName() local itemName = item:getName() -- Is "IGUI_WorkItem1" the "itemDisplayName" for the "item" at items:get(i)? if itemDisplayName == getText("IGUI_WorkItem1") then WorkItemName = itemDisplayName -- Store item display name into WorkItemName end -- Is "IGUI_WorkItem1" the "itemName" for the "item" at items:get(i)? if itemName == getText("IGUI_WorkItem1") then WorkItemName = itemName -- Store item name into WorkItemName end end end If you need the result item's displayname, then you must use "result:getDisplayName()" function recipe_WorkExampleCreat(items, result, player) WorkItemName = result:getDisplayName() end This is the InventoryItem class with all the methods I used: https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html#getDisplayName-- https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html#getName-- Edited March 18, 2020 by ATPHHe Nebula 1 Link to comment Share on other sites More sharing options...
Nebula Posted March 18, 2020 Author Share Posted March 18, 2020 For a long time irrelevant, I figured out ... but thanks anyway. ATPHHe 1 Link to comment Share on other sites More sharing options...
ATPHHe Posted March 18, 2020 Share Posted March 18, 2020 Yup, no problems. ^^ 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