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"}})
|
|
@ -42,7 +42,7 @@ local noise = PerlinNoise{
|
|||
flags = "eased"
|
||||
}
|
||||
|
||||
local function island(pos,r)
|
||||
local function island(pos,r,call)
|
||||
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)
|
||||
if crem > 0 then
|
||||
|
@ -118,12 +118,15 @@ local function island(pos,r)
|
|||
meta:set_float("growth",5000)
|
||||
end
|
||||
end
|
||||
if call then
|
||||
call()
|
||||
end
|
||||
end)
|
||||
end
|
||||
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)}
|
||||
island(pos,48,name)
|
||||
island(pos,48,call)
|
||||
end
|
||||
local function spawn_island(name,pos)
|
||||
local ref = minetest.get_player_by_name(name)
|
||||
|
@ -188,6 +191,9 @@ end
|
|||
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}
|
||||
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 mi,ma = island_range(x,y,z)
|
||||
local visited = {}
|
||||
|
@ -221,22 +227,29 @@ local function spawn_particles(x,y,z,player)
|
|||
end
|
||||
end
|
||||
end
|
||||
local function checkpos(x,y,z)
|
||||
local vm = VoxelManip(island_range(x,y,z))
|
||||
local emi,ema = vm:get_emerged_area()
|
||||
local dat = vm:get_data()
|
||||
local ar = VoxelArea:new{MinEdge=emi,MaxEdge=ema}
|
||||
for x = x-32,x+32 do
|
||||
for y = y-32,y+32 do
|
||||
for z = z-32,z+32 do
|
||||
local d = dat[ar:index(x,y,z)]
|
||||
if d ~= air_c and d ~= ignore_c then
|
||||
return false
|
||||
local function checkpos(x,y,z,ch)
|
||||
local mi,ma = islandgen_range(x,y,z)
|
||||
minetest.emerge_area(mi,ma,function(bpos,act,crem)
|
||||
if crem > 0 then
|
||||
return
|
||||
end
|
||||
local vm = VoxelManip(mi,ma)
|
||||
local emi,ema = vm:get_emerged_area()
|
||||
local dat = vm:get_data()
|
||||
local ar = VoxelArea:new{MinEdge=emi,MaxEdge=ema}
|
||||
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
|
||||
return true
|
||||
ch(true)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
@ -288,28 +301,31 @@ local function get_standing_island(name)
|
|||
end
|
||||
|
||||
local function gen_island_pos(name,fgen)
|
||||
for n=1,fgen or 1 do
|
||||
minetest.after((n-1)*30,function()
|
||||
local x,y,z = 0,0,0
|
||||
x,z = x+math.random(-96,96),z+math.random(-96,96)
|
||||
y=256+math.random(-32,32)
|
||||
if not fgen then
|
||||
for k,isl in pairs(cells) do
|
||||
if isl and isl.valid then
|
||||
table.remove(cells,k)
|
||||
local ip = isl.pos
|
||||
local ref = minetest.get_player_by_name(name)
|
||||
local pos = ip
|
||||
players[name] = {pos = pos, valid = true}
|
||||
save()
|
||||
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
|
||||
local ended = 0
|
||||
local function gen(n)
|
||||
if n > (fgen or 1) then
|
||||
return
|
||||
end
|
||||
local x,y,z = 0,0,0
|
||||
x,z = x+math.random(-96,96),z+math.random(-96,96)
|
||||
y=256+math.random(-32,32)
|
||||
if not fgen then
|
||||
for k,isl in pairs(cells) do
|
||||
if isl and isl.valid then
|
||||
table.remove(cells,k)
|
||||
local ip = isl.pos
|
||||
local ref = minetest.get_player_by_name(name)
|
||||
local pos = ip
|
||||
players[name] = {pos = pos, valid = true}
|
||||
save()
|
||||
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
|
||||
local ok = checkpos(x,y,z)
|
||||
while not ok do
|
||||
end
|
||||
local function ch(ok)
|
||||
if not ok then
|
||||
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
|
||||
sx=-sx
|
||||
|
@ -317,26 +333,37 @@ local function gen_island_pos(name,fgen)
|
|||
end
|
||||
x,z = x+sx,z+sz
|
||||
y=256+math.random(-32,32)
|
||||
ok = checkpos(x,y,z)
|
||||
end
|
||||
local ip = {x=x,y=y,z=z}
|
||||
if not fgen then
|
||||
spawn_island(name,ip)
|
||||
ok = checkpos(x,y,z,ch)
|
||||
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
|
||||
local pl = {
|
||||
pos = ip,
|
||||
valid = true
|
||||
}
|
||||
if not fgen then
|
||||
players[name] = pl
|
||||
else
|
||||
table.insert(cells,pl)
|
||||
end
|
||||
save()
|
||||
end)
|
||||
end
|
||||
checkpos(x,y,z,ch)
|
||||
end
|
||||
minetest.after(0,gen,1)
|
||||
end
|
||||
local updrate = 0.5
|
||||
local to_upd = updrate
|
||||
|
|
|
@ -13,3 +13,6 @@ Reassign this island=Reassign this island
|
|||
Unregister island=Unregister island
|
||||
Register island=Register 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=Разрегистрировать остров
|
||||
Register 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