Jump to content

Recommended Posts

I would like to modify a sleeping structure to check for the current season, and then set SLEEP_TARGET_TEMP_MYSTRUCTURE accordingly to higher in Winter and lower in summer.

The routine to approach the target temperature with each sleeping tick seems to work fine.
I just don't know how to check for the current season properly.

I tried to use print to find the values in the console, but it appears I'm either addressing the wrong variables or I'm addressing them in the wrong way (visibilities).
So far I tried  SEASONS.season, SEASONS._season and their :value, etc.

 

Please help me to translate this lua Pseudocode into DST compatible luascript. :)
Not sure about the best values for the target temperature, but that's no problem to find out by playtesting.

 

Quote

if Season == spring then
      SLEEP_TARGET_TEMP_HOUSE = 30
    elseif Season == summer then
      SLEEP_TARGET_TEMP_HOUSE = 20
    elseif Season == autumn then
      SLEEP_TARGET_TEMP_HOUSE = 30
    elseif Season == winter then
      SLEEP_TARGET_TEMP_HOUSE = 40
    else
      error("invalid Season")
    end

 

Hello Muche,

I found  "TheWorld.state.isspring" doing a search for seasons, within this board.
It still doesnt work though, maybe because the code isn't written inside modmain.lua.

I'll just add what I have so far. Commented out my attempt on TheWorld.state in lines 23-35 of wilson_house.lua and tried to comment what I am intending with the lines and where they should go later, if the season check works. Everything beyond line 39 works fine.

If I uncomment, then the game crashes. Compiler handles TheWorld as an undefined variable IIRC.

DST Wilson Hut.rar

The prefab file is being loaded before the game starts, thus TheWorld is indeed nil.

For a quick check (before the code is moved into its final place, as noted in the comments), move the code into fn function. It gets executed when you (debug) spawn the prefab.

Thank you!

This advice helped me to understand why I could not refer to TheWorld.

I can assign the target temp according to the season now.

Somehow the house does not yet cool the person inside down if target temp < player temp, while it does heat the player up if target temp > player temp as intended.
But I guess that's just a minor problem and I'll find a workaround on that on my own.

Edit: Got it. :)

Edited by KainMorgen

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