worldedit-snipets.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. -- Set day and freeze time.
  2. local function func()
  3. minetest.set_timeofday(0.5);
  4. minetest.after(1, function()
  5. if func then
  6. func()
  7. end
  8. end)
  9. end func()
  10. -- Simple light smooth.
  11. local n = minetest.get_node
  12. local v = vector.add
  13. if n(pos).name ~= "air" and
  14. (n(v(pos, {x=1, y=0, z=0})).name == "air" and
  15. n(v(pos, {x=-1, y=0, z=0})).name == "air") or
  16. (n(v(pos, {x=0, y=0, z=1})).name == "air" and
  17. n(v(pos, {x=0, y=0, z=-1})).name == "air") then
  18. minetest.set_node(pos, {name="air"})
  19. end
  20. -- Another smoothing type.
  21. local n = minetest.get_node
  22. local v = vector.add
  23. if n(pos).name == "air" then
  24. local c = 0
  25. if n(v(pos, {x=1, y=0, z=0})).name ~= "air" then c=c+1 end
  26. if n(v(pos, {x=-1, y=0, z=0})).name ~= "air" then c=c+1 end
  27. if n(v(pos, {x=0, y=0, z=1})).name ~= "air" then c=c+1 end
  28. if n(v(pos, {x=0, y=0, z=-1})).name ~= "air" then c=c+1 end
  29. if c >= 3 then
  30. minetest.set_node(pos, {name="rackstone:cobble"})
  31. end
  32. end
  33. -- Change surface node type.
  34. if minetest.get_node(pos).name ~= "air" and
  35. minetest.get_node(vector.add(pos, {x=0, y=1, z=0})).name == "air" then
  36. minetest.set_node(pos, {name="rackstone:cobble"})
  37. end
  38. -- Place schematic.
  39. --[[
  40. //brush cubeapply 1 luatransform minetest.place_schematic(vector.add(pos, {x=-1, y=-2, z=-1}), minetest.get_worldpath() .. "/schems/pit.mts", "random", nil, true)
  41. --]]