From 7f3e7098184c3bfb6806938a0b9f353830366e95 Mon Sep 17 00:00:00 2001 From: Kimapr Date: Wed, 25 Dec 2019 22:41:17 +0500 Subject: [PATCH] half the island range, add island border view --- nc_sky_isgen/init.lua | 61 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/nc_sky_isgen/init.lua b/nc_sky_isgen/init.lua index d555bf7..dff0546 100644 --- a/nc_sky_isgen/init.lua +++ b/nc_sky_isgen/init.lua @@ -158,8 +158,65 @@ end local air_c = minetest.get_content_id("air") local ignore_c = minetest.get_content_id("ignore") +local function spawn_particle(x,y,z,player) + minetest.add_particlespawner{ + amount = 30, + -- Number of particles spawned over the time period `time`. + + time = 60, + + minpos = {x=x, y=y, z=z}, + maxpos = {x=x, y=y, z=z}, + minvel = {x=-0.5, y=-0.5, z=-0.5}, + maxvel = {x=0.5, y=0.5, z=0.5}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 2, + maxexptime = 3, + minsize = 5, + maxsize = 10, + vertical = false, + texture = "nc_lux_gravel.png", + playername = player, + + glow = 14 + } +end local function island_range(x,y,z) - return {x=x-64,y=y-64,z=z-64},{x=x+64,y=y+64,z=z+64} + return {x=x-32,y=y-32,z=z-32},{x=x+32,y=y+32,z=z+32} +end +local function spawn_particles(x,y,z,player) + local mi,ma = island_range(x,y,z) + local visited = {} + for n1=0,1 do + for n2=0,1 do + for _,ord1 in ipairs({"x","y","z"}) do + for _,ord2 in ipairs({"x","y","z"}) do + for _,ord3 in ipairs({"x","y","z"}) do + if ord2 ~= ord1 and ord3 ~= ord2 and ord3 ~= ord1 then + for x=mi[ord1],ma[ord1] do + local pos = {[ord1]=x} + if n1 == 0 then + pos[ord2] = mi[ord2] + else + pos[ord2] = ma[ord2] + end + if n2 == 0 then + pos[ord3] = mi[ord3] + else + pos[ord3] = ma[ord3] + end + --print(dump(pos)) + if math.random(10)==1 then + spawn_particle(pos.x,pos.y,pos.z,player) + end + end + end + end + end + end + end + end end local function checkpos(x,y,z) local vm = VoxelManip(island_range(x,y,z)) @@ -427,6 +484,8 @@ minetest.register_chatcommand("query", { minetest.chat_send_player(name," takeable: "..tostring(is.valid)) minetest.chat_send_player(name," pos: "..minetest.pos_to_string(is.pos)) minetest.chat_send_player(name,"]") + local p = is.pos + spawn_particles(p.x,p.y,p.z,name) else minetest.chat_send_player(name,S"No island here") end