quadrinka4 Posted August 28, 2016 Share Posted August 28, 2016 (edited) getPlayer():getInventory():AddItem(InventoryItem(Cooked.Steak) ); isn't this the correct way to do ? or this? what have I done wrong? getPlayer():getInventory():AddItem(InventoryItem(Cooked) Base.Steak ); getPlayer():getInventory():AddItem("Base.Steak.Foods.Burnt"); Thank you for your help Edited September 8, 2016 by quadrinka4 Link to comment Share on other sites More sharing options...
tommysticks Posted September 5, 2016 Share Posted September 5, 2016 (edited) Hey man, so you almost have the right code there, but this would be the correct one: getPlayer():getInventory():AddItem('Base.Steak'); It looks like you probably know how to add steak and were just trying to troubleshoot, but what the code is saying is Add the Item Steak from the Base module. If you look at the scripts there is no actual item for cooked steak. So you'd probably have to look at code from cooking which is going to be a little more complicated than just adding items to your inventory. From what I can tell, there isn't an easy way to add cooked steak directly to the inventory, at least not with AddItem(); EDIT Did a quick search and found this: newItem:setCooked(resultItemCreated:isCooked()); ...which might be a way to set the food to cooked. Just gonna take some fucking around. This snippet came from ISCraftAction.lua and looks like the function used to turn food into cooked food. Edited September 5, 2016 by tommysticks Link to comment Share on other sites More sharing options...
tommysticks Posted September 5, 2016 Share Posted September 5, 2016 Alright, so setCooked should work on steak in the inventory. You'll need to add the steak to the inventory first, then set it to cooked. I don't know exactly how the code would look without fuckin with it but it would look something like this: getPlayer():getInventory():AddItem('Base.Steak'); getPlayer():getInventory():getItem('Steak'):setCooked(true);--getItem is probably incorrect Link to comment Share on other sites More sharing options...
blindcoder Posted September 5, 2016 Share Posted September 5, 2016 :AddItem returns a pointer to the added item, so you can do: local steak = getPlayer():getInventory():AddItem("Base.Steak"); steak:setCooked(true); tommysticks 1 Link to comment Share on other sites More sharing options...
quadrinka4 Posted September 8, 2016 Author Share Posted September 8, 2016 Wow thank you both ^^ those codes sure did work very well Link to comment Share on other sites More sharing options...
Norby007 Posted November 2, 2023 Share Posted November 2, 2023 I noticed that if you have a stack of items that you are cooking one at a time, the stack doesn't update until I click the dropdown on any item in the player inventory. Is there a way to force a refresh to the player's inventory after the food is changed to a cooked state? 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