Fireandthethud Posted April 27, 2015 Share Posted April 27, 2015 something along the lines of the following? inst:ListenForEvent("OnCraftItem", myfunction)The help would be much appreciated! Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/ Share on other sites More sharing options...
Fireandthethud Posted April 27, 2015 Author Share Posted April 27, 2015 Oh, and a way to find the item being crafted Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632668 Share on other sites More sharing options...
Corrosive Posted April 27, 2015 Share Posted April 27, 2015 Do you want this to work for things that go in your inventory or buildable things as well (such as the alchemy engine or a pig house)? Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632677 Share on other sites More sharing options...
Fireandthethud Posted April 27, 2015 Author Share Posted April 27, 2015 Buildable as well, if possible. I found this:local function onequip_green(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "greenamulet") owner.components.builder.ingredientmod = TUNING.GREENAMULET_INGREDIENTMOD inst.onitembuild = function() inst.components.finiteuses:Use(1) end inst:ListenForEvent("consumeingredients", inst.onitembuild, owner)endand the "consumeingredients" seems to be close to what I need, but it's not quite because my mod would need to reference the prefab being built. Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632682 Share on other sites More sharing options...
Corrosive Posted April 28, 2015 Share Posted April 28, 2015 @Fireandthethud, You can listen for both the "builditem" and "buildstructure" events. Both of them push the table {item = product, recipe = recipe} as an argument. Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632689 Share on other sites More sharing options...
Fireandthethud Posted April 28, 2015 Author Share Posted April 28, 2015 Oh super!So it'd be something like:local function myfunc(item,recipe)if item:HasTag("mytag") then--do Xendendlistenforevent("builditem",myfunc)listenforevent("buildstructure",myfunc) Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632700 Share on other sites More sharing options...
Blueberrys Posted April 28, 2015 Share Posted April 28, 2015 (edited) @Fireandthethud I think it's like this, need to confirm though.local function myfunc(inst, data) item = data.item recipe = data.recipeendalso the ListenForEvent function is a child of an entity, not a global function. Edited April 28, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/53276-is-there-a-way-to-run-a-function-on-crafting-of-an-item/#findComment-632713 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