Jump to content

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.

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. 

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.

Edited by Mobbstar

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...