mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
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>
This commit is contained in:
parent
e80fc22dd9
commit
2f4037752b
9 changed files with 180 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
local S = minetest.get_translator("testtools")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
dofile(minetest.get_modpath("testtools") .. "/light.lua")
|
||||
|
||||
-- TODO: Add a Node Metadata tool
|
||||
|
||||
minetest.register_tool("testtools:param2tool", {
|
||||
|
|
22
games/devtest/mods/testtools/light.lua
Normal file
22
games/devtest/mods/testtools/light.lua
Normal file
|
@ -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
|
||||
})
|
BIN
games/devtest/mods/testtools/textures/testtools_lighttool.png
Normal file
BIN
games/devtest/mods/testtools/textures/testtools_lighttool.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue