light.lua 768 B

12345678910111213141516171819202122
  1. local S = minetest.get_translator("testtools")
  2. minetest.register_tool("testtools:lighttool", {
  3. description = S("Light tool"),
  4. inventory_image = "testtools_lighttool.png",
  5. groups = { testtool = 1, disable_repair = 1 },
  6. on_use = function(itemstack, user, pointed_thing)
  7. local pos = pointed_thing.above
  8. if pointed_thing.type ~= "node" or not pos then
  9. return
  10. end
  11. local node = minetest.get_node(pos)
  12. local time = minetest.get_timeofday()
  13. local sunlight = minetest.get_natural_light(pos)
  14. local artificial = minetest.get_artificial_light(node.param1)
  15. local message = ("param1 0x%02x | time %.5f | sunlight %d | artificial %d")
  16. :format(node.param1, time, sunlight, artificial)
  17. minetest.chat_send_player(user:get_player_name(), message)
  18. end
  19. })