[Solved] making orbs with voxel fails?

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

[Solved] making orbs with voxel fails?

by AiTechEye » Sat Jan 14, 2017 15:18

Im trying to make holes or orbs with voxel, because it seems to use significantly less cpu.

im checked how the tnt mod works, but are confused that the positions of the changed data always places or parts on wrong/randomly positions.

this does not happen if im using set_node

what is wrong?

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_tool("tools:rad", {
   description = "rad",
   inventory_image = "default_stick.png",
   groups={not_in_creative_inventory = 0,},
      on_use = function(itemstack, user, pointed_thing)

   local radius=5

   local pos = user:getpos()
   local pos1 = vector.subtract(pos, radius)
   local pos2 = vector.add(pos, radius)

   local vox = VoxelManip()
   local min, max = vox:read_from_map(pos1, pos2)
   local area = VoxelArea:new({MinEdge = min, MaxEdge = max})
   local data = vox:get_data()

   local air=minetest.get_content_id("air")
   local dirt=minetest.get_content_id("default:dirt")
   for z = -radius, radius do
   for y = -radius, radius do
   for x = -radius, radius do

      local rad = vector.length(vector.new(x,y,z))
      --local p={x=pos.x+x,y=pos.y+y,z=pos.z+z}
      --local node=minetest.get_node(p)
      local v = area:index(pos.x+x,pos.y+y,pos.z+z)

      if radius/rad>=1 and data[v]==air then
         --minetest.set_node(p,{name="air"})
         data[v]=dirt
      end

   end
   end
   end

   vox:set_data(data)
   vox:write_to_map()
   vox:update_map()
   vox:update_liquids()
end
})



Image
Attachments
screenshot_20170114_155942.png
screenshot_20170114_155942.png (368.43 KiB) Viewed 838 times
Last edited by AiTechEye on Sat Jan 21, 2017 09:04, edited 1 time in total.
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

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

Re: making orbs with voxel?

by paramat » Sat Jan 14, 2017 21:05

See https://github.com/paramat/catacomb/blob/master/init.lua#L212
Your line
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 vox = VoxelManip()

looks wrong.
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: making orbs with voxel?

by AiTechEye » Sun Jan 15, 2017 08:40

maybe, but it does same
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: making orbs with voxel?

by AiTechEye » Sat Jan 21, 2017 09:04

got it, the position have to be rounded.
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

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

Re: [Solved] making orbs with voxel fails?

by paramat » Mon Jan 23, 2017 03:09

Probably needs integers when calculating the index.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests