Jump to content

Recommended Posts

I had an idea to make a mod to buff Willow's lighter only when it's being held by her. I want it to be brighter and use no fuel but only when being held by her.

I found a few mods that do similar things to what I want but I haven't been able to figure out how to put all the pieces together properly. This mod(Infinite Lighter) makes the lighter infinite, and has an option to allow other characters to cook on the lighter, which would be nice to be able to preserve as an option. This mod (Twigs and Matches) makes the lighter not use fuel while being held by Willow, but I don't think it plays nice with the Willow rework. And this mod for Don't Starve classic makes the lighter much brighter.

If someone could help me put this together, or at least help get me started that would be much appreciated.

Edited by Mayli-Song

Simple. Open lighter file search for OnEquip and OnUnEquip functions. Those are used to add light and start fuel consuming. 

Search for lines inst.components.fueled:StartConsuming() and StopConsuming(). 

Currently lighter consmes fuel for all characters. We can change that by adding condition into OnEquip function. Also put changes to lighter for different chars into it. 

---owner is a character who equips item

----owner.prefab is a name of owner

If owner and owner.prefab ~= "willow" then 

---this part will proc for non-willow chars

inst.components.fueled:StartConsuming() 

--- place code that changes 

---light here like in main fn

-- of lighter like inst.Light:SetRadius() 

elseif owner and owner.prefab =="willow" then

--place code that

--will make lighter bright here

end

 

 

Edited by Desblat

 

On 1/25/2020 at 6:08 AM, Desblat said:

Simple. Open lighter file search for OnEquip and OnUnEquip functions. Those are used to add light and start fuel consuming. 

Search for lines inst.components.fueled:StartConsuming() and StopConsuming(). 

Currently lighter consmes fuel for all characters. We can change that by adding condition into OnEquip function. Also put changes to lighter for different chars into it. 

---owner is a character who equips item

----owner.prefab is a name of owner

If owner and owner.prefab ~= "willow" then 

---this part will proc for non-willow chars

inst.components.fueled:StartConsuming() 

--- place code that changes 

---light here like in main fn

-- of lighter like inst.Light:SetRadius() 

elseif owner and owner.prefab =="willow" then

--place code that

--will make lighter bright here

end

 

 

So, I was going to go and put all that in and test it, since it seemed fairly straightforward, but one slight problem. inst.components.fueled:StartConsuming() and StopConsuming() don't seem to exist. In fact, my ctrl+f isn't even finding anything for "consuming." I'm looking in the lighter.lua prefab, I was assuming that was what you meant?

Edited by Mayli-Song
11 hours ago, Mayli-Song said:

 

So, I was going to go and put all that in and test it, since it seemed fairly straightforward, but one slight problem. inst.components.fueled:StartConsuming() and StopConsuming() don't seem to exist. In fact, my ctrl+f isn't even finding anything for "consuming." I'm looking in the lighter.lua prefab, I was assuming that was what you meant?

It's called burnable:Ignite() because lighter uses burnable instead. 

The pattern is the same. 

10 hours ago, Desblat said:

It's called burnable:Ignite() because lighter uses burnable instead. 

The pattern is the same. 

So this still isn't solved and I'm sorry in advance if it's something obvious I'm missing, I'm pretty new at this.
Since you said it uses burnable:Ignite() instead of StartConsuming(), I assumed the pattern would change to 

if owner and owner.prefab ~= "willow" then 
        inst.components.burnable:Ignite()
    elseif owner and owner.prefab =="willow" then
        return
    end

but that makes the lighter not actually equip. The motion is done and it's in the hand slot but she won't hold it and it doesn't show or glow.

So I attempted having burnable:Ignite on both branches and adding inst.components.burnable.ignore fuel = false   and true, but that didn't do anything regarding fuel.

 

With brightness, I tried a few things. I noticed the actual light seems to come from the lighterfire_common prefab, so I tried adding the branch that would check if the owner was Willow to that prefab but it crashed with an error saying the owner variable was undefined. I thought maybe I could make it easier, so I tried just putting the light into the branch on the lighter prefab

       inst.Light:SetIntensity(.85)
       inst.Light:SetColour(200 / 255, 150 / 255, 50 / 255)
       inst.Light:SetFalloff(.5)
       inst.Light:SetRadius(3)

