Big update. Fix darkness
This commit is contained in:
parent
0557561d65
commit
9118873f03
21
README.txt
21
README.txt
@ -1,7 +1,21 @@
|
|||||||
moonrealm 0.8.1 by paramat
|
moonrealm 0.8.2 by paramat
|
||||||
For Minetest 0.4.10
|
For Minetest 0.4.12 or later
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: code WTFPL, textures CC BY-SA
|
Licenses: Code LGPL 2.1. Media CC BY-SA
|
||||||
|
|
||||||
|
|
||||||
|
Version changes:
|
||||||
|
|
||||||
|
Shell drops nothing
|
||||||
|
Simpler appletree with vi = vi + 1 optimisation, more apples
|
||||||
|
New licences
|
||||||
|
paramtype = "light" for light sources
|
||||||
|
No longer override day night ratio on joinplayer to avoid darkness
|
||||||
|
Set SPAWNEGG in functions.lua to enable spawnegg spawning in moonrealm
|
||||||
|
Moonrealm mese glows and drops default:mese
|
||||||
|
Shorten lines, cleanup code, fix undeclared globals
|
||||||
|
Noise objects created only once
|
||||||
|
|
||||||
|
|
||||||
Crafting
|
Crafting
|
||||||
--------
|
--------
|
||||||
@ -100,3 +114,4 @@ LIL
|
|||||||
LLL
|
LLL
|
||||||
L = moonrealm leaves
|
L = moonrealm leaves
|
||||||
I = moonrealm waterice
|
I = moonrealm waterice
|
||||||
|
|
||||||
|
@ -24,37 +24,43 @@ function moonrealm_appletree(pos)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for j = 1, 5 do -- check for life support air
|
for j = 1, 5 do -- check for life support air
|
||||||
for i = -2, 2 do
|
|
||||||
for k = -2, 2 do
|
for k = -2, 2 do
|
||||||
local vi = area:index(x + i, y + j, z + k)
|
local vi = area:index(x - 2, y + j, z + k)
|
||||||
|
for i = -2, 2 do
|
||||||
if data[vi] ~= c_lsair then
|
if data[vi] ~= c_lsair then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
vi = vi + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for j = -2, top do -- spawn appletree
|
|
||||||
|
for j = -2, top do
|
||||||
if j == top - 1 or j == top then
|
if j == top - 1 or j == top then
|
||||||
for i = -2, 2 do
|
|
||||||
for k = -2, 2 do
|
for k = -2, 2 do
|
||||||
local vi = area:index(x + i, y + j, z + k)
|
local vi = area:index(x - 2, y + j, z + k)
|
||||||
if math.random(5) ~= 2 then
|
local viu = area:index(x - 2, y + j - 1, z + k)
|
||||||
|
for i = -2, 2 do
|
||||||
|
if math.random() < 0.8 then
|
||||||
data[vi] = c_appleleaf
|
data[vi] = c_appleleaf
|
||||||
if j == top and math.random() < 0.04 then -- apples hang from leaves
|
if j == top and math.random() < 0.08 then
|
||||||
local viu = area:index(x + i, y + j - 1, z + k)
|
|
||||||
data[viu] = c_apple
|
data[viu] = c_apple
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
vi = vi + 1
|
||||||
|
viu = viu + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif j == top - 2 then
|
elseif j == top - 2 then
|
||||||
for i = -1, 1 do
|
|
||||||
for k = -1, 1 do
|
for k = -1, 1 do
|
||||||
|
local vi = area:index(x - 1, y + j, z + k)
|
||||||
|
for i = -1, 1 do
|
||||||
if math.abs(i) + math.abs(k) == 2 then
|
if math.abs(i) + math.abs(k) == 2 then
|
||||||
local vi = area:index(x + i, y + j, z + k)
|
|
||||||
data[vi] = c_tree
|
data[vi] = c_tree
|
||||||
end
|
end
|
||||||
|
vi = vi + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -70,6 +76,7 @@ function moonrealm_appletree(pos)
|
|||||||
print ("[moonrealm] Appletree sapling grows")
|
print ("[moonrealm] Appletree sapling grows")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Vacuum or air flows into a dug hole
|
-- Vacuum or air flows into a dug hole
|
||||||
|
|
||||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||||
@ -117,9 +124,8 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
|||||||
print ("[moonrealm] Vacuum flows into hole")
|
print ("[moonrealm] Vacuum flows into hole")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- ABMs
|
|
||||||
|
|
||||||
-- Air spreads
|
-- Air spread ABM
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moonrealm:air"},
|
nodenames = {"moonrealm:air"},
|
||||||
@ -168,7 +174,8 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Hydroponic saturation
|
|
||||||
|
-- Hydroponic saturation ABM
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moonrealm:hlsource"},
|
nodenames = {"moonrealm:hlsource"},
|
||||||
@ -216,7 +223,8 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Soil drying
|
|
||||||
|
-- Soil drying ABM
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moonrealm:soil"},
|
nodenames = {"moonrealm:soil"},
|
||||||
@ -261,7 +269,8 @@ minetest.register_abm({
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Space appletree from sapling
|
|
||||||
|
-- Space appletree from sapling ABM
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moonrealm:sapling"},
|
nodenames = {"moonrealm:sapling"},
|
||||||
@ -272,39 +281,11 @@ minetest.register_abm({
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Singlenode option
|
|
||||||
|
|
||||||
local SINGLENODE = true
|
-- Spawn player function, dependant on chunk size of 80 nodes
|
||||||
|
|
||||||
if SINGLENODE then
|
function moonrealm_spawnplayer(player)
|
||||||
minetest.register_on_mapgen_init(function(mgparams)
|
local GRADCEN = 0 -- -- Gradient centre / terrain centre average level
|
||||||
minetest.set_mapgen_params({mgname="singlenode", water_level=-33000})
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
minetest.setting_set("enable_clouds", "false")
|
|
||||||
minetest.after(0, function()
|
|
||||||
skytextures = {
|
|
||||||
"moonrealm_posy.png",
|
|
||||||
"moonrealm_negy.png",
|
|
||||||
"moonrealm_posz.png",
|
|
||||||
"moonrealm_negz.png",
|
|
||||||
"moonrealm_negx.png",
|
|
||||||
"moonrealm_posx.png",
|
|
||||||
}
|
|
||||||
player:set_sky({r=0, g=0, b=0, a=0},"skybox", skytextures)
|
|
||||||
end)
|
|
||||||
player:override_day_night_ratio(1)
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
minetest.setting_set("enable_clouds", "true")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Spawn player
|
|
||||||
|
|
||||||
function moonrealm_spawnplayer(player)
|
|
||||||
local GRADCEN = 1 -- -- Gradient centre / terrain centre average level
|
|
||||||
local CENAMP = 64 -- -- Grad centre amplitude, terrain centre is varied by this
|
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 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 LOGRAD = 128 -- -- Surface generating noise gradient below gradcen, controls depth of lower terrain
|
||||||
@ -365,12 +346,13 @@ if SINGLENODE then
|
|||||||
}
|
}
|
||||||
for chunk = 1, 64 do
|
for chunk = 1, 64 do
|
||||||
print ("[moonrealm] searching for spawn "..chunk)
|
print ("[moonrealm] searching for spawn "..chunk)
|
||||||
|
|
||||||
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
local x0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||||
local z0 = 80 * math.random(-PSCA, PSCA) - 32
|
local z0 = 80 * math.random(-PSCA, PSCA) - 32
|
||||||
local y0 = -32
|
local y0 = 80 * math.floor((GRADCEN + 32) / 80) - 32
|
||||||
local x1 = x0 + 79
|
local x1 = x0 + 79
|
||||||
local z1 = z0 + 79
|
local z1 = z0 + 79
|
||||||
local y1 = 47
|
local y1 = y0 + 79
|
||||||
|
|
||||||
local sidelen = 80
|
local sidelen = 80
|
||||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
@ -433,7 +415,9 @@ if SINGLENODE then
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print ("[moonrealm] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
print ("[moonrealm] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
||||||
|
|
||||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
player:setpos({x=xsp, y=ysp, z=zsp})
|
||||||
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "moonrealm:spacesuit")
|
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "moonrealm:spacesuit")
|
||||||
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "moonrealm:sapling 4")
|
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "moonrealm:sapling 4")
|
||||||
@ -444,6 +428,7 @@ if SINGLENODE then
|
|||||||
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:pick_diamond")
|
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:pick_diamond")
|
||||||
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:axe_diamond")
|
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:axe_diamond")
|
||||||
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:shovel_diamond")
|
minetest.add_item({x=xsp, y=ysp+1, z=zsp}, "default:shovel_diamond")
|
||||||
|
|
||||||
local vm = minetest.get_voxel_manip()
|
local vm = minetest.get_voxel_manip()
|
||||||
local pos1 = {x=xsp-3, y=ysp-3, z=zsp-3}
|
local pos1 = {x=xsp-3, y=ysp-3, z=zsp-3}
|
||||||
local pos2 = {x=xsp+3, y=ysp+6, z=zsp+3}
|
local pos2 = {x=xsp+3, y=ysp+6, z=zsp+3}
|
||||||
@ -453,6 +438,7 @@ if SINGLENODE then
|
|||||||
local c_shell = minetest.get_content_id("moonrealm:shell")
|
local c_shell = minetest.get_content_id("moonrealm:shell")
|
||||||
local c_light = minetest.get_content_id("moonrealm:light")
|
local c_light = minetest.get_content_id("moonrealm:light")
|
||||||
local c_lsair = minetest.get_content_id("moonrealm:air")
|
local c_lsair = minetest.get_content_id("moonrealm:air")
|
||||||
|
|
||||||
for i = -3, 3 do
|
for i = -3, 3 do
|
||||||
for j = -3, 6 do
|
for j = -3, 6 do
|
||||||
for k = -3, 3 do
|
for k = -3, 3 do
|
||||||
@ -478,8 +464,11 @@ if SINGLENODE then
|
|||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
vm:update_map()
|
vm:update_map()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local SPAWNEGG = true
|
||||||
|
if SPAWNEGG then
|
||||||
minetest.register_on_newplayer(function(player)
|
minetest.register_on_newplayer(function(player)
|
||||||
moonrealm_spawnplayer(player)
|
moonrealm_spawnplayer(player)
|
||||||
end)
|
end)
|
||||||
@ -489,3 +478,4 @@ if SINGLENODE then
|
|||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
177
init.lua
177
init.lua
@ -1,21 +1,13 @@
|
|||||||
-- moonrealm 0.8.1 by paramat
|
|
||||||
-- For Minetest 0.4.10
|
|
||||||
-- Depends default
|
|
||||||
-- Licenses: code WTFPL, textures CC BY-SA
|
|
||||||
|
|
||||||
-- TODO
|
|
||||||
-- on-dignode, air, hydroponics, soil drying by LVM too
|
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local XMIN = -8000 -- Approx horizontal limits. 1/4 of normal realm size.
|
local SINGLENODE = true -- Set to true if using singlenode mapgen
|
||||||
|
local YMIN = -8000 -- Approx lower limit
|
||||||
|
local GRADCEN = 0 -- Gradient centre / terrain centre average level
|
||||||
|
local YMAX = 8000 -- Approx upper limit
|
||||||
|
local XMIN = -8000 -- Approx horizontal limits
|
||||||
local XMAX = 8000
|
local XMAX = 8000
|
||||||
local ZMIN = -8000
|
local ZMIN = -8000
|
||||||
local ZMAX = 8000
|
local ZMAX = 8000
|
||||||
-- Change the 3 parameters below when changing between singlenode and stacked modes
|
|
||||||
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 FOOT = true -- Footprints in dust
|
||||||
local CENAMP = 64 -- Grad centre amplitude, terrain centre is varied by this
|
local CENAMP = 64 -- Grad centre amplitude, terrain centre is varied by this
|
||||||
@ -29,7 +21,6 @@ local ICEGRAD = 128 -- Ice gradient, vertical distance for no ice
|
|||||||
local ORECHA = 7*7*7 -- Ore 1/x chance per stone node
|
local ORECHA = 7*7*7 -- Ore 1/x chance per stone node
|
||||||
local TFIS = 0.01 -- Fissure threshold. Controls size of fissures
|
local TFIS = 0.01 -- Fissure threshold. Controls size of fissures
|
||||||
|
|
||||||
|
|
||||||
-- 3D noise for terrain
|
-- 3D noise for terrain
|
||||||
|
|
||||||
local np_terrain = {
|
local np_terrain = {
|
||||||
@ -108,64 +99,96 @@ local np_terblen = {
|
|||||||
persist = 0.4
|
persist = 0.4
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stuff
|
|
||||||
|
|
||||||
moonrealm = {}
|
-- Do files
|
||||||
|
|
||||||
dofile(minetest.get_modpath("moonrealm").."/nodes.lua")
|
dofile(minetest.get_modpath("moonrealm").."/nodes.lua")
|
||||||
dofile(minetest.get_modpath("moonrealm").."/functions.lua")
|
dofile(minetest.get_modpath("moonrealm").."/functions.lua")
|
||||||
|
|
||||||
|
|
||||||
|
-- Set water level in singlenode mapgen
|
||||||
|
|
||||||
|
if SINGLENODE then
|
||||||
|
minetest.register_on_mapgen_init(function(mgparams)
|
||||||
|
minetest.set_mapgen_params({water_level=-32000})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Player positions
|
-- Player positions
|
||||||
|
|
||||||
local player_pos = {}
|
local player_pos = {}
|
||||||
local player_pos_previous = {}
|
local player_pos_previous = {}
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
player_pos_previous[player:get_player_name()] = {x=0,y=0,z=0}
|
player_pos_previous[player:get_player_name()] = {x = 0, y = 0, z = 0}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
player_pos_previous[player:get_player_name()] = nil
|
player_pos_previous[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Globalstep function
|
-- Globalstep function
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
if FOOT and math.random() < 0.3 and player_pos_previous[player:get_player_name()] ~= nil then -- footprints
|
if player_pos_previous[player:get_player_name()] ~= nil and -- footprints
|
||||||
|
FOOT and math.random() < 0.3 then
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
player_pos[player:get_player_name()] = {x=math.floor(pos.x+0.5),y=math.floor(pos.y+0.2),z=math.floor(pos.z+0.5)}
|
player_pos[player:get_player_name()] = {
|
||||||
local p_ground = {x=math.floor(pos.x+0.5),y=math.floor(pos.y+0.4),z=math.floor(pos.z+0.5)}
|
x = math.floor(pos.x + 0.5),
|
||||||
|
y = math.floor(pos.y + 0.2),
|
||||||
|
z = math.floor(pos.z + 0.5)
|
||||||
|
}
|
||||||
|
local p_ground = {
|
||||||
|
x = math.floor(pos.x + 0.5),
|
||||||
|
y = math.floor(pos.y + 0.4),
|
||||||
|
z = math.floor(pos.z + 0.5)
|
||||||
|
}
|
||||||
local n_ground = minetest.get_node(p_ground).name
|
local n_ground = minetest.get_node(p_ground).name
|
||||||
local p_groundpl = {x=math.floor(pos.x+0.5),y=math.floor(pos.y-0.5),z=math.floor(pos.z+0.5)}
|
local p_groundpl = {
|
||||||
if player_pos[player:get_player_name()].x ~= player_pos_previous[player:get_player_name()].x
|
x = math.floor(pos.x + 0.5),
|
||||||
or player_pos[player:get_player_name()].y < player_pos_previous[player:get_player_name()].y
|
y = math.floor(pos.y - 0.5),
|
||||||
or player_pos[player:get_player_name()].z ~= player_pos_previous[player:get_player_name()].z then
|
z = math.floor(pos.z + 0.5)
|
||||||
|
}
|
||||||
|
if player_pos[player:get_player_name()].x ~=
|
||||||
|
player_pos_previous[player:get_player_name()].x or
|
||||||
|
player_pos[player:get_player_name()].y <
|
||||||
|
player_pos_previous[player:get_player_name()].y or
|
||||||
|
player_pos[player:get_player_name()].z ~=
|
||||||
|
player_pos_previous[player:get_player_name()].z then
|
||||||
if n_ground == "moonrealm:dust" then
|
if n_ground == "moonrealm:dust" then
|
||||||
if math.random() < 0.5 then
|
if math.random() < 0.5 then
|
||||||
minetest.add_node(p_groundpl,{name="moonrealm:dustprint1"})
|
minetest.add_node(
|
||||||
|
p_groundpl,
|
||||||
|
{name = "moonrealm:dustprint1"}
|
||||||
|
)
|
||||||
else
|
else
|
||||||
minetest.add_node(p_groundpl,{name="moonrealm:dustprint2"})
|
minetest.add_node(
|
||||||
|
p_groundpl,
|
||||||
|
{name = "moonrealm:dustprint2"}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
player_pos_previous[player:get_player_name()] = {
|
player_pos_previous[player:get_player_name()] = {
|
||||||
x=player_pos[player:get_player_name()].x,
|
x = player_pos[player:get_player_name()].x,
|
||||||
y=player_pos[player:get_player_name()].y,
|
y = player_pos[player:get_player_name()].y,
|
||||||
z=player_pos[player:get_player_name()].z
|
z = player_pos[player:get_player_name()].z
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if math.random() < 0.1 then -- spacesuit restores breath
|
if math.random() < 0.1 then -- spacesuit restores breath
|
||||||
if player:get_inventory():contains_item("main", "moonrealm:spacesuit")
|
if player:get_inventory():contains_item("main", "moonrealm:spacesuit") and
|
||||||
and player:get_breath() < 10 then
|
player:get_breath() < 10 then
|
||||||
player:set_breath(10)
|
player:set_breath(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if math.random() > 0.99 then -- set gravity, skybox and override time when entering/leaving moonrealm
|
if math.random() > 0.99 then -- set gravity, skybox and override light
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
if pos.y > YMIN and pos.y < YMAX then -- entering realm
|
if pos.y > YMIN and pos.y < YMAX then -- entering realm
|
||||||
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
|
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
|
||||||
skytextures = {
|
local skytextures = {
|
||||||
"moonrealm_posy.png",
|
"moonrealm_posy.png",
|
||||||
"moonrealm_negy.png",
|
"moonrealm_negy.png",
|
||||||
"moonrealm_posz.png",
|
"moonrealm_posz.png",
|
||||||
@ -184,12 +207,25 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- Initialize noise objects to nil
|
||||||
|
|
||||||
|
local nobj_terrain = nil
|
||||||
|
local nobj_terralt = nil
|
||||||
|
local nobj_smooth = nil
|
||||||
|
local nobj_fissure = nil
|
||||||
|
local nobj_fault = nil
|
||||||
|
|
||||||
|
local nobj_terblen = nil
|
||||||
|
local nobj_gradcen = nil
|
||||||
|
|
||||||
|
|
||||||
-- On generated function
|
-- On generated function
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if minp.x < XMIN or maxp.x > XMAX
|
if minp.x < XMIN or maxp.x > XMAX or
|
||||||
or minp.y < YMIN or maxp.y > YMAX
|
minp.y < YMIN or maxp.y > YMAX or
|
||||||
or minp.z < ZMIN or maxp.z > ZMAX then
|
minp.z < ZMIN or maxp.z > ZMAX then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -201,14 +237,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local y0 = minp.y
|
local y0 = minp.y
|
||||||
local z0 = minp.z
|
local z0 = minp.z
|
||||||
|
|
||||||
print ("[moonrealm] chunk minp ("..x0.." "..y0.." "..z0..")")
|
|
||||||
|
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_mese = minetest.get_content_id("default:mese")
|
local c_ignore = minetest.get_content_id("ignore")
|
||||||
|
local c_mese = minetest.get_content_id("moonrealm:mese")
|
||||||
local c_mrironore = minetest.get_content_id("moonrealm:ironore")
|
local c_mrironore = minetest.get_content_id("moonrealm:ironore")
|
||||||
local c_mrcopperore = minetest.get_content_id("moonrealm:copperore")
|
local c_mrcopperore = minetest.get_content_id("moonrealm:copperore")
|
||||||
local c_mrgoldore = minetest.get_content_id("moonrealm:goldore")
|
local c_mrgoldore = minetest.get_content_id("moonrealm:goldore")
|
||||||
@ -218,31 +253,41 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local c_dust = minetest.get_content_id("moonrealm:dust")
|
local c_dust = minetest.get_content_id("moonrealm:dust")
|
||||||
local c_vacuum = minetest.get_content_id("moonrealm:vacuum")
|
local c_vacuum = minetest.get_content_id("moonrealm:vacuum")
|
||||||
|
|
||||||
local sidelen = x1 - x0 + 1
|
local chulens = x1 - x0 + 1
|
||||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
local pmaplens2d = {x = chulens, y = chulens, z = 1}
|
||||||
local minpos = {x=x0, y=y0, z=z0}
|
local pmaplens3d = {x = chulens, y = chulens, z = chulens}
|
||||||
local minposd = {x=x0, y=z0}
|
local minpos2d = {x = x0, y = z0}
|
||||||
|
local minpos3d = {x = x0, y = y0, z = z0}
|
||||||
|
|
||||||
local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minpos)
|
nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, pmaplens3d)
|
||||||
local nvals_terralt = minetest.get_perlin_map(np_terralt, chulens):get3dMap_flat(minpos)
|
nobj_terralt = nobj_terralt or minetest.get_perlin_map(np_terralt, pmaplens3d)
|
||||||
local nvals_smooth = minetest.get_perlin_map(np_smooth, chulens):get3dMap_flat(minpos)
|
nobj_smooth = nobj_smooth or minetest.get_perlin_map(np_smooth, pmaplens3d)
|
||||||
local nvals_fissure = minetest.get_perlin_map(np_fissure, chulens):get3dMap_flat(minpos)
|
nobj_fissure = nobj_fissure or minetest.get_perlin_map(np_fissure, pmaplens3d)
|
||||||
local nvals_fault = minetest.get_perlin_map(np_fault, chulens):get3dMap_flat(minpos)
|
nobj_fault = nobj_fault or minetest.get_perlin_map(np_fault, pmaplens3d)
|
||||||
|
|
||||||
local nvals_terblen = minetest.get_perlin_map(np_terblen, chulens):get2dMap_flat(minposd)
|
nobj_terblen = nobj_terblen or minetest.get_perlin_map(np_terblen, pmaplens2d)
|
||||||
local nvals_gradcen = minetest.get_perlin_map(np_gradcen, chulens):get2dMap_flat(minposd)
|
nobj_gradcen = nobj_gradcen or minetest.get_perlin_map(np_gradcen, pmaplens2d)
|
||||||
|
|
||||||
|
local nvals_terrain = nobj_terrain:get3dMap_flat(minpos3d)
|
||||||
|
local nvals_terralt = nobj_terralt:get3dMap_flat(minpos3d)
|
||||||
|
local nvals_smooth = nobj_smooth :get3dMap_flat(minpos3d)
|
||||||
|
local nvals_fissure = nobj_fissure:get3dMap_flat(minpos3d)
|
||||||
|
local nvals_fault = nobj_fault :get3dMap_flat(minpos3d)
|
||||||
|
|
||||||
|
local nvals_terblen = nobj_terblen:get2dMap_flat(minpos2d)
|
||||||
|
local nvals_gradcen = nobj_gradcen:get2dMap_flat(minpos2d)
|
||||||
|
|
||||||
local ni = 1
|
local ni = 1
|
||||||
local nid = 1 -- 2D noise index
|
local ni2d = 1
|
||||||
local stable = {}
|
local stable = {}
|
||||||
for z = z0, z1 do
|
for z = z0, z1 do
|
||||||
local viu = area:index(x0, y0-1, z)
|
local viu = area:index(x0, y0 - 1, z)
|
||||||
for x = x0, x1 do
|
for x = x0, x1 do
|
||||||
local si = x - x0 + 1
|
local si = x - x0 + 1
|
||||||
local nodid = data[viu]
|
local nodid = data[viu]
|
||||||
if nodid == c_vacuum then
|
if nodid == c_vacuum then
|
||||||
stable[si] = false
|
stable[si] = false
|
||||||
else -- solid nodes and ignore in ungenerated chunks
|
else
|
||||||
stable[si] = true
|
stable[si] = true
|
||||||
end
|
end
|
||||||
viu = viu + 1
|
viu = viu + 1
|
||||||
@ -250,24 +295,26 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
for y = y0, y1 do
|
for y = y0, y1 do
|
||||||
local vi = area:index(x0, y, z) -- LVM index for first node in x row
|
local vi = area:index(x0, y, z) -- LVM index for first node in x row
|
||||||
local icecha = ICECHA * (1 + (GRADCEN - y) / ICEGRAD)
|
local icecha = ICECHA * (1 + (GRADCEN - y) / ICEGRAD)
|
||||||
for x = x0, x1 do -- for each node
|
for x = x0, x1 do
|
||||||
local nodid = data[vi]
|
local nodid = data[vi]
|
||||||
local empty = (nodid == c_air or nodid == c_ignore)
|
local empty = (nodid == c_air or nodid == c_ignore)
|
||||||
local grad
|
local grad
|
||||||
local density
|
local density
|
||||||
local si = x - x0 + 1 -- indexes start from 1
|
local si = x - x0 + 1
|
||||||
local terblen = math.max(math.min(math.abs(nvals_terblen[nid]) * 4, 1.5), 0.5) - 0.5 -- terrain blend with smooth
|
local terblen = math.max(math.min(math.abs(nvals_terblen[ni2d]) * 4, 1.5), 0.5) - 0.5
|
||||||
local gradcen = GRADCEN + nvals_gradcen[nid] * CENAMP
|
local gradcen = GRADCEN + nvals_gradcen[ni2d] * CENAMP
|
||||||
if y > gradcen then
|
if y > gradcen then
|
||||||
grad = -((y - gradcen) / HIGRAD) ^ HEXP
|
grad = -((y - gradcen) / HIGRAD) ^ HEXP
|
||||||
else
|
else
|
||||||
grad = ((gradcen - y) / LOGRAD) ^ LEXP
|
grad = ((gradcen - y) / LOGRAD) ^ LEXP
|
||||||
end
|
end
|
||||||
if nvals_fault[ni] >= 0 then
|
if nvals_fault[ni] >= 0 then
|
||||||
density = (nvals_terrain[ni] + nvals_terralt[ni]) / 2 * (1 - terblen)
|
density = (nvals_terrain[ni] +
|
||||||
|
nvals_terralt[ni]) / 2 * (1 - terblen)
|
||||||
+ nvals_smooth[ni] * terblen + grad
|
+ nvals_smooth[ni] * terblen + grad
|
||||||
else
|
else
|
||||||
density = (nvals_terrain[ni] - nvals_terralt[ni]) / 2 * (1 - terblen)
|
density = (nvals_terrain[ni] -
|
||||||
|
nvals_terralt[ni]) / 2 * (1 - terblen)
|
||||||
- nvals_smooth[ni] * terblen + grad
|
- nvals_smooth[ni] * terblen + grad
|
||||||
end
|
end
|
||||||
if density > 0 and empty then -- if terrain and node empty
|
if density > 0 and empty then -- if terrain and node empty
|
||||||
@ -315,18 +362,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
stable[si] = false
|
stable[si] = false
|
||||||
end
|
end
|
||||||
ni = ni + 1
|
ni = ni + 1
|
||||||
nid = nid + 1
|
ni2d = ni2d + 1
|
||||||
vi = vi + 1
|
vi = vi + 1
|
||||||
end
|
end
|
||||||
nid = nid - 80
|
ni2d = ni2d - chulens
|
||||||
end
|
end
|
||||||
nid = nid + 80
|
ni2d = ni2d + chulens
|
||||||
end
|
end
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:set_lighting({day=0, night=0})
|
vm:set_lighting({day=0, night=0}) -- not "nolight" because mapgen does not run in all chunks
|
||||||
vm:calc_lighting()
|
vm:calc_lighting()
|
||||||
vm:write_to_map(data)
|
vm:write_to_map(data)
|
||||||
|
|
||||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||||
print ("[moonrealm] "..chugent.." ms")
|
print ("[moonrealm] "..chugent.." ms chunk ("..x0.." "..y0.." "..z0..")")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
29
license.txt
29
license.txt
@ -1,14 +1,25 @@
|
|||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
License of source code
|
||||||
Version 2, December 2004
|
----------------------
|
||||||
|
Copyright (C) 2014-2015 paramat
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
This program is distributed in the hope that it will be useful,
|
||||||
copies of this license document, and changing it is allowed as long
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
as the name is changed.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
You should have received a copy of the GNU Lesser General Public License along
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
License of media (textures)
|
||||||
|
---------------------------
|
||||||
|
Copyright (C) 2014-2015 paramat
|
||||||
|
|
||||||
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
|
43
nodes.lua
43
nodes.lua
@ -7,7 +7,7 @@ minetest.register_node("moonrealm:stone", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:ironore", {
|
minetest.register_node("moonrealm:ironore", {
|
||||||
description = "MR Iron Ore",
|
description = "Iron Ore",
|
||||||
tiles = {"moonrealm_stone.png^default_mineral_iron.png"},
|
tiles = {"moonrealm_stone.png^default_mineral_iron.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
@ -16,7 +16,7 @@ minetest.register_node("moonrealm:ironore", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:copperore", {
|
minetest.register_node("moonrealm:copperore", {
|
||||||
description = "MR Copper Ore",
|
description = "Copper Ore",
|
||||||
tiles = {"moonrealm_stone.png^default_mineral_copper.png"},
|
tiles = {"moonrealm_stone.png^default_mineral_copper.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
@ -25,7 +25,7 @@ minetest.register_node("moonrealm:copperore", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:goldore", {
|
minetest.register_node("moonrealm:goldore", {
|
||||||
description = "MR Gold Ore",
|
description = "Gold Ore",
|
||||||
tiles = {"moonrealm_stone.png^default_mineral_gold.png"},
|
tiles = {"moonrealm_stone.png^default_mineral_gold.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
@ -34,7 +34,7 @@ minetest.register_node("moonrealm:goldore", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:diamondore", {
|
minetest.register_node("moonrealm:diamondore", {
|
||||||
description = "MR Diamond Ore",
|
description = "Diamond Ore",
|
||||||
tiles = {"moonrealm_stone.png^default_mineral_diamond.png"},
|
tiles = {"moonrealm_stone.png^default_mineral_diamond.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
@ -42,6 +42,17 @@ minetest.register_node("moonrealm:diamondore", {
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("moonrealm:mese", {
|
||||||
|
description = "Mese Block",
|
||||||
|
tiles = {"moonrealm_mese.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 3,
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {cracky=1, level=2},
|
||||||
|
drop = "default:mese",
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:dust", {
|
minetest.register_node("moonrealm:dust", {
|
||||||
description = "Moon Dust",
|
description = "Moon Dust",
|
||||||
tiles = {"moonrealm_dust.png"},
|
tiles = {"moonrealm_dust.png"},
|
||||||
@ -135,7 +146,7 @@ minetest.register_node("moonrealm:waterice", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {cracky=3,melts=1},
|
groups = {cracky=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -194,7 +205,7 @@ minetest.register_node("moonrealm:soil", {
|
|||||||
description = "Moonsoil",
|
description = "Moonsoil",
|
||||||
tiles = {"moonrealm_soil.png"},
|
tiles = {"moonrealm_soil.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {crumbly=3, falling_node=1, soil=3},
|
groups = {crumbly=3},
|
||||||
drop = "moonrealm:dust",
|
drop = "moonrealm:dust",
|
||||||
sounds = default.node_sound_dirt_defaults(),
|
sounds = default.node_sound_dirt_defaults(),
|
||||||
})
|
})
|
||||||
@ -202,6 +213,7 @@ minetest.register_node("moonrealm:soil", {
|
|||||||
minetest.register_node("moonrealm:airlock", {
|
minetest.register_node("moonrealm:airlock", {
|
||||||
description = "Airlock",
|
description = "Airlock",
|
||||||
tiles = {"moonrealm_airlock.png"},
|
tiles = {"moonrealm_airlock.png"},
|
||||||
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
@ -211,18 +223,18 @@ minetest.register_node("moonrealm:airlock", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:glass", {
|
minetest.register_node("moonrealm:glass", {
|
||||||
description = "MR Glass",
|
description = "Glass",
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
tiles = {"default_obsidian_glass.png"},
|
tiles = {"default_obsidian_glass.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
groups = {cracky=3, oddly_breakable_by_hand=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("moonrealm:sapling", {
|
minetest.register_node("moonrealm:sapling", {
|
||||||
description = "MR Sapling",
|
description = "Sapling",
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
visual_scale = 1.0,
|
visual_scale = 1.0,
|
||||||
tiles = {"default_sapling.png"},
|
tiles = {"default_sapling.png"},
|
||||||
@ -231,7 +243,7 @@ minetest.register_node("moonrealm:sapling", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
groups = {snappy=2,dig_immediate=3,flammable=2},
|
groups = {snappy=2, dig_immediate=3, flammable=2},
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -256,9 +268,10 @@ minetest.register_node("moonrealm:appleleaf", {
|
|||||||
minetest.register_node("moonrealm:light", {
|
minetest.register_node("moonrealm:light", {
|
||||||
description = "Light",
|
description = "Light",
|
||||||
tiles = {"moonrealm_light.png"},
|
tiles = {"moonrealm_light.png"},
|
||||||
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=3,oddly_breakable_by_hand=3},
|
groups = {cracky=3, oddly_breakable_by_hand=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -324,25 +337,26 @@ minetest.register_node("moonrealm:shell", {
|
|||||||
tiles = {"moonrealm_shell.png"},
|
tiles = {"moonrealm_shell.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||||
|
drop = "",
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Items
|
-- Items
|
||||||
|
|
||||||
minetest.register_craftitem("moonrealm:spacesuit", {
|
minetest.register_craftitem("moonrealm:spacesuit", {
|
||||||
description = "MR Spacesuit",
|
description = "Spacesuit",
|
||||||
inventory_image = "moonrealm_spacesuit.png",
|
inventory_image = "moonrealm_spacesuit.png",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("moonrealm:helmet", {
|
minetest.register_craftitem("moonrealm:helmet", {
|
||||||
description = "MR Mesetint Helmet",
|
description = "Mesetint Helmet",
|
||||||
inventory_image = "moonrealm_helmet.png",
|
inventory_image = "moonrealm_helmet.png",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("moonrealm:lifesupport", {
|
minetest.register_craftitem("moonrealm:lifesupport", {
|
||||||
description = "MR Life Support",
|
description = "Life Support",
|
||||||
inventory_image = "moonrealm_lifesupport.png",
|
inventory_image = "moonrealm_lifesupport.png",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
@ -472,3 +486,4 @@ minetest.register_craft({
|
|||||||
recipe = "default:mese_crystal",
|
recipe = "default:mese_crystal",
|
||||||
burntime = 50,
|
burntime = 50,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
BIN
textures/moonrealm_mese.png
Normal file
BIN
textures/moonrealm_mese.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 B |
Loading…
x
Reference in New Issue
Block a user