How can I calculate the VoxelManip index from absolute pos?

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

How can I calculate the VoxelManip index from absolute pos?

by burli » Thu Feb 16, 2017 08:14

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
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Thu Feb 16, 2017 11:38

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)
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

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

by burli » Thu Feb 16, 2017 13:50

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")
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

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

by paramat » Fri Feb 17, 2017 19:21

Deleted post.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 63 guests

cron