Jump to content

Light and heat


Recommended Posts

So I was wondering if I could get some help with my mod. I want an item I'm making to give light when my character holds it  but everytime I try to do code it, it works but I can't seem to get it to disable it when it's on the ground. Also I managed to use the code to give it the same warmth of a furnace but only on the ground. Can someone help?

 

Link to comment
Share on other sites

17 hours ago, Meepenator said:

 it works but I can't seem to get it to disable it when it's on the ground

add inst.components.equippable:SetOnUnequip(onunequip) and definde what you want to do when unequipped in the local function onunequip(inst, owner) 

Link to comment
Share on other sites

1 hour ago, Parusoid said:

add inst.components.equippable:SetOnUnequip(onunequip) and definde what you want to do when unequipped in the local function onunequip(inst, owner) 

Tried that. See the only issue I have with the torch one too is that it uses the fire part of it and spawns in a little flame as well, but it does seem to only work in the hand. Right now I'm using the inst.entity:AddLight() one instead.

Link to comment
Share on other sites

I managed to figure it out so I'm going to put the two lines of code I used here just in case other people wanted to use them. 

For the onequip

if inst.Light == nil then

    local light = inst.entity:AddLight()
    inst.Light:SetRadius(0.75)
    inst.Light:SetFalloff(1)
    inst.Light:SetIntensity(0.5)
    inst.Light:SetColour(255/255,10/255,10/255)
    inst.Light:Enable(true)
    
    end

For the onunequip

    if inst.Light ~= nil then
    inst.Light:Enable(false)
        inst.Light = nil
    end

And for the part where it heats you up

 

    inst:AddComponent("heater")
    inst.components.heater:SetThermics(true, false)
    inst.components.heater.equippedheat = 200

Link to comment
Share on other sites

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
 Share

×
  • Create New...