Jump to content

Help me, please!


Recommended Posts

Hi, firstly - It's my first time creating mods and I've never been interested in programming, so I don't know a thing sadly. :wilson_resigned:

So, I tried to do mods for my bf and me, but I cannot do something I would really want in a game:

>(Both) recover their sanity near themselves

>(Both) no sanity loss at the dusk (or smaller), but normal at night

>(for Nick) Gains sanity by drawing on mini signs (+15 or something like that)

>(For Nick) Slower freezes but faster overheat (if it can be done)

>(For Nikola) Slower overheat but faster freezes (if it can be done)

Also, I don't know how to make them have custom inventory (I know, I'm an idiot):

>(For Nick) papyrus and a feather pencil
(Able to craft Mini Sign from the start)

>(For Nikola) Fur Roll and Life-Giving Amulet or Telltale Heart

 

Thank You Really Much!

 

nikola.lua

nick.lua

Edited by Enderia
Link to comment
Share on other sites

That is a lot of things, especially for someone who has never done something like this before. Check out the newcomer post to get a head-start. It tells you how to search the forums efficiently, where to find the game files and the crash/debug log files, and how to debug your mods.

>(Both) recover their sanity near themselves
I'm guessing you mean they gain sanity when they are close to each other.
Put this at the bottom of the master_postinit() function in both character's Lua, after the "if TheWorld.ismastersim" check. Remember to substitute the names!!!

Spoiler

-- Every 1.0 seconds, execute the following function.
inst:DoPeriodicTask(1.0, function()
	-- Do nothing if the player is dead.
	if inst.components.health:IsDead() or inst:HasTag("playerghost") then
		return
	end
	
	-- Store the position of the player in x, y, z variables.
	local x,y,z = inst.Transform:GetWorldPosition()
	
	-- Description of important function, which finds specific entities within a range:
	-- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags)
	
	-- We have limited it to any entity that is not ghosts, visuals or things in limbo.
	-- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want.
	-- You can replace "TUNING.SANITY_EFFECT_RANGE" with a number instead, if you want to change the range.
	-- TUNING.SANITY_EFFECT_RANGE is 10.
	local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, nil, {"playerghost", "INLIMBO", "FX", "NOCLICK", "DECOR"}, nil)
	for k,v in pairs(ents) do 
		-- Substitute "THE_OTHER_CHARACTER_PREFAB" for Nick in Nikola's code, and vice versa.
		if v.prefab == "THE_OTHER_CHARACTER_PREFAB" then
			-- Give 1 sanity if a player with that name is found.
			-- "true" makes the sanity-badge NOT pulse and make a sound when doing this.
			inst.components.sanity:DoDelta(1, true)
			return
		end
	end
end)

 

>(Both) no sanity loss at the dusk (or smaller), but normal at night

>(for Nick) Gains sanity by drawing on mini signs (+15 or something like that)
Sadly, neither the feather_pencil nor the minisign_item know who is drawing with/on them when it happens, so there is no way to know if Nick did it. The only place where there is probably a "doer" variable to access, is in ACTIONS.DRAW.fn. Those are easy to change in DS, but require something special for the server in DST. I can't remember how right now. This one merits its own thread IMO.

>(For Nick) Slower freezes but faster overheat (if it can be done)
These are a bit finicky.Try searching for freeze, overheat and insulation on the forums.

>(For Nikola) Slower overheat but faster freezes (if it can be done)
These are a bit finicky.Try searching for freeze, overheat and insulation on the forums.

>Also, I don't know how to make them have custom inventory (I know, I'm an idiot):
>(For Nick) papyrus and a feather pencil
>(For Nikola) Fur Roll and Life-Giving Amulet or Telltale Heart

Look in your character's Lua files. There's a list called start_inv near the top. Just populate that with items, e.g.,

local start_inv = {
"papyrus",
"papyrus",
"featherpencil",
}

You can find the item prefab names on the Don't Starve Wiki. Here's an example for the Feather Pencil.

>(For Nick) Know the recipe for (and be able to craft) Mini Sign item from the start.
Put this after the "if TheWorld.ismastersim" check in Nick's character Lua.

inst.components.builder:AddRecipe("minisign_item")

