Jump to content

Recommended Posts

Hello! I've made a mod with a small light radius work properly, but for some reason it stops working after a while. The light comes back once the server is restarted, but still glitches off at random moments.

Might not have to do with anything, but it was noticed to happen when I lose a lot of sanity or when someone lights up a torch right by me.

I have linked my character lua to the thread, but here's a peek at the master_postinit, with the light radius part at the end:
 

local master_postinit = function(inst)
	-- choose which sounds this character will play
	inst.soundsname = "wendy"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(140)
	inst.components.hunger:SetMax(150)
	inst.components.sanity:SetMax(210)
	inst.Transform:SetScale(1.1, 1.1, 1.1) 
	
	-- Speed multiplier
	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)
	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
	
	--Star Antlers light
	inst.Light:Enable(true)
	inst.Light:SetRadius(.3)
	inst.Light:SetFalloff(.4)
	inst.Light:SetIntensity(.65)
	inst.Light:SetColour(0/255, 255/255, 255/255)
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
end


Thank you for reading! ~
 

bubblegum.lua

That's how it is, I'm afraid. Certain things use your entity's light. Some turn it on for a while to simulate an effect, and then turn it off. Getting electrocuted turns on the player's light source and changes its color, and then turns it off again when the electrocution state is over. You should be able to find threads or characters where people have added light sources in other ways. One way could be to spawn an entity, put a light source on it, and write a custom script that just follows the player, and perhaps gets removed when they die and created again when they are resurrected.

@Ultroman Aw man, I don't think I would personally be able to code an entity, I'm very very beginner with programming, but I'm at least glad to know it's not that I coded the light radius wrong.  Thanks a bunch for the fast answer, I understand better now ^^

If I remember correctly, I think items that alter your character's light source only activate the moment you equip/unequip them.

If you set something up to re-run your light everytime something is equipped or unequipped, that might solve a lot of these light disappearances!

        

inst:ListenForEvent("equip", function()         --and make one for "unequip" too
        inst.Light:Enable(true)
	inst.Light:SetRadius(.3)
	inst.Light:SetFalloff(.4)
	inst.Light:SetIntensity(.65)
inst.Light:SetColour(0/255, 255/255, 255/255) 

 

 

The problem here being, since I can't really tell how big that light is from the code, if you actually equip a light source of significant size that is much larger than whatever the light your antlers gives, you'll be dousing the light source for this one instead.

10 hours ago, Kiibie said:

@Ultroman Aw man, I don't think I would personally be able to code an entity, I'm very very beginner with programming, but I'm at least glad to know it's not that I coded the light radius wrong.  Thanks a bunch for the fast answer, I understand better now ^^

It's not like you'll be "coding an entity". Klei has done that for you. You just spawn one, put the appropriate components on it, and it'll move around.

This thread could be a start.

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