Jump to content

Events.OnMakeItem Troubles


Kjulo

Recommended Posts

Kmod_Addition_Traits.OnMakeItem = function(result,resultItem,recipe)	if getPlayer():HasTrait("kjulo_armsexpert") then 		if recipe == "Gun_Parts.Disassemble" or  resultItem == "Gun_Parts.GunParts" or result == "Gun_Parts.GunParts" then			getPlayer():getInventory():AddItem("Gun_Parts.GunParts");			getPlayer():getInventory():AddItem("Gun_Parts.GunParts");		end	endendEvents.OnMakeItem.Add(Kmod_Addition_Traits.OnMakeItem);

What i want to do is to give more items (In this case a custom item) when a specific recipe is made. As you can see i've made it check every variable to see if even one is accepted, but nothing happens.

Link to comment
Share on other sites

Ah I think I know what your problem is.

 

OnMakeItem doesn't give you string-parameters but instead the Java Objects:

result        InventoryItemresultItem    InventoryItemrecipe        Recipe

so result:getName() should work.

result and resultItem still diden't work, but recipe did.

if recipe:getName() == "Disassemble" then

This is the final code i used, Thanks for the help.

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...