Jump to content

Recommended Posts

Thermometer Mod

-----------------------------------------------------------------------------

First mod. woohoo!

So story of how i got this idea i was playing around with mods for the first time, one being Always on status mod, after seeing the krampus naughtiness and temperature part, i thought, hmm there is no realistic way you could know your exact body temperature, let alone 24/7 (Because don't starve is basically photorealism for games *points to pigmen*) and i've been wanting to get into modding and this seems like a fairly simple, non-character mod to start out with
What i have planned -

Thermomter - Crafting Recipe 4 cut stone 1 red gem*

While held shows body temperature

drains durability at around the speed of a torch

[maybe]

Naughtiness meter - 4 cut stone 1 purple gem 5 nightmare fuel*

While held shows naughtiness rating

drains durability at around 3/4 the speed of a torch

also, if your the kind of person who likes answering questions feel free to follow this, for tons of questions will be asked, you have been warned

 

 

*Subject to change

 

Ps. if anyone  here's an artist i would love for someone to do the textures, since 1. drawing with a mouse and keyboard is pretty hard and my tablet is broken atm 2. i highly doubt anything i could make would fit in with the don't starve art style

Edited by Blazingice26
Link to comment
https://forums.kleientertainment.com/forums/topic/28080-wip-thermometer-mod/
Share on other sites

So, right now im trying to isolate the code which finds and displays the temperature without invoking the always-on display of health sanity hunger and naughtiness

 

here's what i have so far, still trying to isolate the temperature without breaking the rest of it

-- V0.1 Isolating the temperature feature
 
-- Created by Blazingice26
-- Lots of credit to Kiopho for alwayson status mod, the base mod i used for this
--------------------------------------------------------------------------------------------
 
Assets = {
Asset("ATLAS", "images/status_bg.xml"),
}
 
--------------------------------------------------------------------------------------------
 
local Badge = GLOBAL.require "widgets/badge"
 
local TemperatureBadge = Class(Badge, function(status, owner)
    Badge._ctor(status, "temperature", owner)
end)
 
local function StatusPost()
 
local player = GLOBAL.GetPlayer()
local controls = player.HUD.controls
local status = controls.status
 
controls.clock.text:SetPosition(5,0,0)
 
controls.sidepanel:SetPosition(-100,-70,0)
 
status.brain:SetPosition(0,10,0)
status.stomach:SetPosition(-62,35,0)
status.heart:SetPosition(62,35,0)
 
status.temperature = status:AddChild(TemperatureBadge(owner))
status.temperature:SetPosition(57.5,5,0)
status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent())
 
status.inst:ListenForEvent("temperaturedelta", function(inst, data) status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent()) end, status.owner)
 
-- controls.status.temperature:Hide()
-- controls.status.naughty:Hide()
end
 
AddSimPostInit(StatusPost)
--  I assume all i need is whats above here, but i keep this down here to prevent any unknown issues, do i need this?
 
local function applyupgrades(inst)
 
local max_upgrades = 15
local upgrades = math.min(inst.level, max_upgrades)
 
local hunger_percent = inst.components.hunger:GetPercent()
local health_percent = inst.components.health:GetPercent()
local sanity_percent = inst.components.sanity:GetPercent()
 
inst.components.hunger.max = math.ceil(TUNING.WX78_MIN_HUNGER + upgrades* (TUNING.WX78_MAX_HUNGER - TUNING.WX78_MIN_HUNGER)/max_upgrades)
inst.components.health.maxhealth = math.ceil(TUNING.WX78_MIN_HEALTH + upgrades* (TUNING.WX78_MAX_HEALTH - TUNING.WX78_MIN_HEALTH)/max_upgrades)
inst.components.sanity.max = math.ceil(TUNING.WX78_MIN_SANITY + upgrades* (TUNING.WX78_MAX_SANITY - TUNING.WX78_MIN_SANITY)/max_upgrades)
 
inst.components.hunger:SetPercent(hunger_percent)
inst.components.health:SetPercent(health_percent)
inst.components.sanity:SetPercent(sanity_percent)
 
end
 
local function newoneat(inst, food)
 
if food and food.components.edible and food.components.edible.foodtype == "GEARS" then
inst.level = inst.level + 1
applyupgrades(inst)
inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
inst.HUD.controls.status.heart:PulseGreen()
inst.HUD.controls.status.stomach:PulseGreen()
inst.HUD.controls.status.brain:PulseGreen()
 
inst.HUD.controls.status.brain:ScaleTo(1.2,.9,.7)
inst.HUD.controls.status.heart:ScaleTo(1.2,.9,.7)
inst.HUD.controls.status.stomach:ScaleTo(1.2,.9,.7)
end
end
 
local function wx78eat(inst)
inst.components.eater:SetOnEatFn(newoneat)
end
 

AddPrefabPostInit("wx78", wx78eat)

Edited by Blazingice26

Alright, i think i have finally figured this out, this seems like whats making the temperature, (cuz i removed it and it worked but no temperature)

    status.temperature = status:AddChild(TemperatureBadge(owner))
    status.temperature:SetPosition(57.5,5,0)
    status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent())
    
    status.inst:ListenForEvent("temperaturedelta", function(inst, data)        status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent()) end,           status.owner)

 

Now, i have learned a small bit about lua between here so i think i should put this in

 

local function Equipped(thermometer)
if Equipped = true then
    status.temperature = status:AddChild(TemperatureBadge(owner))
    status.temperature:SetPosition(57.5,5,0)
    status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent())
    
    status.inst:ListenForEvent("temperaturedelta", function(inst, data) status.temperature:SetTemperature(status.owner.components.temperature:GetCurrent()) end, status.owner)
   else
     nil

This is most likely 100% wrong but im still learning, any advice/feedback/tellingmeifthiswillwork?

Edited by Blazingice26

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