That should get you started.

Link to comment
Share on other sites

On 9.07.2019 at 1:19 PM, Ultroman said:

That is a lot of things, especially for someone who has never done something like this before. Check out the newcomer post to get a head-start. It tells you how to search the forums efficiently, where to find the game files and the crash/debug log files, and how to debug your mods.

>(Both) recover their sanity near themselves
I'm guessing you mean they gain sanity when they are close to each other.
Put this at the bottom of the master_postinit() function in both character's Lua, after the "if TheWorld.ismastersim" check. Remember to substitute the names!!!

  Reveal hidden contents


-- Every 1.0 seconds, execute the following function.
inst:DoPeriodicTask(1.0, function()
	-- Do nothing if the player is dead.
	if inst.components.health:IsDead() or inst:HasTag("playerghost") then
		return
	end
	
	-- Store the position of the player in x, y, z variables.
	local x,y,z = inst.Transform:GetWorldPosition()
	
	-- Description of important function, which finds specific entities within a range:
	-- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags)
	
	-- We have limited it to any entity that is not ghosts, visuals or things in limbo.
	-- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want.
	-- You can replace "TUNING.SANITY_EFFECT_RANGE" with a number instead, if you want to change the range.
	-- TUNING.SANITY_EFFECT_RANGE is 10.
	local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, nil, {"playerghost", "INLIMBO", "FX", "NOCLICK", "DECOR"}, nil)
	for k,v in pairs(ents) do 
		-- Substitute "THE_OTHER_CHARACTER_PREFAB" for Nick in Nikola's code, and vice versa.
		if v.prefab == "THE_OTHER_CHARACTER_PREFAB" then
			-- Give 1 sanity if a player with that name is found.
			-- "true" makes the sanity-badge NOT pulse and make a sound when doing this.
			inst.components.sanity:DoDelta(1, true)
			return
		end
	end
end)

 

>(Both) no sanity loss at the dusk (or smaller), but normal at night

>(for Nick) Gains sanity by drawing on mini signs (+15 or something like that)
Sadly, neither the feather_pencil nor the minisign_item know who is drawing with/on them when it happens, so there is no way to know if Nick did it. The only place where there is probably a "doer" variable to access, is in ACTIONS.DRAW.fn. Those are easy to change in DS, but require something special for the server in DST. I can't remember how right now. This one merits its own thread IMO.

>(For Nick) Slower freezes but faster overheat (if it can be done)
These are a bit finicky.Try searching for freeze, overheat and insulation on the forums.

>(For Nikola) Slower overheat but faster freezes (if it can be done)
These are a bit finicky.Try searching for freeze, overheat and insulation on the forums.

>Also, I don't know how to make them have custom inventory (I know, I'm an idiot):
>(For Nick) papyrus and a feather pencil
>(For Nikola) Fur Roll and Life-Giving Amulet or Telltale Heart

Look in your character's Lua files. There's a list called start_inv near the top. Just populate that with items, e.g.,


local start_inv = {
"papyrus",
"papyrus",
"featherpencil",
}

You can find the item prefab names on the Don't Starve Wiki. Here's an example for the Feather Pencil.

>(For Nick) Know the recipe for (and be able to craft) Mini Sign item from the start.
Put this after the "if TheWorld.ismastersim" check in Nick's character Lua.


inst.components.builder:AddRecipe("minisign_item")

That should get you started.

Thank You so much! Everything works perfectly!

I couldn't find anything for the freezing (For Nikola I just used tag "heatresistant" I've found in Willow code) in the forum (the thing I've found wasn't working) but I'm still searching.

Link to comment
Share on other sites

I'm very glad to hear that :) And you're welcome!

There are variables in the temperature component called inherentinsulation and inherentsummerinsulation. Negative values for these are ignored. A positive value for the former makes your character freeze slower, and a positive value for the latter makes you heat up slower.

Edited by Ultroman
Link to comment
Share on other sites

1 hour ago, Ultroman said:

There are variables in the temperature component called inherentinsulation and inherentsummerinsulation. Negative values for these are ignored. A positive value for the former makes your character freeze slower, and a positive value for the latter makes you heat up slower.

Ah, thank You again!

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