jjdamstra Posted February 20, 2015 Share Posted February 20, 2015 I would like to add a tag to the log prefab and then when i go to use it at a firepit, before it burns it, it will check to see if it has that tag and if so then do something Link to comment https://forums.kleientertainment.com/forums/topic/51203-add-and-use-tags/ Share on other sites More sharing options...
Sketchiverse Posted February 20, 2015 Share Posted February 20, 2015 Here's what I have in mind :In you modmain.lua, add a post init to the log prefab and put everything you need in it, like this :local function Log_DoSomething() -- does something...endAddPrefabPostInit("log", function(inst) inst:AddTag("newtag") inst:ListenForEvent("burning", Log_DoSomething())end)I don't know about the "burning" part though, but at least your code could look like that...I'm not sure the listen for event thing would work just as you want though.Also the "Log_" in your function's name doesn't have to be there, it's just in case you have a lot of functions. I'm giving very little help, sorry if you were looking for more. Link to comment https://forums.kleientertainment.com/forums/topic/51203-add-and-use-tags/#findComment-614865 Share on other sites More sharing options...
jjdamstra Posted February 20, 2015 Author Share Posted February 20, 2015 I don't think that will help for what i want. What I'm looking for is: I have a firepit and i want it to make charcoal if logs are used as the fuel. I know there are charcoal mods out there but they make the charcoal with anything that burns. Link to comment https://forums.kleientertainment.com/forums/topic/51203-add-and-use-tags/#findComment-614884 Share on other sites More sharing options...
Mobbstar Posted February 20, 2015 Share Posted February 20, 2015 (edited) I don't think that will help for what i want. What I'm looking for is: I have a firepit and i want it to make charcoal if logs are used as the fuel. I know there are charcoal mods out there but they make the charcoal with anything that burns. This is probably what you mean: inst.components.fuel.ontaken = GiveCharcoal() Define a function to give charcoal to the owner of the log and set it using the line above. I recommend to try using the items owner like this: inst.components.inventoryitem.owner I have put together a sketch of how that'd probably look like. No warrant.local function GiveCoal(inst,taker) local guy = inst.components.inventoryitem.owner if guy and guy.components.inventory then --here you could add further conditions guy.components.inventory:GiveItem(SpawnPrefab("charcoal")) endendlocal function PostLog(inst) inst.components.fuel.ontaken = GiveCoalendAddPrefabPostInit("log",PostLog)EDIT: Oh, and before I forget, my mod Industrial Resolution has a complicated way to make charcoal from logs and boards only. Thought I'd mention it. Edited February 20, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/51203-add-and-use-tags/#findComment-614890 Share on other sites More sharing options...
jjdamstra Posted February 21, 2015 Author Share Posted February 21, 2015 Thanks I'll look at that mod Link to comment https://forums.kleientertainment.com/forums/topic/51203-add-and-use-tags/#findComment-615018 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