Page 1 of 1

How can I calculate the VoxelManip index from absolute pos?

PostPosted: Thu Feb 16, 2017 08:14
by burli
I want to get the vm index from an absolute coordinate like

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
{
   y = 127,
   x = -2593,
   z = 3567
}


This doesn't work

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
      local vi = a:index(pos.x, pos.y, pos.z)
      data[vi] = c_air

Re: How can I calculate the VoxelManip index from absolute p

PostPosted: Thu Feb 16, 2017 11:38
by burli
Or how can I get this to work? I'm confused why it doesn't work

Nodes is a list of positions
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_generated(function(minp, maxp)
   local vm1 = VoxelManip()
   local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
   local data = vm1:get_data()
   local c_air = minetest.get_content_id("air")
   local c_glass = minetest.get_content_id("default:glass")

   for _, pos in pairs(nodes) do
      local vi = a:indexp(pos)
      data[vi] = c_glass
   end

   vm1:set_data(data)
   vm1:write_to_map()
end)

Re: How can I calculate the VoxelManip index from absolute p

PostPosted: Thu Feb 16, 2017 13:50
by burli
I got it. It only works with

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
   local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")

Re: How can I calculate the VoxelManip index from absolute p

PostPosted: Fri Feb 17, 2017 19:21
by paramat
Deleted post.