diff options
author | HybridDog <3192173+HybridDog@users.noreply.github.com> | 2020-10-06 20:49:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 20:49:46 +0200 |
commit | 2f4037752b023f87ca1f8859a8dce4f833353967 (patch) | |
tree | 5c52b01857c8c46d709d43d1bbc194a3805acded /games/devtest/mods/testtools/light.lua | |
parent | e80fc22dd996e5b0efd8c4f67700c0920e323e46 (diff) | |
download | minetest-2f4037752b023f87ca1f8859a8dce4f833353967.tar.gz minetest-2f4037752b023f87ca1f8859a8dce4f833353967.tar.bz2 minetest-2f4037752b023f87ca1f8859a8dce4f833353967.zip |
Add minetest.get_artificial_light and minetest.get_natural_light (#5680)
Add more detailed light detection functions, a function to get the artificial light (torches) and a function to get the sunlight as seen by the player (you can specify timeofday).
Co-authored-by: rubenwardy <rw@rubenwardy.com>
Diffstat (limited to 'games/devtest/mods/testtools/light.lua')
-rw-r--r-- | games/devtest/mods/testtools/light.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/games/devtest/mods/testtools/light.lua b/games/devtest/mods/testtools/light.lua new file mode 100644 index 000000000..a9458ca6b --- /dev/null +++ b/games/devtest/mods/testtools/light.lua @@ -0,0 +1,22 @@ + +local S = minetest.get_translator("testtools") + +minetest.register_tool("testtools:lighttool", { + description = S("Light tool"), + inventory_image = "testtools_lighttool.png", + groups = { testtool = 1, disable_repair = 1 }, + on_use = function(itemstack, user, pointed_thing) + local pos = pointed_thing.above + if pointed_thing.type ~= "node" or not pos then + return + end + + local node = minetest.get_node(pos) + local time = minetest.get_timeofday() + local sunlight = minetest.get_natural_light(pos) + local artificial = minetest.get_artificial_light(node.param1) + local message = ("param1 0x%02x | time %.5f | sunlight %d | artificial %d") + :format(node.param1, time, sunlight, artificial) + minetest.chat_send_player(user:get_player_name(), message) + end +}) |