But this also gave me a crash, with an error stating "attempt to index field 'Light' (a nil value)"

6 hours ago, Mayli-Song said:

So this still isn't solved and I'm sorry in advance if it's something obvious I'm missing, I'm pretty new at this.
Since you said it uses burnable:Ignite() instead of StartConsuming(), I assumed the pattern would change to 


if owner and owner.prefab ~= "willow" then 
        inst.components.burnable:Ignite()
    elseif owner and owner.prefab =="willow" then
        return
    end

but that makes the lighter not actually equip. The motion is done and it's in the hand slot but she won't hold it and it doesn't show or glow.

 

OnEquip function is used to create Light object, it's actually fire that follows lighter that shines, not the lighter itself. And to show lighter in hands visually:

OverrideSymbol - place lighter into hand instead of invisible placeholder

ShowSymbol - shows hand with lighter

HideSymbol - hides hand 

You should keep all the code that was in OnEquip originally, and only add your If-the-else instead of line with Ignite(). 

 

6 hours ago, Mayli-Song said:

So brightness, I tried a few things. I noticed the actual light seems to come from the lighterfire_common prefab, so I tried adding the branch that would check if the owner was Willow to that prefab but it crashed with an error saying the owner variable was undefined. I thought maybe I could make it easier, so I tried just putting the light into the branch on the lighter prefab


       inst.Light:SetIntensity(.85)
       inst.Light:SetColour(200 / 255, 150 / 255, 50 / 255)
       inst.Light:SetFalloff(.5)
       inst.Light:SetRadius(3)

But this also gave me a crash, with an error stating "attempt to index field 'Light' (a nil value)"

Your approach is wrong. You can edit Light properties from OnEquip function. You need to change flame Light, not lighter light, because lighter doesn't have Light component.

Study OnEquip component, there is some thing like inst.fire=SpawnPrefab("fire") 

inst.fire is a link to fire that we need. Now after spawning fire you can add this :

If owner.prefab=="" then

inst.fire.Light:SetIntensity(.85)

end

Note that you can not use link to fire before fire was created or you will crash. 

11 hours ago, Desblat said:

OnEquip function is used to create Light object, it's actually fire that follows lighter that shines, not the lighter itself. And to show lighter in hands visually:

OverrideSymbol - place lighter into hand instead of invisible placeholder

ShowSymbol - shows hand with lighter

HideSymbol - hides hand 

You should keep all the code that was in OnEquip originally, and only add your If-the-else instead of line with Ignite(). 

I had kept all the other code is OnEquip, the only thing I changed was the line containing inst.components.burnable:Ignite(), which i replaced with the piece of code I showed you. I didn't touch any of the code including OverrideSymbol, HideSymbol or ShowSymbol.

11 hours ago, Desblat said:

Your approach is wrong. You can edit Light properties from OnEquip function. You need to change flame Light, not lighter light, because lighter doesn't have Light component.

Study OnEquip component, there is some thing like inst.fire=SpawnPrefab("fire") 

inst.fire is a link to fire that we need. Now after spawning fire you can add this :

If owner.prefab=="" then

inst.fire.Light:SetIntensity(.85)

end

Note that you can not use link to fire before fire was created or you will crash. 

 

The whole section including inst.fire = SpawnPrefab("lighterfire") is commented out. I don't know what that means for editing the code, if the code should go elsewhere or if I should uncomment that section or what.

 

20 hours ago, Mayli-Song said:

The whole section including inst.fire = SpawnPrefab("lighterfire") is commented out. I don't know what that means for editing the code, if the code should go elsewhere or if I should uncomment that section or what.

It is still there, but it's more complex, klei made it so it uses different lights for different skins of lighter. The approach is the same. Here is the code.

 

