Jump to content

Add and Use Tags


jjdamstra

Recommended Posts

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

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

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"))

    end

end

local function PostLog(inst)

    inst.components.fuel.ontaken = GiveCoal

end

AddPrefabPostInit("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

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.

×
  • Create New...