Guest User

Untitled

a guest
Apr 25th, 2013
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function DOM_copia_construcao(nome, ponto1,ponto2,blocos)
  2. local mapa={}
  3.  
  4. local p1={x=ponto1.x,y=ponto1.y,z=ponto1.z}
  5. local p2={x=ponto2.x,y=ponto2.y,z=ponto2.z}
  6. local pi={x=p1.x,y=p1.y,z=p1.z}
  7.  
  8. local arq = minetest.get_modpath("domb") .."/maps/"..nome.."-constr-sav.txt"
  9.  
  10. -- Caso o ponto 2 tenha menores valores em x, y ou z os valores serão trocados.
  11. if p1.x > p2.x then
  12. pi.x = p2.x
  13. end
  14. if p1.y > p2.y then
  15. pi.y = p2.y
  16. end
  17. if p1.z > p2.z then
  18. pi.z = p2.z
  19. end
  20.  
  21. local x=0
  22. local y=0
  23. local z=0
  24. local posicao =1
  25. local vx=1
  26. local vy=1
  27. local vz=1
  28.  
  29. if p1.x > p2.x then vx=-1 end
  30. if p1.y > p2.y then vy=-1 end
  31. if p1.z > p2.z then vz=-1 end
  32.  
  33. for x=p1.x,p2.x,vx do
  34. for y=p1.y,p2.y,vy do
  35. for z=p1.z,p2.z,vz do
  36. local o = (minetest.env:get_node({x=x, y=y, z=z}))
  37. local meta = minetest.env:get_meta({x=x, y=y, z=z})
  38. if meta ~= nil then
  39. DOM_inspeciona("Meta lido:",meta:to_table())
  40. end
  41.  
  42. m = DOM_meta_para_tabela(meta)
  43. if o.name ~= "ignore" and o.name ~= "air" then
  44. mapa[posicao] = {}
  45. mapa[posicao].x = x-pi.x
  46. mapa[posicao].y = y-pi.y
  47. mapa[posicao].z = z-pi.z
  48. mapa[posicao].o = o
  49. mapa[posicao].m = m
  50. posicao = posicao + 1
  51. -- DOM_inspeciona_r("Ponto:"..tostring(x)..","..tostring(y)..","..tostring(z),o.name)
  52. end
  53. end
  54. end
  55. end
  56.  
  57.  
  58. --Write the file, if is possible.
  59. a, error = io.open(arq, "w")
  60. if error then return error end
  61. a:write(minetest.serialize(mapa))
  62. -- a:write(dump(mapa))
  63. a:close()
  64.  
  65. -- a, error = io.open(arq.."3", "w")
  66. -- if error then return error end
  67. -- d=tostring(mapa)
  68.  
  69. -- a:write(d)
  70. -- a:write(dom_m.serialize(mapa))
  71. -- a:close()
  72. domb_mapa = mapa
  73.  
  74. return pi
  75. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×