local function onequip(inst, owner)
	------ EDIT FUEL ------
	if owner.prefab ~= "willow" then
		inst.components.burnable:Ignite()
	end
	---- end edit fuel ----
	
    local skin_build = inst:GetSkinBuild()
    if skin_build ~= nil then
        owner:PushEvent("equipskinneditem", inst:GetSkinName())
        owner.AnimState:OverrideItemSkinSymbol("swap_object", skin_build, "swap_lighter", inst.GUID, "swap_lighter")
    else
        owner.AnimState:OverrideSymbol("swap_object", "swap_lighter", "swap_lighter")
    end

    owner.AnimState:Show("ARM_carry")
    owner.AnimState:Hide("ARM_normal")

    owner.SoundEmitter:PlaySound("dontstarve/wilson/lighter_on")


    if inst.fires == nil then
        inst.fires = {}

        for i, fx_prefab in ipairs(inst:GetSkinName() == nil and { "lighterfire" } or SKIN_FX_PREFAB[inst:GetSkinName()] or {}) do
            local fx = SpawnPrefab(fx_prefab)
            fx.entity:SetParent(owner.entity)
            fx.entity:AddFollower()
            fx.Follower:FollowSymbol(owner.GUID, "swap_object", fx.fx_offset_x, fx.fx_offset_y, 0)
            fx:AttachLightTo(owner)

			------ EDIT LIGHT ------
			if owner.prefab == "willow" and fx.Light then
				fx.Light:SetIntensity(.6)
				fx.Light:SetRadius(.5)
				fx.Light:SetFalloff(.6)
				fx.Light:SetColour(180 / 255, 195 / 255, 225 / 255)
			end
			---- end edit light ----
			
            table.insert(inst.fires, fx)
        end
    end


    --[[if inst.fire == nil then
        inst.fire = SpawnPrefab("lighterfire")
        --inst.fire.Transform:SetScale(.125, .125, .125)
        inst.fire.entity:AddFollower()
        inst.fire.Follower:FollowSymbol(owner.GUID, "swap_object", 56, -40, 0)
    end]]
end

 

1 hour ago, Desblat said:

It is still there, but it's more complex, klei made it so it uses different lights for different skins of lighter. The approach is the same. Here is the code.

I said this fixed it but actually on closer inspection, no matter what edits I do to the intensity or radius in the light section, the lighter doesn't get any brighter. I'm really sorry to keep bugging you on this because I really thought this worked but even changing the intensity to 1.00 and the radius to 100 doesn't produce any noticeable change.

18 minutes ago, Mayli-Song said:

I said this fixed it but actually on closer inspection, no matter what edits I do to the intensity or radius in the light section, the lighter doesn't get any brighter. I'm really sorry to keep bugging you on this because I really thought this worked but even changing the intensity to 1.00 and the radius to 100 doesn't produce any noticeable change.

Make your-own lighterfire prefab with brighter light and uncomment last section in onequipm but only for willow. That should do.

3 hours ago, Desblat said:

Make your-own lighterfire prefab with brighter light and uncomment last section in onequipm but only for willow. That should do.

lighterfire itself has no light, its in lighterfire_common, so I tried making a lighterfire_common with the brighter stats and subbing it in the commented out section like this

if owner.prefab == "willow" then
        if inst.fires == nil then
            inst.fires = SpawnPrefab("lighterfire_common_willow")
            --inst.fire.Transform:SetScale(.125, .125, .125)
            inst.fire.entity:AddFollower()
            inst.fire.Follower:FollowSymbol(owner.GUID, "swap_object", 56, -40, 0)
        end
    end

I had to change inst.fire to inst.fires or the game crashes, but like this it doesn't do anything. It doesn't crash though so I guess there's that.

It's not possible to spawn lighterfire_common_willow because it's not a prefab it's a template.

image.thumb.png.61a2559c454319b840b3ab5b930e9f51.png

Use nightstickfire prefab. It's bright and it's simple as that.

 

    if inst.fire2 == nil then
        inst.fire2= SpawnPrefab("nightstickfire")
        --inst.fire2.Transform:SetScale(.125, .125, .125)
        inst.fire2.entity:AddFollower()
        inst.fire2.Follower:FollowSymbol(owner.GUID, "swap_object", 56, -40, 0)
    end
Edited by Desblat

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...