Jump to content

Help with Nightvision and Fast Walk coding


Recommended Posts

Hi all,

Apparently I'm trying to make a character that can survive in the darkness, and I saw a few other modders having night vision. I thought that I could give it a go but do not know where to begin. Walking Fast for my character is just to boost him when collecting materials, as when winter comes, it is difficult to gather materials alrealdy. I hope someone can help me in this as it is my first time doing it ><.

Link to comment
Share on other sites

To change his walkspeed you can go into: dont_starve/mods/yourmod/scripts/prefabs/yourcharacter.lua

In that .lua you can find:

inst.components.locomotor.walkspeed = 4

inst.components.locomotor.runspeed = 6

These are the defaults for walk and run speeds. I am pretty sure walkspeed is the character's normal speed and runspeed is their speed with speed-affecting items (such as walking cane, aerodynamic hat, coffee, etc) So say you change the walkspeed to 10 (which is pretty fast) It would be a good idea to change the runspeed to +25% of the walkspeed. So if the walkspeed was 10, the runspeed would be 12.5. (10+2.5) If anyone could correct me if I am wrong about runspeed, that would be much appreciated.

As for the nightvision, add this to dont_starve/mods/yourmod/scripts/prefabs/yourcharacter.lua in the local fn: (with the hunger, sanity and health setting)

    inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)
    GetWorld().components.colourcubemanager:SetOverrideColourCube("images/colour_cubes/beaver_vision_cc.tex")

You can twiddle with the numbers to change the light around.

This will give your character "nightvision" (well it's actually a glowing light, but shh)

Link to comment
Share on other sites

15 hours ago, NeddoFreddo said:

To change his walkspeed you can go into: dont_starve/mods/yourmod/scripts/prefabs/yourcharacter.lua

In that .lua you can find:

inst.components.locomotor.walkspeed = 4

inst.components.locomotor.runspeed = 6

These are the defaults for walk and run speeds. I am pretty sure walkspeed is the character's normal speed and runspeed is their speed with speed-affecting items (such as walking cane, aerodynamic hat, coffee, etc) So say you change the walkspeed to 10 (which is pretty fast) It would be a good idea to change the runspeed to +25% of the walkspeed. So if the walkspeed was 10, the runspeed would be 12.5. (10+2.5) If anyone could correct me if I am wrong about runspeed, that would be much appreciated.

As for the nightvision, add this to dont_starve/mods/yourmod/scripts/prefabs/yourcharacter.lua in the local fn: (with the hunger, sanity and health setting)

    inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)
    GetWorld().components.colourcubemanager:SetOverrideColourCube("images/colour_cubes/beaver_vision_cc.tex")

You can twiddle with the numbers to change the light around.

This will give your character "nightvision" (well it's actually a glowing light, but shh)

But when I launch my character in DST, it tells me nil value for the Colour Cube thing.

Link to comment
Share on other sites

3 minutes ago, AyzatMoDs said:

But when I launch my character in DST, it tells me nil value for the Colour Cube thing.

Oh, you're making the mod for DST. In that case, you'll need to put

  inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)
    GetWorld().components.colourcubemanager:SetOverrideColourCube("data/images/colour_cubes/beaver_vision_cc.tex")

If, for some reason that doesn't work, (I am not that great at DST coding) put:

  inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)

This just gets rid of the color cube, so the light will just be that, a colored light. So you might have to change around the light intensity and color so that you can see it properly.

Link to comment
Share on other sites

 

11 minutes ago, NeddoFreddo said:

Oh, you're making the mod for DST. In that case, you'll need to put

  inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)
    GetWorld().components.colourcubemanager:SetOverrideColourCube("data/images/colour_cubes/beaver_vision_cc.tex")

If, for some reason that doesn't work, (I am not that great at DST coding) put:

  inst.entity:AddLight()
    inst.Light:SetRadius(20)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(128/255,80/255,0/255)
    inst.Light:Enable(true)

This just gets rid of the color cube, so the light will just be that, a colored light. So you might have to change around the light intensity and color so that you can see it properly.

Thanks, NeddoFreddo!

Apparently the first one didn't work as planned.. colourcubemanager.

The second one works fine. The colour doesn't matter much really.

Was wondering how to create a wearable infinite item for my character to gain sanity overtime? Would that be possible?

Link to comment
Share on other sites

9 minutes ago, AyzatMoDs said:

 

Thanks, NeddoFreddo!

Apparently the first one didn't work as planned.. colourcubemanager.

The second one works fine. The colour doesn't matter much really.

Was wondering how to create a wearable infinite item for my character to gain sanity overtime? Would that be possible?

No problem. Always happy to help :D

Assuming you haven't already got the head item working, you can use this tutorial: 

But change it from a handslot equippable item to whatever slot you want equippable item.

If you have problems doing that, I have previously made a headslot item, so I could upload that and you could just change the names and art around. 

After you've done that, or assuming you've already made the head item, getting it to have infinite durability is ultra-easy. Just don't add in a function adding durability.

To make your item slowly restore sanity, put this in the local function:

    inst:AddComponent("dapperness")
    inst.components.dapperness.dapperness = TUNING.DAPPERNESS_MED

TUNING.DAPPERNESS_MED restores 3.3 sanity per minute. You could change that to TUNING.DAPPERNESS_LARGE, TUNING.DAPPERNESS_SMALL, or TUNING.DAPPERNESS_TINY. I am not sure what values those other ones are though. An easier option is to replace the whole TUNING.DAPPERNESS_MED with a number, (which will become sanity/min when worn. So 

inst.components.dapperness.dapperness = 10

will make the item restore 10 sanity/min.)

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