Meepenator Posted December 2, 2018 Share Posted December 2, 2018 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 https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/ Share on other sites More sharing options...
Ultroman Posted December 2, 2018 Share Posted December 2, 2018 Have you looked at how the torch works? Link to comment https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/#findComment-1125417 Share on other sites More sharing options...
Meepenator Posted December 3, 2018 Author Share Posted December 3, 2018 Yeah, I have but I wanted my item to not work on fuel but instead be limited by the downsides it gives to the character. Link to comment https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/#findComment-1125758 Share on other sites More sharing options...
Parusoid Posted December 3, 2018 Share Posted December 3, 2018 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 https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/#findComment-1125800 Share on other sites More sharing options...
Meepenator Posted December 3, 2018 Author Share Posted December 3, 2018 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 https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/#findComment-1125839 Share on other sites More sharing options...
Meepenator Posted December 6, 2018 Author Share Posted December 6, 2018 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 https://forums.kleientertainment.com/forums/topic/99914-light-and-heat/#findComment-1127525 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now