add a way to make sand

This commit is contained in:
Kimapr 2020-01-07 15:40:12 +05:00
parent bef0202358
commit a1a02508f5
3 changed files with 98 additions and 14 deletions

83
nc_sandmaking/init.lua Normal file
View File

@ -0,0 +1,83 @@
-- LUALOCALS >
local nodecore,minetest =
nodecore,minetest
-- LUALOCALS <
local modname = minetest.get_current_modname()
minetest.register_node(modname..":dirty_gravel",{
description = "Dirty Gravel",
tiles = {"nc_terrain_gravel.png^(nc_terrain_dirt.png^[opacity:127)"},
groups = {
crumbly = 1,
sandmaker = 1
},
alternate_loose = {
groups = {
crumbly = 2,
falling_repose = 2
}
},
sounds = nodecore.sounds("nc_terrain_swishy")
})
nodecore.register_craft{
label = "cook sand from dirty gravel",
action = "cook",
touchgroups = {flame=3},
duration = 30,
cookfx = true,
nodes = {
{
match = {groups={sandmaker=1}},
replace = "nc_terrain:sand"
}
}
}
nodecore.register_cook_abm({nodenames={"group:sandmaker"},neighbours={"group:flame"}})
nodecore.register_craft{
label = "mix dirty gravel (fail)",
action = "pummel",
toolgroups = {thumpy = 2},
normal = {y=1},
priority = 2,
nodes = {
{
match = {groups={dirt=true}},
replace = "air"
},
{
y=-1,
x=1,
match = {buildable_to=true},
replace = "nc_terrain:gravel"
},
{
y=-1,
match = {groups={gravel=true}},
replace = "nc_terrain:dirt"
}
}
}
nodecore.register_craft{
label = "mix dirty gravel",
action = "pummel",
toolgroups = {thumpy = 2},
normal = {y=1},
priority = 1,
nodes = {
{
match = {groups={dirt=true}},
replace = "air"
},
{
y=-1,
match = {groups={gravel=true}},
replace = modname..":dirty_gravel"
}
}
}

2
nc_sandmaking/mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = nc_sandmaking
depends = nc_terrain, nc_fire, nc_api, nc_api_craft

View File

@ -29,12 +29,12 @@ local function cosify(x)
return 1-math.cos(x*math.pi/2) return 1-math.cos(x*math.pi/2)
end end
local pers = 0.9 local pers = 0.75
local oct = 4 local oct = 5
local noise = PerlinNoise{ local noise = PerlinNoise{
scale = maxval(oct,pers,128), scale = maxval(oct,pers,64),
spread = {x=128,y=128,z=128}, spread = {x=128,y=64,z=128},
seed=1297, seed=1297,
octaves = oct, octaves = oct,
persistence = pers, persistence = pers,
@ -58,15 +58,15 @@ local function island(pos,r,call)
local function geto(x1,y1,z1,n) local function geto(x1,y1,z1,n)
local r1 = 48+n local r1 = 48+n
local dista = dist(0,0,0,x1,y1*3,z1) local dista = dist(0,0,0,x1,y1*3,z1)
local m = math.max(0,1-dista/r1) local m = 1-dista/r1
local r2 = -(sigmoid((48+n/2)/48*3)*56) local r2 = -(sigmoid((48+n/2)/48*3)*56)
if y1 <= 0 and y1 >= r2 then if y1 <= 0 and y1 >= r2 then
local r3 = (1-math.sin(y1/r2*math.pi/2))*r1 local r3 = (1-math.sin(y1/r2*math.pi/2))*r1
local distb = dist(0,y1,0,x1,y1,z1) local distb = dist(0,y1,0,x1,y1,z1)
local m2 = math.max(0,1-distb/r3) local m2 = 1-distb/r3
m = math.max(m2,m) m = math.max(m2,m)
end end
return cosify(m) return m
end end
local grasses = {} local grasses = {}
local stones = {} local stones = {}
@ -350,8 +350,8 @@ local function gen_island_pos(name,fgen)
checkpos(x,y,z,ch) checkpos(x,y,z,ch)
else else
local ip = {x=x,y=y,z=z} local ip = {x=x,y=y,z=z}
checkpos(x,y,z,function(ok) --checkpos(x,y,z,function(ok)
assert(ok,"super-duper-error") -- assert(ok,"super-duper-error")
if not fgen then if not fgen then
spawn_island(name,ip) spawn_island(name,ip)
else else
@ -375,7 +375,7 @@ local function gen_island_pos(name,fgen)
table.insert(cells,pl) table.insert(cells,pl)
end end
save() save()
end) --end)
end end
end end
checkpos(x,y,z,ch) checkpos(x,y,z,ch)
@ -398,7 +398,7 @@ minetest.register_globalstep(function(dt)
for k,ref in pairs(minetest.get_connected_players()) do for k,ref in pairs(minetest.get_connected_players()) do
local is = get_standing_island(ref:get_player_name()) local is = get_standing_island(ref:get_player_name())
if is and not minetest.check_player_privs(ref,{server = true}) then if is and not minetest.check_player_privs(ref,{server = true}) then
is.valid = false is.t[is.k].valid = false
end end
local p = ref:get_pos() local p = ref:get_pos()
if p.y < -128 then if p.y < -128 then
@ -544,7 +544,7 @@ minetest.register_chatcommand("query", {
description = S"Query information about this island", description = S"Query information about this island",
func = function(name,param) func = function(name,param)
local is local is
if param then if param ~= "" then
is = players[param] is = players[param]
if not is then if not is then
minetest.chat_send_player(name,S("Can't find @1's island",param)) minetest.chat_send_player(name,S("Can't find @1's island",param))
@ -601,9 +601,8 @@ minetest.register_chatcommand("islandgen",{
}) })
minetest.register_on_joinplayer(function(ref) minetest.register_on_joinplayer(function(ref)
local meta = ref:get_meta()
local name = ref:get_player_name() local name = ref:get_player_name()
if not players[name] then if not players[name] and minetest.check_player_privs(ref,{interact=true}) then
gen_island_pos(name) gen_island_pos(name)
end end
end) end)