Fix some bugs, add /reset cmd, change stone sieve recipe to be actually be stone and not wood with cobble surface

This commit is contained in:
Kimapr 2019-10-25 06:48:34 +05:00
parent ead3d3a7fc
commit 0ec00d9ac7
3 changed files with 180 additions and 73 deletions

View File

@ -10,10 +10,12 @@ local side = "nc_tree_tree_side.png"
local top = wmodname.. "_plank.png"
local top_sieve = wmodname .. "_plank.png^[mask:"..modname.."_sieve.png^nc_tree_leaves.png"
local stop = "nc_terrain_stone.png"
local sside = "nc_terrain_stone.png"
local stop_sieve = "nc_terrain_stone.png^[mask:"..modname.."_sieve.png^nc_terrain_cobble.png"
minetest.register_node(modname .. ":table", {
function regsieve(suff,top,side,top_sieve,groups)
minetest.register_node(modname .. ":table"..suff, {
description = "Wooden Table",
drawtype = "nodebox",
node_box = nodecore.fixedbox(
@ -26,16 +28,12 @@ minetest.register_node(modname .. ":table", {
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top, top, side },
groups = {
choppy = 1,
flammable = 2,
fire_fuel = 3,
},
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
minetest.register_node(modname .. ":table_broken", {
minetest.register_node(modname .. ":table_broken"..suff, {
description = "Broken Wooden Table",
drawtype = "nodebox",
node_box = nodecore.fixedbox(
@ -51,15 +49,11 @@ minetest.register_node(modname .. ":table_broken", {
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top, top, side },
groups = {
choppy = 1,
flammable = 2,
fire_fuel = 3,
},
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
minetest.register_node(modname .. ":sieve", {
minetest.register_node(modname .. ":sieve"..suff, {
description = "Wooden Sieve",
drawtype = "nodebox",
use_texture_alpha = true,
@ -77,38 +71,21 @@ minetest.register_node(modname .. ":sieve", {
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top_sieve, top_sieve, side },
groups = {
choppy = 1,
flammable = 2,
fire_fuel = 3,
},
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
minetest.register_node(modname .. ":sieve_stone", {
description = "Stone Sieve",
drawtype = "nodebox",
use_texture_alpha = true,
node_box = nodecore.fixedbox(
{-4/16,7/16,-4/16,4/16,0.5,4/16},
{-0.5, 7/16, -0.5, -0.5+4/16,0.5,0.5},
{0.5-4/16, 7/16, -0.5, 0.5, 0.5, 0.5},
{-8/32, 7/16, 8/32, 8/32, 0.5, 0.5},
{-8/32, 7/16, -0.5, 8/32, 0.5, -8/32},
{-0.5, -0.5, -0.5, -7/16, 7/16, -7/16},
{-0.5, -0.5, 7/16, -7/16, 7/16, 0.5},
{7/16, -0.5, -0.5, 0.5, 7/16, -7/16},
{7/16, -0.5, 7/16, 0.5, 7/16, 0.5}
),
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { stop_sieve, stop_sieve, sside },
groups = {
cracky = 2,
},
paramtype = "light",
sounds = nodecore.sounds("nc_terrain_stony"),
})
end
regsieve("",top,side,top_sieve,{
choppy = 1,
flammable = 2,
fire_fuel = 3,
})
regsieve("_stone",stop,sside,stop_sieve,{
cracky = 2,
})
minetest.register_craftitem(modname..":random_dust",{
description = "Dust of random minerals",
@ -124,6 +101,15 @@ nodecore.register_craft({
},
})
nodecore.register_craft({
label = "break a table",
action = "pummel",
toolgroups = {cracky = 2},
nodes = {
{match = modname .. ":table_stone", replace = modname .. ":table_broken_stone"}
},
})
local dio = {
items={{name = "nc_stonework:chip", count = 4, scatter = 2}}
}
@ -167,7 +153,7 @@ local dirtss = {
["nc_terrain:gravel_loose"] = duo2,
["nc_terrain:sand"] = duo3,
["nc_terrain:sand_loose"] = duo3,
["nc_tree:leaves_loose"] = {node = "nc_terrain:water_source"},
["nc_tree:leaves_loose"] = {node = "nc_terrain:hm_water_source"},
}
for k,v in pairs(dirts) do
@ -240,7 +226,7 @@ nodecore.register_craft({
label = "assemble stone sieve",
norotate = true,
nodes = {
{y = -1, match = modname .. ":table_broken", replace = modname .. ":sieve_stone"},
{y = -1, match = modname .. ":table_broken_stone", replace = modname .. ":sieve_stone"},
{match = "nc_terrain:cobble_loose", replace = "air"},
}
})
@ -268,3 +254,34 @@ nodecore.register_craft({
{x = 1, z = 0, match = wmodname .. ":staff", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble stone table",
action = "pummel",
toolgroups = {thumpy = 3},
priority = 1,
norotate = true,
nodes = {
{match = "nc_terrain:cobble_loose", replace = modname .. ":table_stone"},
{x = -1, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = -1, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble stone table",
action = "pummel",
toolgroups = {thumpy = 3},
priority = 1,
norotate = true,
nodes = {
{match = "nc_terrain:cobble_loose", replace = modname .. ":table_stone"},
{x = 0, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 0, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
{x = -1, z = 0, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = 0, match = "nc_lode:rod_annealed", replace = "air"},
}
})

View File

@ -1,17 +1,10 @@
--nothing--
local grass = "nc_terrain:dirt_with_grass"
local dirt = "nc_terrain:dirt"
local tree = "nc_tree:eggcorn_planted"
local stone = "nc_terrain:stone"
local queue = {}
minetest.register_globalstep(function(dt)
for f,_ in pairs(queue) do
if not coroutine.resume(f) then
queue[f]=nil
end
end
end)
local function maxval(octaves,persistence,scale)
local m = scale
local poc = scale
@ -25,15 +18,11 @@ local function maxval(octaves,persistence,scale)
end
local function island(pos,r)
minetest.after(2,function()--queue[coroutine.create(function()
local noise = PerlinNoise({
seed = math.random(10000),
octaves = 3,
spread = {x=r/2,y=r/2,z=r/2},
lacunarity = 2,
persistence = 0.5,
flags = "absvalue"
})
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
return
end
local n = 0
local c = 0
local cm = (r*2+1)^3
@ -43,17 +32,15 @@ local function island(pos,r)
local hdist = (x*x+z*z)^0.5
local uhdist = (math.max(0,r-hdist)/r)^((1-uvdist)^3*5)
local udist = math.max(0,r-dist)/r
if math.min(1,math.max(0,uhdist^2)) ~= uhdist^2 then
print(uhdist^2)
end
local m = ((math.max(r-(hdist),0)/r)^0.1*(uhdist^2))-uhdist*uvdist^3
return m
end
local grasses = {}
for x=-r,r do
for z=-r,r do
for y=-r,r do
local xx,yy,zz = pos.x+x,pos.y+y,pos.z+z
o,o2 = geto(x,y,z),geto(x,y+1,z)
local o,o2 = geto(x,y,z),geto(x,y+1,z)
local oc = (o > 0.4)
local oc2 = o2 > 0.4
local og = (o > 0.6)
@ -62,6 +49,7 @@ local function island(pos,r)
local nam = dirt
if not og and not oc2 then
nam = grass
table.insert(grasses,{x=xx,y=yy,z=zz})
end
if og then
nam = stone
@ -77,15 +65,21 @@ local function island(pos,r)
end
end
end
minetest.set_node({x=pos.x,y=pos.y+10,z=pos.z},{name="nc_tree:eggcorn_planted"})
end)--end)] = true
for n=1,4 do
if #grasses > 1 then
local n = math.random(1,#grasses)
local v = table.remove(grasses,n)
minetest.set_node(v,{name=tree})
end
end
end)
end
local f = math.floor
local function spawn_island(name,pos)
local ref = minetest.get_player_by_name(name)
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
island(pos,16,name)
ref:set_pos({x=pos.x,y=pos.y+30,z=pos.z})
ref:set_pos({x=pos.x,y=pos.y+256,z=pos.z})
end
local store = minetest.get_mod_storage()
local function pid(x,z)
@ -104,13 +98,89 @@ local function gen_island_pos(name)
ok = checkpos(x,z)
end
store:set_string(pid(x,z),name)
spawn_island(name,{x=x*128,y=256,z=z*128})
return pid(x,z)
local range = {min={x=x*128-64,y=256-64,z=z*128-64},max={x=x*128+64,y=256+64,z=z*128+64}}
local ip = {x=x*128+math.random(-32,32),y=256,z=z*128+math.random(-32,32)}
spawn_island(name,ip)
return pid(x,z),ip,range
end
local updrate = 0.5
local to_upd = updrate
minetest.register_globalstep(function(dt)
for f,_ in pairs(queue) do
local ok,err = coroutine.resume(f)
if not ok then
print(err)
queue[f]=nil
end
end
to_upd = to_upd-dt
if to_upd <= 0 then
to_upd = to_upd+updrate
for k,ref in pairs(minetest.get_connected_players()) do
local p = ref:get_pos()
if p.y < 0 then
ref:set_hp(ref:get_hp()-2,{reason="set_hp"})
if p.y < -128 then
local meta = ref:get_meta()
local pos = minetest.string_to_pos(meta:get_string("islandpos"))
if pos then
pos.y=pos.y+256
ref:set_pos(pos)
end
end
end
end
end
end)
minetest.register_chatcommand("reset",{
description = "Reset your island",
func = function(name,param)
local ref = minetest.get_player_by_name(name)
local meta = ref:get_meta()
local r = meta:get_string("islandrange")
r = minetest.deserialize(r)
minetest.emerge_area(r.min,r.max,function(bp,act,crem)
if crem > 0 then
return
end
local ref = minetest.get_player_by_name(name)
local meta = ref:get_meta()
local pos = minetest.string_to_pos(meta:get_string("islandpos"))
if pos then
local r = meta:get_string("islandrange")
r = minetest.deserialize(r)
print("PREVM")
air_c = minetest.get_content_id("air")
local vm = VoxelManip(r.min,r.max)
local rmi,rma = vm:get_emerged_area()
local var = VoxelArea:new{MinEdge=rmi,MaxEdge=rma}
local d = vm:get_data()
for x=r.min.x,r.max.x do
for y=r.min.y,r.max.y do
for z=r.min.z,r.max.z do
local i = var:index(x,y,z)
d[i] = air_c
end
end
end
vm:set_data(d)
print("PREWRITE")
vm:write_to_map()
print("POSTVM")
spawn_island(name,pos)
end
end)
end
})
minetest.register_on_joinplayer(function(ref)
local meta = ref:get_meta()
local name = ref:get_player_name()
if meta:get_string("island") == "" then
meta:set_string("island",gen_island_pos(name))
local p,ip,r = gen_island_pos(name)
meta:set_string("island",p)
meta:set_string("islandpos",minetest.pos_to_string(ip))
meta:set_string("islandrange",minetest.serialize(r))
end
end)

View File

@ -230,6 +230,26 @@ regliquid({
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
sounds = nodecore.sounds("nc_terrain_watery")
})
regliquid({
description = "HM Water",
mapgen = {},
tiles = {"nc_terrain_water.png"},
paramtype = "light",
liquid_viscosity = 1,
liquid_renewable = false,
alpha = 160,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drowning = 1,
drop = "",
groups = { coolant = 1, water = 2, moist = 2 },
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
sounds = nodecore.sounds("nc_terrain_watery")
})
regliquid({
name = "lava",
description = "Molten Rock",
@ -250,8 +270,8 @@ regliquid({
sounds = nodecore.sounds("nc_terrain_bubbly")
})
local src = modname..":water_source"
local flow = modname..":water_flowing"
local src = modname..":hm_water_source"
local flow = modname..":hm_water_flowing"
nodecore.register_limited_abm({