forked from Kimapr/nodecore-skyblock
Add sponge spores
This commit is contained in:
parent
17bef30b02
commit
32a859db6a
|
@ -23,13 +23,4 @@ nodecore.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
nodecore.register_craft({
|
|
||||||
label = "squash water from leaves",
|
|
||||||
action = "pummel",
|
|
||||||
nodes = {
|
|
||||||
{match = "nc_tree:leaves_loose", replace = "nc_terrain:water_source"}
|
|
||||||
},
|
|
||||||
toolgroups = {thumpy = 2}
|
|
||||||
})
|
|
||||||
|
|
||||||
nodecore.register_cook_abm({nodenames = {"nc_terrain:cobble"}, neighbors = {"group:flame"}})
|
nodecore.register_cook_abm({nodenames = {"nc_terrain:cobble"}, neighbors = {"group:flame"}})
|
|
@ -42,7 +42,7 @@ local noise = PerlinNoise{
|
||||||
flags = "eased"
|
flags = "eased"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function island(pos,r)
|
local function island(pos,r,call)
|
||||||
local x,y,z = pos.x,pos.y,pos.z
|
local x,y,z = pos.x,pos.y,pos.z
|
||||||
minetest.emerge_area({x=x-r,y=y-r,z=z-r},{x=x+r,y=y+r,z=z+r},function(bp,act,crem)
|
minetest.emerge_area({x=x-r,y=y-r,z=z-r},{x=x+r,y=y+r,z=z+r},function(bp,act,crem)
|
||||||
if crem > 0 then
|
if crem > 0 then
|
||||||
|
@ -118,12 +118,15 @@ local function island(pos,r)
|
||||||
meta:set_float("growth",5000)
|
meta:set_float("growth",5000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if call then
|
||||||
|
call()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local f,abs = math.floor, math.abs
|
local f,abs = math.floor, math.abs
|
||||||
local function raw_spawn_island(pos)
|
local function raw_spawn_island(pos,call)
|
||||||
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
|
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
|
||||||
island(pos,48,name)
|
island(pos,48,call)
|
||||||
end
|
end
|
||||||
local function spawn_island(name,pos)
|
local function spawn_island(name,pos)
|
||||||
local ref = minetest.get_player_by_name(name)
|
local ref = minetest.get_player_by_name(name)
|
||||||
|
@ -188,6 +191,9 @@ end
|
||||||
local function island_range(x,y,z)
|
local function island_range(x,y,z)
|
||||||
return {x=x-32,y=y-32,z=z-32},{x=x+32,y=y+32,z=z+32}
|
return {x=x-32,y=y-32,z=z-32},{x=x+32,y=y+32,z=z+32}
|
||||||
end
|
end
|
||||||
|
local function islandgen_range(x,y,z)
|
||||||
|
return {x=x-64,y=y-64,z=z-64},{x=x+64,y=y+64,z=z+64}
|
||||||
|
end
|
||||||
local function spawn_particles(x,y,z,player)
|
local function spawn_particles(x,y,z,player)
|
||||||
local mi,ma = island_range(x,y,z)
|
local mi,ma = island_range(x,y,z)
|
||||||
local visited = {}
|
local visited = {}
|
||||||
|
@ -221,22 +227,29 @@ local function spawn_particles(x,y,z,player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function checkpos(x,y,z)
|
local function checkpos(x,y,z,ch)
|
||||||
local vm = VoxelManip(island_range(x,y,z))
|
local mi,ma = islandgen_range(x,y,z)
|
||||||
local emi,ema = vm:get_emerged_area()
|
minetest.emerge_area(mi,ma,function(bpos,act,crem)
|
||||||
local dat = vm:get_data()
|
if crem > 0 then
|
||||||
local ar = VoxelArea:new{MinEdge=emi,MaxEdge=ema}
|
return
|
||||||
for x = x-32,x+32 do
|
end
|
||||||
for y = y-32,y+32 do
|
local vm = VoxelManip(mi,ma)
|
||||||
for z = z-32,z+32 do
|
local emi,ema = vm:get_emerged_area()
|
||||||
local d = dat[ar:index(x,y,z)]
|
local dat = vm:get_data()
|
||||||
if d ~= air_c and d ~= ignore_c then
|
local ar = VoxelArea:new{MinEdge=emi,MaxEdge=ema}
|
||||||
return false
|
for x = mi.x,ma.x do
|
||||||
|
for y = mi.y,ma.y do
|
||||||
|
for z = mi.y,ma.z do
|
||||||
|
local d = dat[ar:index(x,y,z)]
|
||||||
|
if d ~= air_c and d ~= ignore_c then
|
||||||
|
ch(false)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
ch(true)
|
||||||
return true
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,28 +301,31 @@ local function get_standing_island(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function gen_island_pos(name,fgen)
|
local function gen_island_pos(name,fgen)
|
||||||
for n=1,fgen or 1 do
|
local ended = 0
|
||||||
minetest.after((n-1)*30,function()
|
local function gen(n)
|
||||||
local x,y,z = 0,0,0
|
if n > (fgen or 1) then
|
||||||
x,z = x+math.random(-96,96),z+math.random(-96,96)
|
return
|
||||||
y=256+math.random(-32,32)
|
end
|
||||||
if not fgen then
|
local x,y,z = 0,0,0
|
||||||
for k,isl in pairs(cells) do
|
x,z = x+math.random(-96,96),z+math.random(-96,96)
|
||||||
if isl and isl.valid then
|
y=256+math.random(-32,32)
|
||||||
table.remove(cells,k)
|
if not fgen then
|
||||||
local ip = isl.pos
|
for k,isl in pairs(cells) do
|
||||||
local ref = minetest.get_player_by_name(name)
|
if isl and isl.valid then
|
||||||
local pos = ip
|
table.remove(cells,k)
|
||||||
players[name] = {pos = pos, valid = true}
|
local ip = isl.pos
|
||||||
save()
|
local ref = minetest.get_player_by_name(name)
|
||||||
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
|
local pos = ip
|
||||||
ref:set_pos({x=pos.x,y=pos.y+256,z=pos.z})
|
players[name] = {pos = pos, valid = true}
|
||||||
return
|
save()
|
||||||
end
|
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
|
||||||
|
ref:set_pos({x=pos.x,y=pos.y+256,z=pos.z})
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local ok = checkpos(x,y,z)
|
end
|
||||||
while not ok do
|
local function ch(ok)
|
||||||
|
if not ok then
|
||||||
local sx,sz = math.random(-96,96),math.random(-96,96)
|
local sx,sz = math.random(-96,96),math.random(-96,96)
|
||||||
if ((x+sx)^2+(z+sz)^2)^0.5 < (x^2+z^2)^0.5 then
|
if ((x+sx)^2+(z+sz)^2)^0.5 < (x^2+z^2)^0.5 then
|
||||||
sx=-sx
|
sx=-sx
|
||||||
|
@ -317,26 +333,37 @@ local function gen_island_pos(name,fgen)
|
||||||
end
|
end
|
||||||
x,z = x+sx,z+sz
|
x,z = x+sx,z+sz
|
||||||
y=256+math.random(-32,32)
|
y=256+math.random(-32,32)
|
||||||
ok = checkpos(x,y,z)
|
ok = checkpos(x,y,z,ch)
|
||||||
end
|
|
||||||
local ip = {x=x,y=y,z=z}
|
|
||||||
if not fgen then
|
|
||||||
spawn_island(name,ip)
|
|
||||||
else
|
else
|
||||||
raw_spawn_island(ip)
|
local ip = {x=x,y=y,z=z}
|
||||||
|
if not fgen then
|
||||||
|
spawn_island(name,ip)
|
||||||
|
else
|
||||||
|
raw_spawn_island(ip,function()
|
||||||
|
ended = ended + 1
|
||||||
|
if ended >= (fgen or 1) then
|
||||||
|
minetest.chat_send_player(name,S"Island generation done")
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name,S("Generated an island (@1%)"), math.floor(ended/(fgen or 1)*1000)/10)
|
||||||
|
end
|
||||||
|
minetest.after(0,gen,n+1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
local pl = {
|
||||||
|
pos = ip,
|
||||||
|
valid = true
|
||||||
|
}
|
||||||
|
if not fgen then
|
||||||
|
players[name] = pl
|
||||||
|
else
|
||||||
|
table.insert(cells,pl)
|
||||||
|
end
|
||||||
|
save()
|
||||||
end
|
end
|
||||||
local pl = {
|
end
|
||||||
pos = ip,
|
checkpos(x,y,z,ch)
|
||||||
valid = true
|
|
||||||
}
|
|
||||||
if not fgen then
|
|
||||||
players[name] = pl
|
|
||||||
else
|
|
||||||
table.insert(cells,pl)
|
|
||||||
end
|
|
||||||
save()
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
minetest.after(0,gen,1)
|
||||||
end
|
end
|
||||||
local updrate = 0.5
|
local updrate = 0.5
|
||||||
local to_upd = updrate
|
local to_upd = updrate
|
||||||
|
|
|
@ -13,3 +13,6 @@ Reassign this island=Reassign this island
|
||||||
Unregister island=Unregister island
|
Unregister island=Unregister island
|
||||||
Register island=Register island
|
Register island=Register island
|
||||||
Get a new island=Get a new island
|
Get a new island=Get a new island
|
||||||
|
Bulk island generation=Bulk island generation
|
||||||
|
Island generation done=Island generation done
|
||||||
|
Generated an island (@1%)=Generated an island (@1%)
|
||||||
|
|
|
@ -13,3 +13,6 @@ Reassign this island=Переназначить этот остров
|
||||||
Unregister island=Разрегистрировать остров
|
Unregister island=Разрегистрировать остров
|
||||||
Register island=Зарегистрировать остров
|
Register island=Зарегистрировать остров
|
||||||
Get a new island=Получить новый остров
|
Get a new island=Получить новый остров
|
||||||
|
Bulk island generation=Массовая генерация островов
|
||||||
|
Island generation done=Генерация островов завершена
|
||||||
|
Generated an island (@1%)=Сгенерирован остров (@1%)
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
-- LUALOCALS < ---------------------------------------------------------
|
||||||
|
local minetest, nodecore, pairs, vector
|
||||||
|
= minetest, nodecore, pairs, vector
|
||||||
|
-- LUALOCALS > ---------------------------------------------------------
|
||||||
|
|
||||||
|
local modname = minetest.get_current_modname()
|
||||||
|
local S = minetest.get_translator(modname)
|
||||||
|
|
||||||
|
local alldirs = nodecore.dirs()
|
||||||
|
|
||||||
|
local sproutgroups = {
|
||||||
|
green = 1,
|
||||||
|
sand = 1,
|
||||||
|
moist = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local living = modname .. ":spore"
|
||||||
|
|
||||||
|
minetest.register_node(living, {
|
||||||
|
description = S"Sponge Spore",
|
||||||
|
tiles = {"nc_tree_humus.png^(nc_sponge.png^[opacity:64)^nc_tree_peat.png"},
|
||||||
|
groups = {
|
||||||
|
crumbly = 2,
|
||||||
|
moist = 1,
|
||||||
|
},
|
||||||
|
sounds = nodecore.sounds("nc_terrain_swishy")
|
||||||
|
})
|
||||||
|
|
||||||
|
nodecore.register_craft({
|
||||||
|
label = "make sponge spore",
|
||||||
|
action = "pummel",
|
||||||
|
toolgroups = {thumpy = 2},
|
||||||
|
nodes = {
|
||||||
|
{
|
||||||
|
match = {name = "nc_tree:peat", count = 8},
|
||||||
|
replace = living
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
nodecore.register_limited_abm({
|
||||||
|
label = "Sponge Spore Sprouting",
|
||||||
|
interval = 1,
|
||||||
|
chance = 40,
|
||||||
|
limited_max = 1000,
|
||||||
|
nodenames = {living},
|
||||||
|
action = function(pos, node)
|
||||||
|
local vdirs = {}
|
||||||
|
local opos = pos
|
||||||
|
for _,dir in pairs(alldirs) do
|
||||||
|
local pos = vector.add(pos,dir)
|
||||||
|
local groups = {}
|
||||||
|
for k,v in pairs(sproutgroups) do
|
||||||
|
groups[k]=0
|
||||||
|
end
|
||||||
|
for _,dir in pairs(alldirs) do
|
||||||
|
local pos = vector.add(pos,dir)
|
||||||
|
if not vector.equals(pos,opos) then
|
||||||
|
local name = minetest.get_node(pos).name
|
||||||
|
for k,v in pairs(sproutgroups) do
|
||||||
|
groups[k] = groups[k] + minetest.get_item_group(name,k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local valid = true
|
||||||
|
for k,v in pairs(groups) do
|
||||||
|
if v < sproutgroups[k] then
|
||||||
|
valid = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if valid and minetest.get_item_group(minetest.get_node(pos).name,"sand") > 0 then
|
||||||
|
table.insert(vdirs,dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #vdirs > 0 then
|
||||||
|
local dir = vdirs[math.random(1,#vdirs)]
|
||||||
|
local pos = vector.add(pos,dir)
|
||||||
|
minetest.set_node(pos,{name="nc_sponge:sponge_living"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
|
@ -0,0 +1,2 @@
|
||||||
|
# textdomain: nc_sponge_spores
|
||||||
|
Sponge Spore=Sponge Spore
|
|
@ -0,0 +1,2 @@
|
||||||
|
# textdomain: nc_sponge_spores
|
||||||
|
Sponge Spore=Спора Губки
|
|
@ -0,0 +1,2 @@
|
||||||
|
name = nc_sponge_spores
|
||||||
|
depends = nc_api, nc_api_craft, nc_sponge, nc_tree
|
Loading…
Reference in New Issue