Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
"air","default:water_source"
"air"
Chiu ChunLing wrote:Well, I want to have the mechanics down before I mess with making it do the generation. Also, I'm pretty new to this, so I have no experience with making a map generator. Could you be more specific about the nature of the problems you're seeing? I know that all the falling produces a lot of dropped items in places where there is lots of sand or whatever, I've been running around on some islands and things go pretty crazy.
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
minetest.register_on_generated(function(minp, maxp)--function that affects generated mapblockchunks
if maxp.y < 2 or minp.y > 256 then return end
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")--we get the voxelmanip objects
local data = vm:get_data()-- array of raw node data (node content ids) read from the vm object
local vxa = VoxelArea:new{MinEdge=emin, MaxEdge=emax} --
local heightmap,hndx = minetest.get_mapgen_object("heightmap"),1--heightmap and index
local erdng_ids,slope_ids,air_id,torch_id = {},{},minetest.get_content_id("air"),minetest.get_content_id("default:torch")
for k,v in pairs(eroding_nodes) do erdng_ids[minetest.get_content_id("default:"..k)] = k end
for k,v in pairs(erosion_materials) do
for s,_ in pairs(slopes) do slope_ids[k..s] = minetest.get_content_id("erosion:slope_"..k..s) end
end
for z=minp.z,maxp.z do--traverse z coordinates
for x=minp.x,maxp.x do--traverse x coordinates
local vpos = vxa:index(x,heightmap[hndx], z)--get the index for the surface node at this x and z
if erdng_ids[data[vpos]] and data[vpos+vxa.ystride] == air_id then--the id was loaded in erdng_ids and the node above is air
data[vpos+vxa.ystride] = torch_id--set that air block to be a torch
end
hndx = hndx+1--continue traversing the heightmap
end
end
vm:set_data(data)--set altered data to the vm
vm:calc_lighting()--recalculate lighting
vm:write_to_map(data) --save altered data in vm
end)
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
minetest.register_on_generated(function(minp, maxp)--function that affects generated mapblockchunks
if minp.y > 256 then return end
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local data,prm2 = vm:get_data(),vm:get_param2_data()
local vxa = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local erdng_ids,slope_ids,dpstn,cube3,box,vpos = {},{},{},{},{}
for k,v in pairs(slopes) do dpstn[k] = minetest.get_content_id("moreblocks:slope_stone"..k) end
dpstn.stone,dpstn.air = minetest.get_content_id("default:stone"),minetest.get_content_id("air")
for x=-1,1 do cube3[x]={} for y=-1,1 do cube3[x][y]={}
for z=-1,1 do cube3[x][y][z]=x+y*vxa.ystride+z*vxa.zstride end
end end
for k,v in pairs(eroding_nodes) do erdng_ids[minetest.get_content_id("default:"..k)] = v[2] end
for k,v in pairs(erosion_materials) do
for s,_ in pairs(slopes) do slope_ids[k..s] = minetest.get_content_id("erosion:slope_"..k..s) end
end
for vpos=vxa:index(minp.x,minp.y,minp.z),vxa:index(maxp.x,maxp.y,maxp.z) do
if data[vpos] == dpstn.air then
box.w = data[vpos+cube3[-1][0][0]] == dpstn.stone
box.e = data[vpos+cube3[1][0][0]] == dpstn.stone
box.d = data[vpos+cube3[0][-1][0]] == dpstn.stone
box.u = data[vpos+cube3[0][1][0]] == dpstn.stone
box.s = data[vpos+cube3[0][0][-1]] == dpstn.stone
box.n = data[vpos+cube3[0][0][1]] == dpstn.stone
box.t = (box.w and 1 or 0)+(box.e and 1 or 0)+(box.d and 1 or 0)+(box.u and 1 or 0)+(box.s and 1 or 0)+(box.n and 1 or 0)
if box.t == 2 then
box.f = box.d and box.n and 0
or box.d and box.e and 1
or box.d and box.s and 2
or box.d and box.w and 3
or box.u and box.n and 20
or box.u and box.w and 21
or box.u and box.s and 22
or box.u and box.e and 23
or box.w and box.s and 7
or box.e and box.n and 9
or box.w and box.n and 12
or box.e and box.s and 18
or -1
if -1<box.f then data[vpos],prm2[vpos] = dpstn[""],box.f end
elseif box.t == 3 then
box.f = box.d and box.n and box.w and 0
or box.d and box.e and box.n and 1
or box.d and box.s and box.e and 2
or box.d and box.w and box.s and 3
or box.u and box.n and box.e and 20
or box.u and box.w and box.n and 21
or box.u and box.s and box.w and 22
or box.u and box.e and box.s and 23
or -1
if -1<box.f then data[vpos],prm2[vpos] = dpstn._inner_cut,box.f
if box.u and data[vpos+cube3[0][-1][0]] == dpstn.air then
data[vpos+cube3[0][-1][0]],prm2[vpos+cube3[0][-1][0]] = dpstn._outer_cut,box.f
end
end
end
end
end
vm:set_data(data)--set altered data to the vm
vm:set_param2_data(prm2)--set altered param2 data
vm:calc_lighting()--recalculate lighting
vm:write_to_map(data) --save altered data in vm
end)
Users browsing this forum: No registered users and 49 guests