Page 1 of 1

[Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Wed Jun 04, 2014 00:44
by HeroOfTheWinds
So, a while back there was a thread by MirceaKitsune asking for mapgenv7's temperature/humidity and weather to be added back into the core game. In that thread, Paramat said he wished that a mod would be made to show the temperature and humidity at any given point in the world... Leading to this: the tempidity mod, which creates a simple HUD display for each individual player to see the temperature and humidity where they are currently standing!

Right now, it still is in development, but it has enough basic functionality to be worth posting, and development is proceeding quickly. There is currently no set up at all on the player's end, you just have to put the mod in and enable it. It has been extensively tested with watershed and skylands, but regular mapgenv7 environments are still experimental, as they use 2D perlin noise parameters instead of the 3D noise used by the aforementioned mods.

Version 0.2 UPDATE:
  • Now compatible with 2D noise-based mgv7 (basically, default mgv7).
  • Formula for determining the display value of temperature and humidity in skylands and watershed has been reworked, temperatures now range from -35 C to +35 C. Humidity is in percentage.
  • Automatic check for installed mods and currently used mapgen.
Screenshots:
Spoiler
Image
Image
Image
License: LGPL v2.1
Download: https://github.com/HeroOfTheWinds/tempi ... master.zip (Unzip, rename to 'tempidity', and place in mods folder)
GitHub: https://github.com/HeroOfTheWinds/tempidity

Planned changes:
  • Allow display to be turned on and off, either via chat-command or by later having a thermometer item that must be in the inventory
  • See if a faster method of determining temp/humidity at a position can be developed
  • Have a more believable range of temperatures than current for 2D noisegen (71.5 degrees Celsius is not habitable!)
  • Make sure there is compatibility across all mgv7-using mods/games
Enjoy!

Re: [Mod] Temperature and Humidity HUD [0.1] [tempidity]

Posted: Wed Jun 04, 2014 01:54
by paramat
Good to see this mod, i'll try it out in watershed. This will work in watershed and skylands, but mgv7 uses 2D temp and humidity with different parameters ... mgv7 is about to be rewritten by hmmmm soon anyway. Looking at your code ... you're using hmmmm's temp and humidity scalings, which are tuned exclusively for mgv7 noise parameters where temp has 1 octave, humidity has 2 octaves. As this mod has my watershed noise params you need to (and are free too) design new scalings that make sense :)
Range of noise value depends on number of octaves and persistence:
1 octave, any persistence > variation from -1 to 1 mgv7 temp
2 octaves, persist 0.5 > -1.5 to 1.5
2 octaves, persist 0.6 > -1.6 to 1.6 mgv7 humid
3 octaves, persist 0.5 > -1.75 to 1.75 watershed

Re: [Mod] Temperature and Humidity HUD [0.1] [tempidity]

Posted: Wed Jun 04, 2014 02:23
by HeroOfTheWinds
Thanks for the input, paramat. I knew something was missing, and that clears up a lot of it.
When I update it, I'll include the default 2D params that were in one of your other posts relating to mgv7, and have the mod check first for mgv7 in the mapgen parameters, and set it to the 2D noise if so. Then, I'll have it check for watershed and/or skylands, and swap the parameters to 3D if they are found... that will also entail a secondary check with skylands so as to switch between values depending on elevation (if it's at skylands level, switch to the 3D noise)

Also, thank you for the noise value table. That is something that has always been the hardest part for me to grasp when working with perlin. When you have 3 octaves marked as watershed, what aspect of it are you referring to?

Re: [Mod] Temperature and Humidity HUD [0.1] [tempidity]

Posted: Wed Jun 04, 2014 02:37
by paramat
Yeah i should explain this ...
Generated noise value is the addition of several 'octaves'. The first octave has amplitude of 1 (outputs -1 to 1). Each additional octave is noise with a characteristic 'spread' / 'scale' half the size of the previous octave, and an amplitude that is 'persistence' x amplitude of previous octave. Each higher octave generates finer detail with a smaller amplitude, the persistence is the balance of fine detail to coarse detail.

1 octave > -1 to 1
2 octaves, persist 0.6 > output = (-1 to 1) + (-0.6 to 0.6) = -1.6 to 1.6
3 octaves, persist 0.5 > output = (-1 to 1) + (-0.5 to 0.5) + (-0.25 to 0.25) = -1.75 to 1.75

Persist:
0.33 very smooth
0.4 smooth
0.5 industry standard '1/f' noise
0.6 minetest standard
0.67 very rough / science fiction setting. In a 3D mapgen lots of overhangs and floaty stuff (used in fracture, watershed mountains)

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Wed Jun 04, 2014 21:22
by HeroOfTheWinds
Thank you again for the help, paramat.

Version 0.2 is now released!
Changes:
  • Now compatible with 2D noise-based mgv7 (basically, default mgv7).
  • Formula for determining the display value of temperature and humidity in skylands and watershed has been reworked, temperatures now range from -35 C to +35 C. Humidity is in percentage.
  • Automatic check for installed mods and currently used mapgen.
I've done a little testing with the default temperature by using Big Freaking Dig, but the results are still inconclusive on whether or not it is accurate. There certainly are some temperatures that are not natural though...

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Thu Jun 05, 2014 05:11
by paramat
Here's another suggestion ... the dtime function runs roughly 10 times per second, and each time you cycle through all players and do perlin noise calculations, this is unecessary procesing load to update the readout so often, i would put in a math.random (or some better method) so it updates every few seconds :)

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Thu Jun 05, 2014 19:33
by HeroOfTheWinds
Actually, in the first version, I had some commented-out code that would make it update only every 2 seconds. I guess it would be a good idea to add that back in. :P Until I get around to pushing a new commit with that, here's the easy way to do it:
insert "local utime = 1" before the register_globalstep() call in the code
enclose everything within the globalstep in an if block saying "if utime >= 1 then"
just before the 'end' statement of the if block, put "utime = 0"
after the end for the if block, put "utime = utime + dtime"

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sun Jun 15, 2014 10:41
by MirceaKitsune
Ahhh... I have been waiting for this! I was afraid I'll be left without any way to detect temperature and humidity, after the weather system has been carelessly removed (in my opinion at least).

I strongly suggest that this or another method to read temp / humidity is added to builtin! IMO this is a feature that should have its own default function, and which every mod should have easy access to.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sun Jun 15, 2014 12:52
by Krock
Is this efficient and fast?
https://github.com/HeroOfTheWinds/tempi ... it.lua#L82
3D noises, [playercount]-times every globalstep sounds not very fast for me.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Thu Jun 19, 2014 18:39
by HeroOfTheWinds
@Krock: Sadly, no, it is not particularly fast. Even when I set it to only update every second or two (which reminds me I still need to push those changes), it causes notable slowdown. I intend to find a more efficient method... Which leads to

@MirceaKitsune: Glad that you like the idea. There was a method built in for reading temp/humidity (mintest.get_humidity(pos)), but the wiki says the functions were removed. Still haven't tested to see if they're still coded in though... If they are, they probably would be quicker than my method.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Tue Jul 05, 2016 01:33
by basil60
Does this work in Minetest 0.4.14?
It seems to throw an error

2016-07-05 11:28:52: ERROR[Main]: ServerError: Runtime error from mod 'tempidity' in callback environment_Step(): ...r\Desktop\minetest-0.4.14\bin\..\mods\tempidity\init.lua:82: attempt to index a nil value
2016-07-05 11:28:52: ERROR[Main]: stack traceback:
2016-07-05 11:28:52: ERROR[Main]: ...r\Desktop\minetest-0.4.14\bin\..\mods\tempidity\init.lua:82: in function <...r\Desktop\minetest-0.4.14\bin\..\mods\tempidity\init.lua:66>
2016-07-05 11:28:52: ERROR[Main]: ...Desktop\minetest-0.4.14\bin\..\builtin\game\register.lua:369: in function <...Desktop\minetest-0.4.14\bin\..\builtin\game\register.lua:349>

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Tue Jul 05, 2016 14:26
by paramat
'register on mapgen init' is deprecated:

Code: Select all

minetest.register_on_mapgen_init(function(mgparams)
	if mgparams.mgname == "v7" then
		mg = "v7"
	end
end)
For this to work in mgv7 try:

Code: Select all

local mg_params = minetest.get_mapgen_params()
if mg_params.mgname == "v7" then
	mg = "v7"
end
However also the heat / humidity noise params at lines 93 and 97 need updating to the current defaults:
https://github.com/minetest/minetest/bl ... mple#L1086

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sun Jun 04, 2017 18:03
by texmex
I don't understand how to update this based on the instructions above. Could someone with the skillset provide a solution so that we may have this mod's functionality back?

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sat Jan 20, 2018 00:13
by ShadMOrdre
Ive updated this mod to work with mgv5, mgv7, valleys, and carpathian. I have removed support for watershed and skylands.

DOWNLOAD: https://github.com/ShadMOrdre/lib_tempe ... master.zip
Browse Code: https://github.com/ShadMOrdre/lib_tempedity

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sat Jan 20, 2018 12:27
by paramat
I just added these APIs to MT 0.5.0dev:

Code: Select all

* `minetest.get_heat(pos)`
    * Returns the heat at the position, or `nil` on failure.
* `minetest.get_humidity(pos)`
    * Returns the humidity at the position, or `nil` on failure.
* `minetest.get_biome_data(pos)`
    * Returns a table containing:
        * `biome` the biome id of the biome at that position
        * `heat` the heat at the position
        * `humidity` the humidity at the position
    * Or returns `nil` on failure.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Sat Jan 20, 2018 18:23
by v-rob
paramat wrote:I just added these APIs to MT 0.5.0dev:

Code: Select all

* `minetest.get_heat(pos)`
    * Returns the heat at the position, or `nil` on failure.
* `minetest.get_humidity(pos)`
    * Returns the humidity at the position, or `nil` on failure.
* `minetest.get_biome_data(pos)`
    * Returns a table containing:
        * `biome` the biome id of the biome at that position
        * `heat` the heat at the position
        * `humidity` the humidity at the position
    * Or returns `nil` on failure.
*Gasp!* Finally! I've been waiting for this for a while. Thanks paramat!

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Tue Jan 23, 2018 04:14
by ShadMOrdre
paramat wrote:I just added these APIs to MT 0.5.0dev:

Code: Select all

* `minetest.get_heat(pos)`
    * Returns the heat at the position, or `nil` on failure.
* `minetest.get_humidity(pos)`
    * Returns the humidity at the position, or `nil` on failure.
* `minetest.get_biome_data(pos)`
    * Returns a table containing:
        * `biome` the biome id of the biome at that position
        * `heat` the heat at the position
        * `humidity` the humidity at the position
    * Or returns `nil` on failure.
Will any of this get backported to 0.4.17dev? If the answer stays no, then this mod can be used for 0.4.16 and earlier to still gain these benefits.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Tue Jan 23, 2018 07:58
by paramat
It won't be backported to 0.4.17 as it's not a bugfix.

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Tue Jan 23, 2018 18:08
by texmex
Here's a 0.5 version with the same output.

Code: Select all

local function tempidity ()
  for _,player in ipairs(minetest.get_connected_players()) do
    minetest.chat_send_player(player:get_player_name(), "Heat:" ..minetest.get_heat(player:get_pos()))
    minetest.chat_send_player(player:get_player_name(), "Humidity:" ..minetest.get_humidity(player:get_pos()))
  end
  minetest.after(1, tempidity)
end

minetest.after(1, tempidity)

Re: [Mod] Temperature and Humidity HUD [0.2] [tempidity]

Posted: Mon Feb 11, 2019 04:55
by Skulls
A hacky hack updated this to function with the snazzy new functions:
https://github.com/misterskullz/tempidity

And biome name has been added
Image