borders.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. minetest.register_node('levels:border', {
  2. description = 'Invisible Border',
  3. inventory_image = 'levels_border.png',
  4. drawtype = 'allfaces',
  5. paramtype = 'light',
  6. pointable = false,
  7. tiles = {'levels_blank.png'},
  8. groups = {breakable=1, not_in_creative_inventory=1},
  9. })
  10. minetest.register_node('levels:border_alt', {
  11. description = 'visible Border',
  12. drawtype = 'allfaces',
  13. paramtype = 'light',
  14. pointable = true,
  15. tiles = {'levels_border.png'},
  16. groups = {breakable=1},
  17. on_construct = function(pos)
  18. local timer = minetest.get_node_timer(pos)
  19. timer:start(30)
  20. end,
  21. on_timer = function(pos)
  22. minetest.set_node(pos, {name='levels:border'})
  23. end
  24. })
  25. minetest.register_chatcommand('border', {
  26. description = 'Turn invisible borders visible.',
  27. func = function(name)
  28. local player = minetest.get_player_by_name(name)
  29. local pos = vector.round(player:get_pos())
  30. local pos1 = {x=pos.x+5, y=pos.y+5, z=pos.z+5}
  31. local pos2 = {x=pos.x-5, y=pos.y-3, z=pos.z-5}
  32. local node_list = minetest.find_nodes_in_area(pos1, pos2, 'levels:border')
  33. for _,pos in pairs(node_list) do
  34. minetest.set_node(pos, {name='levels:border_alt'})
  35. end
  36. end
  37. })