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 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 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 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 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 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 Share on other sites More sharing options...
Blueberrys Posted April 28, 2015 Share Posted April 28, 2015 @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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.