Singlenode option with spawn egg
parent
e76469ca56
commit
19e2d52709
|
@ -1,4 +1,4 @@
|
|||
moonrealm 0.6.5 by paramat
|
||||
moonrealm 0.6.6 by paramat
|
||||
For latest stable Minetest and back to 0.4.8
|
||||
Depends default
|
||||
Licenses: code WTFPL, textures CC BY-SA
|
||||
|
|
180
functions.lua
180
functions.lua
|
@ -169,4 +169,182 @@ minetest.register_abm({
|
|||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
moonrealm_appletree(pos)
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
||||
-- Singlenode option
|
||||
|
||||
local SINGLENODE = true
|
||||
|
||||
if SINGLENODE then
|
||||
minetest.register_on_mapgen_init(function(mgparams)
|
||||
minetest.set_mapgen_params({mgname="singlenode", water_level=-33000})
|
||||
end)
|
||||
|
||||
-- Spawn player
|
||||
|
||||
function spawnplayer(player)
|
||||
local GRADCEN = 1 -- -- Gradient centre / terrain centre average level
|
||||
local CENAMP = 64 -- -- Grad centre amplitude, terrain centre is varied by this
|
||||
local HIGRAD = 128 -- -- Surface generating noise gradient above gradcen, controls depth of upper terrain
|
||||
local LOGRAD = 128 -- -- Surface generating noise gradient below gradcen, controls depth of lower terrain
|
||||
local HEXP = 0.5 -- -- Noise offset exponent above gradcen, 1 = normal 3D perlin terrain
|
||||
local LEXP = 2 -- -- Noise offset exponent below gradcen
|
||||
local STOT = 0.04 -- -- Stone density threshold, depth of dust
|
||||
local PSCA = 4 -- Player scatter from world centre in chunks (80 nodes).
|
||||
local xsp
|
||||
local ysp
|
||||
local zsp
|
||||
local np_terrain = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=512, z=512},
|
||||
seed = 58588900033,
|
||||
octaves = 6,
|
||||
persist = 0.67
|
||||
}
|
||||
local np_terralt = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=414, y=414, z=414},
|
||||
seed = 13331930910,
|
||||
octaves = 6,
|
||||
persist = 0.67
|
||||
}
|
||||
local np_smooth = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=828, y=828, z=828},
|
||||
seed = 113,
|
||||
octaves = 4,
|
||||
persist = 0.4
|
||||
}
|
||||
local np_fault = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=414, y=828, z=414},
|
||||
seed = 14440002,
|
||||
octaves = 4,
|
||||
persist = 0.5
|
||||
}
|
||||
local np_gradcen = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=1024, y=1024, z=1024},
|
||||
seed = 9344,
|
||||
octaves = 4,
|
||||
persist = 0.4
|
||||
}
|
||||
local np_terblen = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=2048, y=2048, z=2048},
|
||||
seed = -13002,
|
||||
octaves = 3,
|
||||
persist = 0.4
|
||||
}
|
||||
for chunk = 1, 64 do
|
||||
print ("[moonrealm] searching for spawn "..chunk)
|
||||
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||
local z0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||
local y0 = -32
|
||||
local x1 = x0 + 79
|
||||
local z1 = z0 + 79
|
||||
local y1 = 47
|
||||
|
||||
local sidelen = 80
|
||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||
local minpos = {x=x0, y=y0, z=z0}
|
||||
local minposd = {x=x0, y=z0}
|
||||
|
||||
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minpos)
|
||||
local nvals_terralt = minetest.get_perlin_map(np_terralt, chulens):get3dMap_flat(minpos)
|
||||
local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minpos)
|
||||
local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minpos)
|
||||
|
||||
local nvals_terblen = minetest.get_perlin_map(np_terblen, chulens):get2dMap_flat(minposd)
|
||||
local nvals_gradcen = minetest.get_perlin_map(np_gradcen, chulens):get2dMap_flat(minposd)
|
||||
|
||||
local nixz = 1
|
||||
local nixyz = 1
|
||||
local stable = {}
|
||||
for z = z0, z1 do
|
||||
for y = y0, y1 do
|
||||
for x = x0, x1 do
|
||||
local si = x - x0 + 1
|
||||
local grad
|
||||
local density
|
||||
local terblen = math.max(math.min(math.abs(nvals_terblen[nixz]) * 4, 1.5), 0.5) - 0.5
|
||||
local gradcen = GRADCEN + nvals_gradcen[nixz] * CENAMP
|
||||
if y > gradcen then
|
||||
grad = -((y - gradcen) / HIGRAD) ^ HEXP
|
||||
else
|
||||
grad = ((gradcen - y) / LOGRAD) ^ LEXP
|
||||
end
|
||||
if nvals_fault[nixyz] >= 0 then
|
||||
density = (nvals_terrain[nixyz] + nvals_terralt[nixyz]) / 2 * (1 - terblen)
|
||||
+ nvals_smooth[nixyz] * terblen + grad
|
||||
else
|
||||
density = (nvals_terrain[nixyz] - nvals_terralt[nixyz]) / 2 * (1 - terblen)
|
||||
- nvals_smooth[nixyz] * terblen + grad
|
||||
end
|
||||
if density >= STOT then
|
||||
stable[si] = true
|
||||
elseif stable[si] and density < 0 then
|
||||
ysp = y + 8
|
||||
xsp = x
|
||||
zsp = z
|
||||
break
|
||||
end
|
||||
nixz = nixz + 1
|
||||
nixyz = nixyz + 1
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz - 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz + 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
end
|
||||
print ("[moonrealm] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local pos1 = {x=xsp-2, y=ysp-2, z=zsp-2}
|
||||
local pos2 = {x=xsp+2, y=ysp+2, z=zsp+2}
|
||||
local emin, emax = vm:read_from_map(pos1, pos2)
|
||||
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
|
||||
local data = vm:get_data()
|
||||
local c_glass = minetest.get_content_id("default:glass")
|
||||
local c_lsair = minetest.get_content_id("moonrealm:air")
|
||||
for i = -2, 2 do
|
||||
for j = -2, 2 do
|
||||
for k = -2, 2 do
|
||||
local vi = area:index(xsp + i, ysp + j, zsp + k)
|
||||
if i ^ 2 + j ^ 2 + k ^ 2 >= 4 then
|
||||
data[vi] = c_glass
|
||||
else
|
||||
data[vi] = c_lsair
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
end
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
spawnplayer(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
spawnplayer(player)
|
||||
return true
|
||||
end)
|
||||
end
|
35
init.lua
35
init.lua
|
@ -1,22 +1,20 @@
|
|||
-- moonrealm 0.6.5 by paramat
|
||||
-- moonrealm 0.6.6 by paramat
|
||||
-- For latest stable Minetest and back to 0.4.8
|
||||
-- Depends default
|
||||
-- Licenses: code WTFPL, textures CC BY-SA
|
||||
|
||||
-- TODO
|
||||
-- Craters
|
||||
-- Exclusive ores
|
||||
-- singlenode mode with spawn chamber
|
||||
|
||||
-- Parameters
|
||||
|
||||
local XMIN = -33000 -- -- Approx horizontal limits
|
||||
local XMAX = 33000
|
||||
local ZMIN = -33000
|
||||
local ZMAX = 33000
|
||||
local XMIN = -8000 -- -- Approx horizontal limits. 1/4 of normal realm size.
|
||||
local XMAX = 8000
|
||||
local ZMIN = -8000
|
||||
local ZMAX = 8000
|
||||
|
||||
local YMIN = 14000 -- -- Approx lower limit
|
||||
local GRADCEN = 15000 -- -- Gradient centre / terrain centre average level
|
||||
local YMAX = 16000 -- -- Approx upper limit
|
||||
local YMIN = -8000 -- -- Approx lower limit
|
||||
local GRADCEN = 1 -- -- Gradient centre / terrain centre average level
|
||||
local YMAX = 8000 -- -- Approx upper limit
|
||||
|
||||
local FOOT = true -- -- Footprints in dust
|
||||
local CENAMP = 64 -- -- Grad centre amplitude, terrain centre is varied by this
|
||||
|
@ -196,6 +194,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_mese = minetest.get_content_id("default:mese")
|
||||
local c_mrironore = minetest.get_content_id("moonrealm:ironore")
|
||||
local c_mrcopperore = minetest.get_content_id("moonrealm:copperore")
|
||||
|
@ -237,6 +236,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local vi = area:index(x0, y, z) -- LVM index for first node in x row
|
||||
local icecha = ICECHA * (1 + (GRADCEN - y) / ICEGRAD)
|
||||
for x = x0, x1 do -- for each node
|
||||
local nodid = data[vi]
|
||||
local air = nodid == c_air
|
||||
local grad
|
||||
local density
|
||||
local si = x - x0 + 1 -- indexes start from 1
|
||||
|
@ -283,15 +284,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
data[vi] = c_dust
|
||||
end
|
||||
else -- fissure
|
||||
data[vi] = c_vacuum
|
||||
if air then
|
||||
data[vi] = c_vacuum
|
||||
end
|
||||
stable[si] = false
|
||||
end
|
||||
else -- fissure or unstable missing node
|
||||
data[vi] = c_vacuum
|
||||
if air then
|
||||
data[vi] = c_vacuum
|
||||
end
|
||||
stable[si] = false
|
||||
end
|
||||
else -- vacuum
|
||||
data[vi] = c_vacuum
|
||||
if air then
|
||||
data[vi] = c_vacuum
|
||||
end
|
||||
stable[si] = false
|
||||
end
|
||||
ni = ni + 1
|
||||
|
|
23
nodes.lua
23
nodes.lua
|
@ -1,6 +1,7 @@
|
|||
minetest.register_node("moonrealm:stone", {
|
||||
description = "Moon Stone",
|
||||
tiles = {"moonrealm_stone.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
@ -8,6 +9,7 @@ minetest.register_node("moonrealm:stone", {
|
|||
minetest.register_node("moonrealm:ironore", {
|
||||
description = "MR Iron Ore",
|
||||
tiles = {"moonrealm_stone.png^default_mineral_iron.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2},
|
||||
drop = "default:iron_lump",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -16,6 +18,7 @@ minetest.register_node("moonrealm:ironore", {
|
|||
minetest.register_node("moonrealm:copperore", {
|
||||
description = "MR Copper Ore",
|
||||
tiles = {"moonrealm_stone.png^default_mineral_copper.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2},
|
||||
drop = "default:copper_lump",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -24,6 +27,7 @@ minetest.register_node("moonrealm:copperore", {
|
|||
minetest.register_node("moonrealm:goldore", {
|
||||
description = "MR Gold Ore",
|
||||
tiles = {"moonrealm_stone.png^default_mineral_gold.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2},
|
||||
drop = "default:gold_lump",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -32,6 +36,7 @@ minetest.register_node("moonrealm:goldore", {
|
|||
minetest.register_node("moonrealm:diamondore", {
|
||||
description = "MR Diamond Ore",
|
||||
tiles = {"moonrealm_stone.png^default_mineral_diamond.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=1},
|
||||
drop = "default:diamond",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
@ -40,6 +45,7 @@ minetest.register_node("moonrealm:diamondore", {
|
|||
minetest.register_node("moonrealm:dust", {
|
||||
description = "Moon Dust",
|
||||
tiles = {"moonrealm_dust.png"},
|
||||
is_ground_content = false,
|
||||
groups = {crumbly=3, falling_node=1},
|
||||
sounds = default.node_sound_sand_defaults({
|
||||
footstep = {name="default_sand_footstep", gain=0.1},
|
||||
|
@ -49,6 +55,7 @@ minetest.register_node("moonrealm:dust", {
|
|||
minetest.register_node("moonrealm:dustprint1", {
|
||||
description = "Moon Dust Footprint1",
|
||||
tiles = {"moonrealm_dustprint1.png", "moonrealm_dust.png"},
|
||||
is_ground_content = false,
|
||||
groups = {crumbly=3, falling_node=1},
|
||||
drop = "moonrealm:dust",
|
||||
sounds = default.node_sound_sand_defaults({
|
||||
|
@ -59,6 +66,7 @@ minetest.register_node("moonrealm:dustprint1", {
|
|||
minetest.register_node("moonrealm:dustprint2", {
|
||||
description = "Moon Dust Footprint2",
|
||||
tiles = {"moonrealm_dustprint2.png", "moonrealm_dust.png"},
|
||||
is_ground_content = false,
|
||||
groups = {crumbly=3, falling_node=1},
|
||||
drop = "moonrealm:dust",
|
||||
sounds = default.node_sound_sand_defaults({
|
||||
|
@ -70,6 +78,7 @@ minetest.register_node("moonrealm:vacuum", {
|
|||
description = "Vacuum",
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
|
@ -83,6 +92,7 @@ minetest.register_node("moonrealm:air", {
|
|||
drawtype = "glasslike",
|
||||
tiles = {"moonrealm_air.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
|
@ -93,6 +103,7 @@ minetest.register_node("moonrealm:air", {
|
|||
minetest.register_node("moonrealm:airgen", {
|
||||
description = "Air Generator",
|
||||
tiles = {"moonrealm_airgen.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
|
@ -122,6 +133,7 @@ minetest.register_node("moonrealm:waterice", {
|
|||
tiles = {"moonrealm_waterice.png"},
|
||||
light_source = 1,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,melts=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
|
@ -146,6 +158,7 @@ minetest.register_node("moonrealm:hlflowing", {
|
|||
},
|
||||
alpha = 224,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
|
@ -165,6 +178,7 @@ minetest.register_node("moonrealm:hlsource", {
|
|||
tiles = {"moonrealm_hl.png"},
|
||||
alpha = 224,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
buildable_to = true,
|
||||
|
@ -179,6 +193,7 @@ minetest.register_node("moonrealm:hlsource", {
|
|||
minetest.register_node("moonrealm:soil", {
|
||||
description = "Moonsoil",
|
||||
tiles = {"moonrealm_soil.png"},
|
||||
is_ground_content = false,
|
||||
groups = {crumbly=3, falling_node=1, soil=3},
|
||||
drop = "moonrealm:dust",
|
||||
sounds = default.node_sound_dirt_defaults(),
|
||||
|
@ -188,6 +203,7 @@ minetest.register_node("moonrealm:airlock", {
|
|||
description = "Airlock",
|
||||
tiles = {"moonrealm_airlock.png"},
|
||||
light_source = 14,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
post_effect_color = {a=255, r=0, g=0, b=0},
|
||||
groups = {cracky=3},
|
||||
|
@ -199,6 +215,7 @@ minetest.register_node("moonrealm:glass", {
|
|||
drawtype = "glasslike",
|
||||
tiles = {"default_obsidian_glass.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
|
@ -212,6 +229,7 @@ minetest.register_node("moonrealm:sapling", {
|
|||
inventory_image = "default_sapling.png",
|
||||
wield_image = "default_sapling.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
groups = {snappy=2,dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
|
@ -223,6 +241,7 @@ minetest.register_node("moonrealm:leaves", {
|
|||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
|
@ -238,6 +257,7 @@ minetest.register_node("moonrealm:light", {
|
|||
description = "Light",
|
||||
tiles = {"moonrealm_light.png"},
|
||||
light_source = 14,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
@ -245,6 +265,7 @@ minetest.register_node("moonrealm:light", {
|
|||
minetest.register_node("moonrealm:stonebrick", {
|
||||
description = "Moon Stone Brick",
|
||||
tiles = {"moonrealm_stonebricktop.png", "moonrealm_stonebrickbot.png", "moonrealm_stonebrick.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
@ -254,6 +275,7 @@ minetest.register_node("moonrealm:stoneslab", {
|
|||
tiles = {"moonrealm_stonebricktop.png", "moonrealm_stonebrickbot.png", "moonrealm_stonebrick.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
buildable_to = true,
|
||||
node_box = {
|
||||
|
@ -278,6 +300,7 @@ minetest.register_node("moonrealm:stonestair", {
|
|||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {cracky=3},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
|
|
Loading…
Reference in New Issue