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 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 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 Share on other sites More sharing options...
Mobbstar Posted February 20, 2015 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. 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. Link to comment 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 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.