summaryrefslogtreecommitdiff
path: root/games/devtest/mods/testtools/light.lua
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2021-03-16 17:37:24 +0000
committerGitHub <noreply@github.com>2021-03-16 18:37:24 +0100
commit91135381421f646e0f6a8d9201b5cdc7e42605e1 (patch)
treec208de82e645da4564c533fad3ce46a5f0343acf /games/devtest/mods/testtools/light.lua
parent88f514ad7a849eb4a67b5ee2c41c93856cf3808f (diff)
downloadminetest-91135381421f646e0f6a8d9201b5cdc7e42605e1.tar.gz
minetest-91135381421f646e0f6a8d9201b5cdc7e42605e1.tar.bz2
minetest-91135381421f646e0f6a8d9201b5cdc7e42605e1.zip
DevTest: Formspec tests, children getter, better lighttool (#10918)
Diffstat (limited to 'games/devtest/mods/testtools/light.lua')
-rw-r--r--games/devtest/mods/testtools/light.lua31
1 files changed, 23 insertions, 8 deletions
diff --git a/games/devtest/mods/testtools/light.lua b/games/devtest/mods/testtools/light.lua
index a9458ca6b..afca9a489 100644
--- a/games/devtest/mods/testtools/light.lua
+++ b/games/devtest/mods/testtools/light.lua
@@ -1,22 +1,37 @@
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
+local function get_func(is_place)
+ return function(itemstack, user, pointed_thing)
+ local pos
+ if is_place then
+ pos = pointed_thing.under
+ else
+ pos = pointed_thing.above
+ end
if pointed_thing.type ~= "node" or not pos then
return
end
local node = minetest.get_node(pos)
+ local pstr = minetest.pos_to_string(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)
+ local message = ("pos=%s | param1=0x%02x | " ..
+ "sunlight=%d | artificial=%d | timeofday=%.5f" )
+ :format(pstr, node.param1, sunlight, artificial, time)
minetest.chat_send_player(user:get_player_name(), message)
end
+end
+
+minetest.register_tool("testtools:lighttool", {
+ description = S("Light Tool") .. "\n" ..
+ S("Show light values of node") .. "\n" ..
+ S("Punch: Light of node above touched node") .. "\n" ..
+ S("Place: Light of touched node itself"),
+ inventory_image = "testtools_lighttool.png",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_use = get_func(false),
+ on_place = get_func(true),
})