Version MFF.
0
.gitignore
vendored
Normal file → Executable file
0
LazyJ-changelog.txt
Normal file → Executable file
0
changelog.txt
Normal file → Executable file
3
depends.txt
Normal file → Executable file
@ -1,5 +1,4 @@
|
|||||||
default
|
default
|
||||||
flowers?
|
flowers?
|
||||||
moreblocks?
|
moreblocks?
|
||||||
skins?
|
watershed?
|
||||||
treecapitator?
|
|
||||||
|
44
init.lua
Normal file → Executable file
@ -47,34 +47,43 @@ http://github.com/Splizard/minetest-mod-snow/
|
|||||||
-- Until something else can be figured out, use paramat's "Snowdrift" mod instead.
|
-- Until something else can be figured out, use paramat's "Snowdrift" mod instead.
|
||||||
-- dofile(modpath.."/falling_snow.lua")
|
-- dofile(modpath.."/falling_snow.lua")
|
||||||
|
|
||||||
local load_time_start = minetest.get_us_time()
|
|
||||||
|
|
||||||
|
|
||||||
-- Original init.lua File Broken into Smaller Files
|
-- Original init.lua File Broken into Smaller Files
|
||||||
local srcpath = minetest.get_modpath"snow".."/src/"
|
local modpath = minetest.get_modpath("snow")
|
||||||
dofile(srcpath.."abms.lua")
|
dofile(modpath.."/src/abms.lua")
|
||||||
dofile(srcpath.."aliases.lua")
|
dofile(modpath.."/src/aliases.lua")
|
||||||
dofile(srcpath.."crafting.lua")
|
dofile(modpath.."/src/crafting.lua")
|
||||||
|
|
||||||
|
|
||||||
-- The formspec menu didn't work when util.lua was the very first "dofile" so I moved
|
-- The formspec menu didn't work when util.lua was the very first "dofile" so I moved
|
||||||
-- it and all the other original "dofiles", in order, to the bottom of the list. ~ LazyJ
|
-- it and all the other original "dofiles", in order, to the bottom of the list. ~ LazyJ
|
||||||
-- Minetest would crash if the mapgen was called upon before the rest of other snow lua files so
|
-- Minetest would crash if the mapgen was called upon before the rest of other snow lua files so
|
||||||
-- I put it lower on the list and that seems to do the trick. ~ LazyJ
|
-- I put it lower on the list and that seems to do the trick. ~ LazyJ
|
||||||
dofile(srcpath.."util.lua")
|
dofile(modpath.."/src/util.lua")
|
||||||
dofile(srcpath.."snowball.lua")
|
dofile(modpath.."/src/snowball.lua")
|
||||||
-- To get Xmas tree saplings, the "christmas_content", true or false, in "util.lua" has to be determined first.
|
-- To get Xmas tree saplings, the "christmas_content", true or false, in "util.lua" has to be determined first.
|
||||||
-- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ
|
-- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ
|
||||||
dofile(srcpath.."nodes.lua")
|
dofile(modpath.."/src/nodes.lua")
|
||||||
dofile(srcpath.."mapgen.lua")
|
dofile(modpath.."/src/basic_stairs_slabs.lua")
|
||||||
dofile(srcpath.."sled.lua")
|
-- dofile(modpath.."/src/mapgen.lua")
|
||||||
dofile(srcpath.."falling_snow.lua")
|
dofile(modpath.."/src/sled.lua")
|
||||||
|
-- dofile(modpath.."/src/falling_snow.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Check for "MoreBlocks". If not found, skip this next "dofile".
|
||||||
|
|
||||||
|
if rawget(_G, "stairsplus")
|
||||||
|
and minetest.get_modpath("moreblocks") then
|
||||||
|
|
||||||
|
dofile(modpath.."/src/stairsplus.lua")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
local is_uneven
|
local is_uneven
|
||||||
--This function places snow checking at the same time for snow level and increasing as needed.
|
--This function places snow checking at the same time for snow level and increasing as needed.
|
||||||
--This also takes into account sourrounding snow and makes snow even.
|
--This also takes into account sourrounding snow and makes snow even.
|
||||||
function snow.place(pos)
|
function snow.place(pos)
|
||||||
|
if pos.y < -19000 then return end -- Don't put anything in the nether!
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
|
||||||
--Oops, maybe there is no node?
|
--Oops, maybe there is no node?
|
||||||
@ -189,12 +198,3 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
|
||||||
local msg = "[snow] loaded after ca. " .. time .. " seconds."
|
|
||||||
if time > 0.01 then
|
|
||||||
print(msg)
|
|
||||||
else
|
|
||||||
minetest.log("info", msg)
|
|
||||||
end
|
|
||||||
|
0
license.txt
Normal file → Executable file
0
models/sled.x
Normal file → Executable file
0
other_textures/connected_textures_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 656 B |
0
other_textures/default_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 82 B After Width: | Height: | Size: 82 B |
0
other_textures/default_ice.xcf
Normal file → Executable file
0
other_textures/inkscape_default_ice.svg
Normal file → Executable file
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
0
other_textures/mocha.png
Normal file → Executable file
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
0
other_textures/mocha.xcf
Normal file → Executable file
0
other_textures/original_snow_snow_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 300 B |
0
other_textures/rect2985.png
Normal file → Executable file
Before Width: | Height: | Size: 81 B After Width: | Height: | Size: 81 B |
0
other_textures/snow_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
0
other_textures/snow_needles_decorated_animated.xcf
Normal file → Executable file
0
other_textures/snow_snow.png
Normal file → Executable file
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 164 B |
0
other_textures/snow_snow_brick.xcf
Normal file → Executable file
0
other_textures/snow_snow_cobble.xcf
Normal file → Executable file
0
other_textures/snow_snow_side.png
Normal file → Executable file
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 726 B |
0
other_textures/snow_snowball.png
Normal file → Executable file
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
0
other_textures/snow_snowfall.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
0
other_textures/snow_star_lit.xcf
Normal file → Executable file
0
other_textures/xdefault_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B |
0
other_textures/xdefault_furnace_bottom.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_furnace_fire_bg.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
0
other_textures/xdefault_furnace_fire_fg.png
Normal file → Executable file
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
0
other_textures/xdefault_furnace_front.png
Normal file → Executable file
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 553 B |
0
other_textures/xdefault_furnace_front_active.png
Normal file → Executable file
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
0
other_textures/xdefault_furnace_side.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_furnace_top.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_glass.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
0
other_textures/xdefault_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
0
other_textures/xdefault_ice.xcf
Normal file → Executable file
0
other_textures/xdefault_snow.png
Normal file → Executable file
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 164 B |
0
other_textures/xdefault_stone_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 572 B |
6
readme.txt
Normal file → Executable file
@ -101,9 +101,3 @@ As admin you can use the /snow command in-game to make various changes.
|
|||||||
UNINSTALL:
|
UNINSTALL:
|
||||||
------------
|
------------
|
||||||
Simply delete the folder snow from the mods folder.
|
Simply delete the folder snow from the mods folder.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
— use the settingtypes.txt
|
|
||||||
— test if the fixed ground_y search works correctly at chunkcorners at ground level
|
|
||||||
|
0
schematics/pine.mts
Normal file → Executable file
29
src/abms.lua
Normal file → Executable file
@ -1,3 +1,16 @@
|
|||||||
|
--Backwards Compatability.
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"snow:snow1","snow:snow2","snow:snow3","gsnow4","snow:snow5","snow:snow6","snow:snow7","snow:snow8"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
minetest.add_node(pos, {name="default:snow"})
|
||||||
|
minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1))))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
|
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
@ -139,7 +152,7 @@ minetest.register_abm({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
--Grow Pine Saplings
|
--Grow Pine Saplings
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"snow:sapling_pine"},
|
nodenames = {"snow:sapling_pine"},
|
||||||
@ -158,21 +171,21 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
||||||
|
|
||||||
snow.make_pine(pos,false)
|
-- snow.make_pine(pos,false)
|
||||||
-- This finds the sapling under the grown tree. ~ LazyJ
|
-- This finds the sapling under the grown tree. ~ LazyJ
|
||||||
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
||||||
-- This switches the sapling to a tree trunk. ~ LazyJ
|
-- This switches the sapling to a tree trunk. ~ LazyJ
|
||||||
minetest.set_node(pos, {name="default:pinetree"})
|
minetest.set_node(pos, {name="default:pinetree"})
|
||||||
-- This is more for testing but it may be useful info to some admins when
|
-- This is more for testing but it may be useful info to some admins when
|
||||||
-- grepping the server logs too. ~ LazyJ
|
-- grepping the server logs too. ~ LazyJ
|
||||||
minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos))
|
minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
--Grow Christmas Tree Saplings
|
--Grow Christmas Tree Saplings
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"snow:xmas_tree"},
|
nodenames = {"snow:xmas_tree"},
|
||||||
@ -188,14 +201,14 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
||||||
|
|
||||||
snow.make_pine(pos,false,true)
|
--snow.make_pine(pos,false,true)
|
||||||
minetest.log("action", "A pine sapling grows into a Christmas tree at "..minetest.pos_to_string(pos)) -- ~ LazyJ
|
minetest.log("action", "A pine sapling grows into a Christmas tree at "..minetest.pos_to_string(pos)) -- ~ LazyJ
|
||||||
--else -- 'Else', if there isn't air in each of the 8 nodes above the sapling,
|
--else -- 'Else', if there isn't air in each of the 8 nodes above the sapling,
|
||||||
-- then don't anything; including not allowing the sapling to grow.
|
-- then don't anything; including not allowing the sapling to grow.
|
||||||
-- ~ LazyJ, 2014_04_10
|
-- ~ LazyJ, 2014_04_10
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
})
|
})]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4
src/aliases.lua
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
-- Some aliases for compatibility switches and some to make "/give" commands
|
-- Some aliases for compatibility switches and some to make "/give" commands
|
||||||
-- a little easier
|
-- a little easier
|
||||||
|
|
||||||
|
minetest.register_alias("snow:needles", "default:pine_needles")
|
||||||
minetest.register_alias("snow:snow", "default:snow")
|
minetest.register_alias("snow:snow", "default:snow")
|
||||||
minetest.register_alias("default_snow", "default:snow")
|
minetest.register_alias("default_snow", "default:snow")
|
||||||
minetest.register_alias("snow:snowball", "default:snow")
|
minetest.register_alias("snow:snowball", "default:snow")
|
||||||
@ -25,7 +26,8 @@ minetest.register_alias("icysnow", "snow:snow_cobble")
|
|||||||
minetest.register_alias("snowcobble", "snow:snow_cobble")
|
minetest.register_alias("snowcobble", "snow:snow_cobble")
|
||||||
minetest.register_alias("snowycobble", "snow:snow_cobble")
|
minetest.register_alias("snowycobble", "snow:snow_cobble")
|
||||||
minetest.register_alias("cobblesnow", "snow:snow_cobble")
|
minetest.register_alias("cobblesnow", "snow:snow_cobble")
|
||||||
|
minetest.register_alias("snow:leaves", "default:pine_needles")
|
||||||
|
minetest.register_alias("snow:sapling_pine", "default:pine_sapling")
|
||||||
|
|
||||||
-- To clean up my first stairsplus attempt.
|
-- To clean up my first stairsplus attempt.
|
||||||
-- Stair
|
-- Stair
|
||||||
|
0
src/basic_stairs_slabs.lua
Normal file → Executable file
0
src/crafting.lua
Normal file → Executable file
22
src/falling_snow.lua
Normal file → Executable file
@ -106,25 +106,7 @@ local function cold_perlin_test(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
v = minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=x, y=y}) >= rarity
|
v = minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=x, y=y}) >= rarity
|
||||||
|
cold_perl_values[y][x] = v
|
||||||
local em = ""
|
|
||||||
if type(x) ~= "number" then
|
|
||||||
em = em.. "x no number but "..type(x).." "
|
|
||||||
elseif x%1 ~= 0 then
|
|
||||||
em = em.. "x no integer but "..x.." "
|
|
||||||
end
|
|
||||||
if type(y) ~= "number" then
|
|
||||||
em = em.. "y no number but "..type(y).." "
|
|
||||||
elseif y%1 ~= 0 then
|
|
||||||
em = em.. "y no integer but "..y.." "
|
|
||||||
end
|
|
||||||
if em ~= "" then
|
|
||||||
error(em)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cold_perl_values[y] then
|
|
||||||
cold_perl_values[y][x] = v
|
|
||||||
end
|
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -238,7 +220,7 @@ end
|
|||||||
local lighter_snowfall = snow.lighter_snowfall
|
local lighter_snowfall = snow.lighter_snowfall
|
||||||
local function calc_snowfall()
|
local function calc_snowfall()
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local ppos = vector.round(player:getpos())
|
local ppos = player:getpos()
|
||||||
|
|
||||||
-- Make sure player is not in a cave/house...
|
-- Make sure player is not in a cave/house...
|
||||||
if get_snow(ppos)
|
if get_snow(ppos)
|
||||||
|
22
src/mapgen.lua
Normal file → Executable file
@ -197,25 +197,3 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
|
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- treecapitator support
|
|
||||||
if minetest.global_exists"treecapitator" then
|
|
||||||
treecapitator.register_tree{
|
|
||||||
trees = {"default:pine_tree"},
|
|
||||||
leaves = {"snow:needles"},
|
|
||||||
range = 1,
|
|
||||||
range_up = 2,
|
|
||||||
range_down = 3,
|
|
||||||
stem_height_min = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
treecapitator.register_tree{
|
|
||||||
trees = {"default:pine_tree"},
|
|
||||||
leaves = {"snow:needles_decorated"},
|
|
||||||
fruits = {"snow:star_lit", "snow:star"},
|
|
||||||
range = 1,
|
|
||||||
range_up = 3,
|
|
||||||
range_down = 3,
|
|
||||||
stem_height_min = 1,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
174
src/mapgen_v6.lua
Normal file → Executable file
@ -172,21 +172,6 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local perlin_objs, perlins_chulen
|
|
||||||
local function get_perlins(sidelen)
|
|
||||||
if perlins_chulen == sidelen then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
perlins_chulen = sidelen
|
|
||||||
local chulens = {x=sidelen, y=sidelen}
|
|
||||||
perlin_objs = {
|
|
||||||
default = minetest.get_perlin_map(np_default, chulens),
|
|
||||||
cold = minetest.get_perlin_map(np_cold, chulens),
|
|
||||||
ice = minetest.get_perlin_map(np_ice, chulens),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local nbuf_default, nbuf_cold, nbuf_ice
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
|
|
||||||
@ -209,9 +194,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local snow_tab,num = {},1
|
local snow_tab,num = {},1
|
||||||
local pines_tab,pnum = {},1
|
local pines_tab,pnum = {},1
|
||||||
|
|
||||||
get_perlins(x1 - x0 + 1)
|
local sidelen = x1 - x0 + 1
|
||||||
local nvals_default = perlin_objs.default:get2dMap_flat({x=x0+150, y=z0+50}, nbuf_default)
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
local nvals_cold, nvals_ice, ndia
|
local nvals_default = minetest.get_perlin_map(np_default, chulens):get2dMap_flat{x=x0+150, y=z0+50}
|
||||||
|
local nvals_cold, nvals_ice
|
||||||
|
|
||||||
-- Choose biomes
|
-- Choose biomes
|
||||||
local pr = PseudoRandom(seed+57)
|
local pr = PseudoRandom(seed+57)
|
||||||
@ -237,7 +223,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local in_biome = false
|
local in_biome = false
|
||||||
local test
|
local test
|
||||||
if nvals_default[ni] < 0.35 then
|
if nvals_default[ni] < 0.35 then
|
||||||
nvals_cold = nvals_cold or perlin_objs.cold:get2dMap_flat({x=x0, y=z0}, nbuf_cold)
|
if not nvals_cold then
|
||||||
|
nvals_cold = minetest.get_perlin_map(np_cold, chulens):get2dMap_flat{x=x0, y=z0}
|
||||||
|
end
|
||||||
test = math.min(nvals_cold[ni], 1)
|
test = math.min(nvals_cold[ni], 1)
|
||||||
if smooth then
|
if smooth then
|
||||||
if test >= smooth_rarity_max
|
if test >= smooth_rarity_max
|
||||||
@ -259,40 +247,41 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- remove trees near alpine
|
-- remove trees near alpine
|
||||||
local ground_y
|
local ground_y
|
||||||
if data[area:index(x, maxp.y, z)] == c.air then
|
if data[area:index(x, maxp.y, z)] == c.air then
|
||||||
local ytop = math.min(heightmap[ni]+20, maxp.y)
|
for y = math.min(heightmap[ni]+20, maxp.y), math.max(minp.y, heightmap[ni]-5), -1 do
|
||||||
local vi = area:index(x, ytop, z)
|
if data[area:index(x, y, z)] ~= c.air then
|
||||||
for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do
|
|
||||||
if data[vi] ~= c.air then
|
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ground_y then
|
if ground_y then
|
||||||
local vi = area:index(x, ground_y, z)
|
local vi = area:index(x, ground_y, z)
|
||||||
for _ = minp.y - 16, ground_y do
|
if data[vi] == c.leaves
|
||||||
local id = data[vi]
|
or data[vi] == c.jungleleaves then
|
||||||
if id == c.leaves
|
nodes_added = true
|
||||||
or id == c.jungleleaves
|
for y = ground_y, -16, -1 do
|
||||||
or id == c.tree
|
local vi = area:index(x, y, z)
|
||||||
or id == c.apple then
|
local id = data[vi]
|
||||||
data[vi] = c.air
|
if id ~= c.air then
|
||||||
nodes_added = true
|
if id == c.leaves
|
||||||
else
|
or id == c.jungleleaves
|
||||||
break
|
or id == c.tree
|
||||||
|
or id == c.apple then
|
||||||
|
data[vi] = c.air
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
nodes_added = true
|
||||||
|
write_to_map = true
|
||||||
if not nvals_ice then
|
if not nvals_ice then
|
||||||
nvals_ice = perlin_objs.ice:get2dMap_flat({x=x0, y=z0}, nbuf_ice)
|
nvals_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat{x=x0, y=z0}
|
||||||
|
|
||||||
nodes_added = true
|
|
||||||
write_to_map = true
|
|
||||||
end
|
end
|
||||||
local icetype = nvals_ice[ni]
|
local icetype = nvals_ice[ni]
|
||||||
local cool = icetype > 0 -- only spawns ice on edge of water
|
local cool = icetype > 0 -- only spawns ice on edge of water
|
||||||
@ -306,14 +295,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- avoid generating underground
|
-- avoid generating underground
|
||||||
if data[area:index(x, maxp.y, z)] == c.air then
|
if data[area:index(x, maxp.y, z)] == c.air then
|
||||||
-- search for non air node from 20 m above ground down to 5 m below ground (confined by minp and maxp)
|
-- search for non air node from 20 m above ground down to 5 m below ground (confined by minp and maxp)
|
||||||
local ytop = math.min(heightmap[ni]+20, maxp.y)
|
for y = math.min(heightmap[ni]+20, maxp.y), math.max(minp.y, heightmap[ni]-5), -1 do
|
||||||
local vi = area:index(x, ytop, z)
|
if data[area:index(x, y, z)] ~= c.air then
|
||||||
for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do
|
|
||||||
if data[vi] ~= c.air then
|
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -327,13 +313,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
-- generate stone ground
|
-- generate stone ground
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = ground_y, math.max(-6, minp.y-6), -1 do
|
||||||
for _ = math.max(-6, minp.y-6), ground_y do
|
local vi = area:index(x, y, z)
|
||||||
if data[vi] == c.stone then
|
if data[vi] == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.stone
|
data[vi] = c.stone
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
elseif pines
|
elseif pines
|
||||||
and pr:next(1,36) == 1 then
|
and pr:next(1,36) == 1 then
|
||||||
@ -358,21 +343,26 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if not icesheet
|
if not icesheet
|
||||||
and not icecave
|
and not icecave
|
||||||
and not icehole then
|
and not icehole then
|
||||||
local y = data[node - area.ystride]
|
local nds = {
|
||||||
local ice = y ~= c.water and y ~= c.ice
|
data[area:index(x+1, ground_y, z)],
|
||||||
|
data[area:index(x, ground_y, z+1)],
|
||||||
|
data[area:index(x+1, ground_y, z+1)],
|
||||||
|
data[area:index(x-1, ground_y, z-1)],
|
||||||
|
data[area:index(x-1, ground_y, z)],
|
||||||
|
data[area:index(x, ground_y, z-1)],
|
||||||
|
}
|
||||||
|
local ice
|
||||||
|
if pr:next(1,4) == 1
|
||||||
|
and (cool or icebergs) then
|
||||||
|
for _,i in ipairs(nds) do
|
||||||
|
if i == c.ice then
|
||||||
|
ice = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if not ice then
|
if not ice then
|
||||||
ndia = ndia or {
|
for _,i in ipairs(nds) do
|
||||||
area.zstride - 1,
|
|
||||||
1,
|
|
||||||
-2*area.zstride - 2,
|
|
||||||
area.zstride,
|
|
||||||
1 - area.zstride,
|
|
||||||
0
|
|
||||||
}
|
|
||||||
local vi = node + 1
|
|
||||||
for n = 1,6 do
|
|
||||||
local i = data[vi]
|
|
||||||
if i ~= c.water
|
if i ~= c.water
|
||||||
and i ~= c.ice
|
and i ~= c.ice
|
||||||
and i ~= c.air
|
and i ~= c.air
|
||||||
@ -380,24 +370,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
ice = true
|
ice = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi + ndia[n]
|
|
||||||
end
|
|
||||||
|
|
||||||
if not ice
|
|
||||||
and (cool or icebergs)
|
|
||||||
and pr:next(1,4) == 1 then
|
|
||||||
|
|
||||||
local vi = node + 1
|
|
||||||
for i = 1,6 do
|
|
||||||
if data[vi] == c.ice then
|
|
||||||
ice = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
vi = vi + ndia[i]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local y = data[area:index(x, ground_y-1, z)]
|
||||||
if ice
|
if ice
|
||||||
|
or (y ~= c.water and y ~= c.ice) -- and y ~= "air") …I don't think y can be a string here ~HybridDog
|
||||||
or (icebergs and pr:next(1,6) == 1) then
|
or (icebergs and pr:next(1,6) == 1) then
|
||||||
data[node] = c.ice
|
data[node] = c.ice
|
||||||
end
|
end
|
||||||
@ -408,13 +385,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[node] = c.ice
|
data[node] = c.ice
|
||||||
end
|
end
|
||||||
if icecave then
|
if icecave then
|
||||||
local vi = area:index(x, ground_y-1, z)
|
for y = ground_y-1, -33, -1 do
|
||||||
for _ = math.max(minp.y-16, -33), ground_y-1 do
|
local vi = area:index(x, y, z)
|
||||||
if data[vi] ~= c.water then
|
if data[vi] ~= c.water then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.air
|
data[vi] = c.air
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if icesheet then
|
if icesheet then
|
||||||
@ -433,23 +409,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
-- replace papyrus plants with snowblocks
|
-- replace papyrus plants with snowblocks
|
||||||
local vi = area:index(x, ground_y, z)
|
local y = ground_y
|
||||||
for _ = 1,7 do
|
for _ = 1,7 do
|
||||||
if data[vi] ~= c.papyrus then
|
local vi = area:index(x, y, z)
|
||||||
|
if data[vi] == c.papyrus then
|
||||||
|
data[vi] = c.snow_block
|
||||||
|
y = y-1
|
||||||
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.snow_block
|
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
elseif alpine then
|
elseif alpine then
|
||||||
-- make stone pillars out of trees and other stuff
|
-- make stone pillars out of trees and other stuff
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = ground_y, math.max(-6, minp.y-6), -1 do
|
||||||
for _ = 0, ground_y - math.max(-6, minp.y-6) do
|
local stone = area:index(x, y, z)
|
||||||
if data[vi] == c.stone then
|
if data[stone] == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.stone
|
data[stone] = c.stone
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
-- put snow onto it
|
-- put snow onto it
|
||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
@ -460,8 +437,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
end
|
end
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = 0, 12 do
|
||||||
for _ = 0, 12 do
|
y = ground_y-y
|
||||||
|
local vi = area:index(x, y, z)
|
||||||
local nd = data[vi]
|
local nd = data[vi]
|
||||||
local plantlike = is_plantlike(nd)
|
local plantlike = is_plantlike(nd)
|
||||||
if replacements[nd] then
|
if replacements[nd] then
|
||||||
@ -473,7 +451,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[vi] = c.dirt_with_snow
|
data[vi] = c.dirt_with_snow
|
||||||
break
|
break
|
||||||
elseif plantlike then
|
elseif plantlike then
|
||||||
local under = vi - area.ystride
|
local under = area:index(x, y-1, z)
|
||||||
if data[under] == c.dirt_with_grass then
|
if data[under] == c.dirt_with_grass then
|
||||||
-- replace other plants with shrubs
|
-- replace other plants with shrubs
|
||||||
data[vi] = c.snow_shrub
|
data[vi] = c.snow_shrub
|
||||||
@ -484,7 +462,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
elseif nd == c.stone then
|
elseif nd == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -498,14 +475,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- try to fix oom memory crashes
|
||||||
|
minetest.after(0, collectgarbage)
|
||||||
|
|
||||||
if num ~= 1 then
|
if num ~= 1 then
|
||||||
for i = 1, num-1 do
|
for _,i in pairs(snow_tab) do
|
||||||
i = snow_tab[i]
|
|
||||||
-- set snow
|
-- set snow
|
||||||
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
||||||
end
|
end
|
||||||
for i = 1, num-1 do
|
for _,i in pairs(snow_tab) do
|
||||||
i = snow_tab[i]
|
|
||||||
local y,z,x,test = unpack(i)
|
local y,z,x,test = unpack(i)
|
||||||
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
||||||
if test > 0 then
|
if test > 0 then
|
||||||
@ -550,8 +528,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if pines
|
if pines
|
||||||
and pnum ~= 1 then
|
and pnum ~= 1 then
|
||||||
local spawn_pine = snow.voxelmanip_pine
|
local spawn_pine = snow.voxelmanip_pine
|
||||||
for i = 1, pnum-1 do
|
for _,pos in pairs(pines_tab) do
|
||||||
spawn_pine(pines_tab[i], area, data)
|
spawn_pine(pos, area, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
0
src/mapgen_v7.lua
Normal file → Executable file
141
src/nodes.lua
Normal file → Executable file
@ -13,11 +13,6 @@ local nodedef = {
|
|||||||
drop = {
|
drop = {
|
||||||
max_items = 1,
|
max_items = 1,
|
||||||
items = {
|
items = {
|
||||||
{
|
|
||||||
-- player will get sapling with 1/20 chance
|
|
||||||
items = {'snow:sapling_pine'},
|
|
||||||
rarity = 20,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
items = {'snow:needles'},
|
items = {'snow:needles'},
|
||||||
}
|
}
|
||||||
@ -32,15 +27,15 @@ If christmas_content is enabled, then this next part will override the pine need
|
|||||||
The Xmas tree needles are registred and defined a farther down in this nodes.lua file.
|
The Xmas tree needles are registred and defined a farther down in this nodes.lua file.
|
||||||
|
|
||||||
~ LazyJ
|
~ LazyJ
|
||||||
]]
|
|
||||||
if snow.christmas_content then
|
if snow.christmas_content then
|
||||||
table.insert(nodedef.drop.items, 1, {
|
table.insert(nodedef.drop.items, 1, {
|
||||||
-- player will get xmas tree with 1/120 chance
|
-- player will get xmas tree with 1/120 chance
|
||||||
items = {"snow:xmas_tree"},
|
items = {'snow:xmas_tree'},
|
||||||
rarity = 120,
|
rarity = 120,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
minetest.register_node("snow:needles", table.copy(nodedef))
|
minetest.register_node("snow:needles", table.copy(nodedef))
|
||||||
|
|
||||||
snow.register_on_configuring(function(name, v)
|
snow.register_on_configuring(function(name, v)
|
||||||
@ -85,7 +80,7 @@ nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
|
|||||||
minetest.register_node("snow:needles_decorated", nodedef)
|
minetest.register_node("snow:needles_decorated", nodedef)
|
||||||
|
|
||||||
|
|
||||||
-- Saplings
|
--[[ Saplings
|
||||||
|
|
||||||
nodedef = {
|
nodedef = {
|
||||||
description = "Pine Sapling",
|
description = "Pine Sapling",
|
||||||
@ -111,7 +106,7 @@ nodedef.inventory_image = "snow_xmas_tree.png"
|
|||||||
nodedef.wield_image = "snow_xmas_tree.png"
|
nodedef.wield_image = "snow_xmas_tree.png"
|
||||||
|
|
||||||
minetest.register_node("snow:xmas_tree", nodedef)
|
minetest.register_node("snow:xmas_tree", nodedef)
|
||||||
|
]]
|
||||||
|
|
||||||
nodedef = {
|
nodedef = {
|
||||||
description = "Star",
|
description = "Star",
|
||||||
@ -137,7 +132,7 @@ minetest.register_node("snow:star", table.copy(nodedef))
|
|||||||
|
|
||||||
-- Star (Lit Version) on Xmas Trees
|
-- Star (Lit Version) on Xmas Trees
|
||||||
nodedef.description = nodedef.description.." Lighted"
|
nodedef.description = nodedef.description.." Lighted"
|
||||||
nodedef.light_source = LIGHT_MAX
|
nodedef.light_source = default.LIGHT_MAX
|
||||||
nodedef.tiles = {"snow_star_lit.png"}
|
nodedef.tiles = {"snow_star_lit.png"}
|
||||||
nodedef.drop = "snow:star"
|
nodedef.drop = "snow:star"
|
||||||
nodedef.groups.not_in_creative_inventory = 1
|
nodedef.groups.not_in_creative_inventory = 1
|
||||||
@ -335,12 +330,16 @@ minetest.register_node("snow:snow_cobble", nodedef)
|
|||||||
|
|
||||||
-- Override Default Nodes to Add Extra Functions
|
-- Override Default Nodes to Add Extra Functions
|
||||||
|
|
||||||
|
-- This adds code to the existing default ice. ~ LazyJ
|
||||||
minetest.override_item("default:ice", {
|
minetest.override_item("default:ice", {
|
||||||
use_texture_alpha = true,
|
-- The Lines: 1. Alpah to make semi-transparent ice, 2 to work with
|
||||||
param2 = 0, --param2 is reserved for how much ice will freezeover.
|
-- the dirt_with_grass/snow/just dirt ABMs. ~ LazyJ, 2014_03_09
|
||||||
sunlight_propagates = true, -- necessary for dirt_with_grass/snow/just dirt ABMs
|
use_texture_alpha = true, -- 1
|
||||||
|
param2 = 0,
|
||||||
|
--param2 is reserved for how much ice will freezeover.
|
||||||
|
sunlight_propagates = true, -- 2
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
inventory_image = minetest.inventorycube"default_ice.png".."^[brighten",
|
inventory_image = minetest.inventorycube("default_ice.png").."^[brighten",
|
||||||
liquidtype = "none",
|
liquidtype = "none",
|
||||||
-- I made this a lot harder to dig than snow blocks because ice is much more dense
|
-- I made this a lot harder to dig than snow blocks because ice is much more dense
|
||||||
-- and solid than fluffy snow. ~ LazyJ
|
-- and solid than fluffy snow. ~ LazyJ
|
||||||
@ -354,11 +353,12 @@ minetest.override_item("default:ice", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- This adds code to the existing, default snowblock. ~ LazyJ
|
||||||
minetest.override_item("default:snowblock", {
|
minetest.override_item("default:snowblock", {
|
||||||
-- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
liquidtype = "none", -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
liquidtype = "none",
|
paramtype = "light", -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
paramtype = "light",
|
sunlight_propagates = true, -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
sunlight_propagates = true,
|
|
||||||
-- Snow blocks should be easy to dig because they are just fluffy snow. ~ LazyJ
|
-- Snow blocks should be easy to dig because they are just fluffy snow. ~ LazyJ
|
||||||
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=1, icemaker=1, cooks_into_ice=1, falling_node=1},
|
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=1, icemaker=1, cooks_into_ice=1, falling_node=1},
|
||||||
--drop = "snow:snow_cobble",
|
--drop = "snow:snow_cobble",
|
||||||
@ -366,106 +366,3 @@ minetest.override_item("default:snowblock", {
|
|||||||
-- Thinking in terms of layers, dirt_with_snow could also double as
|
-- Thinking in terms of layers, dirt_with_snow could also double as
|
||||||
-- dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ, 2014_04_04
|
-- dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ, 2014_04_04
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.override_item("default:snow", {
|
|
||||||
drop = {
|
|
||||||
max_items = 2,
|
|
||||||
items = {
|
|
||||||
{items = {'snow:moss'}, rarity = 20,},
|
|
||||||
{items = {'default:snow'},}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
leveled = 7,
|
|
||||||
node_box = {
|
|
||||||
type = "leveled",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, falling_node=1, melts=2, float=1},
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = true,
|
|
||||||
node_placement_prediction = "",
|
|
||||||
on_construct = function(pos)
|
|
||||||
pos.y = pos.y-1
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
if node.name == "default:dirt_with_grass"
|
|
||||||
or node.name == "default:dirt" then
|
|
||||||
node.name = "default:dirt_with_snow"
|
|
||||||
minetest.set_node(pos, node)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
--Handle node drops due to node level.
|
|
||||||
on_dig = function(pos, node, digger)
|
|
||||||
local level = minetest.get_node_level(pos)
|
|
||||||
minetest.node_dig(pos, node, digger)
|
|
||||||
if minetest.get_node(pos).name ~= node.name then
|
|
||||||
local inv = digger:get_inventory()
|
|
||||||
if not inv then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local left = inv:add_item("main", "default:snow "..tostring(level/7-1))
|
|
||||||
if not left:is_empty() then
|
|
||||||
minetest.add_item({
|
|
||||||
x = pos.x + math.random()/2-0.25,
|
|
||||||
y = pos.y + math.random()/2-0.25,
|
|
||||||
z = pos.z + math.random()/2-0.25,
|
|
||||||
}, left)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
--Manage snow levels.
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
local under = pointed_thing.under
|
|
||||||
local oldnode_under = minetest.get_node_or_nil(under)
|
|
||||||
local above = pointed_thing.above
|
|
||||||
|
|
||||||
if not oldnode_under
|
|
||||||
or not above then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
|
|
||||||
olddef_under = olddef_under or minetest.nodedef_default
|
|
||||||
|
|
||||||
local place_to
|
|
||||||
-- If node under is buildable_to, place into it instead (eg. snow)
|
|
||||||
if olddef_under.buildable_to then
|
|
||||||
place_to = under
|
|
||||||
else
|
|
||||||
-- Place above pointed node
|
|
||||||
place_to = above
|
|
||||||
end
|
|
||||||
|
|
||||||
local level = minetest.get_node_level(place_to)
|
|
||||||
if level == 63 then
|
|
||||||
minetest.set_node(place_to, {name="default:snowblock"})
|
|
||||||
else
|
|
||||||
minetest.set_node_level(place_to, level+7)
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(place_to).name ~= "default:snow" then
|
|
||||||
local itemstack, placed = minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
||||||
return itemstack, placed
|
|
||||||
end
|
|
||||||
|
|
||||||
itemstack:take_item()
|
|
||||||
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
on_use = snow.shoot_snowball
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Do stairs files
|
|
||||||
|
|
||||||
local path = minetest.get_modpath"snow".."/src/"
|
|
||||||
|
|
||||||
dofile(path.."basic_stairs_slabs.lua")
|
|
||||||
|
|
||||||
if minetest.global_exists"stairsplus"
|
|
||||||
and minetest.get_modpath"moreblocks" then
|
|
||||||
dofile(path.."stairsplus.lua")
|
|
||||||
end
|
|
||||||
|
0
src/sled.lua
Normal file → Executable file
108
src/snowball.lua
Normal file → Executable file
@ -6,13 +6,13 @@
|
|||||||
-- Quite a bit of trial-and-error learning here and it boiled down to a
|
-- Quite a bit of trial-and-error learning here and it boiled down to a
|
||||||
-- small handful of code lines making the difference. ~ LazyJ
|
-- small handful of code lines making the difference. ~ LazyJ
|
||||||
|
|
||||||
local creative_mode = minetest.settings:get_bool"creative_mode"
|
local creative_mode = minetest.setting_getbool("creative_mode")
|
||||||
|
|
||||||
|
|
||||||
local snowball_velocity, entity_attack_delay
|
local snowball_velocity, entity_attack_delay
|
||||||
local function update_snowball_vel(v)
|
local function update_snowball_vel(v)
|
||||||
snowball_velocity = v
|
snowball_velocity = v
|
||||||
local walkspeed = tonumber(minetest.settings:get"movement_speed_walk") or 4
|
local walkspeed = tonumber(minetest.setting_get("movement_speed_walk")) or 4
|
||||||
entity_attack_delay = (walkspeed+1)/v
|
entity_attack_delay = (walkspeed+1)/v
|
||||||
end
|
end
|
||||||
update_snowball_vel(snow.snowball_velocity)
|
update_snowball_vel(snow.snowball_velocity)
|
||||||
@ -27,14 +27,14 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function get_gravity()
|
local function get_gravity()
|
||||||
local grav = tonumber(minetest.settings:get"movement_gravity") or 9.81
|
local grav = tonumber(minetest.setting_get("movement_gravity")) or 9.81
|
||||||
return grav*snowball_gravity
|
return grav*snowball_gravity
|
||||||
end
|
end
|
||||||
|
|
||||||
local someone_throwing, just_acitvated
|
local someone_throwing, just_acitvated
|
||||||
|
|
||||||
--Shoot snowball
|
--Shoot snowball
|
||||||
function snow.shoot_snowball(item, player)
|
local function snow_shoot_snowball(item, player)
|
||||||
local addp = {y = 1.625} -- + (math.random()-0.5)/5}
|
local addp = {y = 1.625} -- + (math.random()-0.5)/5}
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
||||||
@ -64,7 +64,7 @@ if creative_mode then
|
|||||||
local item = player:get_wielded_item()
|
local item = player:get_wielded_item()
|
||||||
local itemname = item:get_name()
|
local itemname = item:get_name()
|
||||||
if itemname == "default:snow" then
|
if itemname == "default:snow" then
|
||||||
snow.shoot_snowball(nil, player)
|
snow_shoot_snowball(nil, player)
|
||||||
active = true
|
active = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -174,11 +174,10 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||||||
end
|
end
|
||||||
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
||||||
if v ~= self.object then
|
if v ~= self.object then
|
||||||
local entity_name = v:get_luaentity().name
|
local entity_name = v:get_entity_name()
|
||||||
if v:is_player()
|
if entity_name ~= "snow:snowball_entity"
|
||||||
or (entity_name ~= "snow:snowball_entity"
|
|
||||||
and entity_name ~= "__builtin:item"
|
and entity_name ~= "__builtin:item"
|
||||||
and entity_name ~= "gauges:hp_bar") then
|
and entity_name ~= "gauges:hp_bar" then
|
||||||
local vvel = v:getvelocity() or v:get_player_velocity()
|
local vvel = v:getvelocity() or v:get_player_velocity()
|
||||||
local veldif = self.object:getvelocity()
|
local veldif = self.object:getvelocity()
|
||||||
if vvel then
|
if vvel then
|
||||||
@ -252,6 +251,97 @@ minetest.register_node(":default:snow", {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.override_item("default:snow", {
|
||||||
|
drop = {
|
||||||
|
max_items = 2,
|
||||||
|
items = {
|
||||||
|
{items = {'snow:moss'}, rarity = 20,},
|
||||||
|
{items = {'default:snow'},}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
leveled = 7,
|
||||||
|
node_box = {
|
||||||
|
type = "leveled",
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, falling_node=1, melts=2, float=1},
|
||||||
|
sunlight_propagates = true,
|
||||||
|
--Disable placement prediction for snow.
|
||||||
|
node_placement_prediction = "",
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y-1
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name == "default:dirt_with_grass"
|
||||||
|
or node.name == "default:dirt" then
|
||||||
|
node.name = "default:dirt_with_snow"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
--Handle node drops due to node level.
|
||||||
|
on_dig = function(pos, node, digger)
|
||||||
|
local level = minetest.get_node_level(pos)
|
||||||
|
minetest.node_dig(pos, node, digger)
|
||||||
|
if minetest.get_node(pos).name ~= node.name then
|
||||||
|
local inv = digger:get_inventory()
|
||||||
|
if not inv then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local left = inv:add_item("main", "default:snow "..tostring(level/7-1))
|
||||||
|
if not left:is_empty() then
|
||||||
|
minetest.add_item({
|
||||||
|
x = pos.x + math.random()/2-0.25,
|
||||||
|
y = pos.y + math.random()/2-0.25,
|
||||||
|
z = pos.z + math.random()/2-0.25,
|
||||||
|
}, left)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
--Manage snow levels.
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
local under = pointed_thing.under
|
||||||
|
local oldnode_under = minetest.get_node_or_nil(under)
|
||||||
|
local above = pointed_thing.above
|
||||||
|
|
||||||
|
if not oldnode_under
|
||||||
|
or not above then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
|
||||||
|
olddef_under = olddef_under or minetest.nodedef_default
|
||||||
|
|
||||||
|
local place_to
|
||||||
|
-- If node under is buildable_to, place into it instead (eg. snow)
|
||||||
|
if olddef_under.buildable_to then
|
||||||
|
place_to = under
|
||||||
|
else
|
||||||
|
-- Place above pointed node
|
||||||
|
place_to = above
|
||||||
|
end
|
||||||
|
|
||||||
|
local level = minetest.get_node_level(place_to)
|
||||||
|
if level == 63 then
|
||||||
|
minetest.set_node(place_to, {name="default:snowblock"})
|
||||||
|
else
|
||||||
|
minetest.set_node_level(place_to, level+7)
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(place_to).name ~= "default:snow" then
|
||||||
|
local itemstack, placed = minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
|
return itemstack, placed
|
||||||
|
end
|
||||||
|
|
||||||
|
itemstack:take_item()
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
|
on_use = snow_shoot_snowball
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
A note about default torches, melting, and "buildable_to = true" in default snow.
|
A note about default torches, melting, and "buildable_to = true" in default snow.
|
||||||
|
|
||||||
|
12
src/stairsplus.lua
Normal file → Executable file
@ -36,7 +36,7 @@ There is one in each of the "stairsplus.register_all" sections.
|
|||||||
|
|
||||||
-- Check for infinite stacks
|
-- Check for infinite stacks
|
||||||
|
|
||||||
--if minetest.get_modpath("unified_inventory") or not minetest.settigetbool("creative_mode") then
|
--if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
|
||||||
-- snow_stairsplus.expect_infinite_stacks = false
|
-- snow_stairsplus.expect_infinite_stacks = false
|
||||||
--else
|
--else
|
||||||
-- snow_stairsplus.expect_infinite_stacks = true
|
-- snow_stairsplus.expect_infinite_stacks = true
|
||||||
@ -50,9 +50,12 @@ There is one in each of the "stairsplus.register_all" sections.
|
|||||||
-- First, let's run a check to see if MoreBlocks is installed; we're going to need it for the
|
-- First, let's run a check to see if MoreBlocks is installed; we're going to need it for the
|
||||||
-- next section of stairsplus stuff. ~LazyJ
|
-- next section of stairsplus stuff. ~LazyJ
|
||||||
|
|
||||||
|
if (minetest.get_modpath("moreblocks"))
|
||||||
|
and rawget(_G, "stairsplus")
|
||||||
|
|
||||||
-- 'If' MoreBlocks was found and stairsplus is available, well, 'then' go ahead with this next part:
|
-- 'If' MoreBlocks was found and stairsplus is available, well, 'then' go ahead with this next part:
|
||||||
|
|
||||||
|
then
|
||||||
|
|
||||||
--[[ Leave commented out - For reference only. ~ LazyJ
|
--[[ Leave commented out - For reference only. ~ LazyJ
|
||||||
function stairsplus.register_all(modname, subname, recipeitem, fields)
|
function stairsplus.register_all(modname, subname, recipeitem, fields)
|
||||||
@ -271,6 +274,7 @@ for _, name in pairs(snow_nodes) do
|
|||||||
|
|
||||||
stairsplus:register_all("moreblocks", name, nodename, {
|
stairsplus:register_all("moreblocks", name, nodename, {
|
||||||
description = ndef.description,
|
description = ndef.description,
|
||||||
|
drop = ndef.drop,
|
||||||
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=2, icemaker=1},
|
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=2, icemaker=1},
|
||||||
tiles = ndef.tiles,
|
tiles = ndef.tiles,
|
||||||
--paramtype2 = "facedir",
|
--paramtype2 = "facedir",
|
||||||
@ -332,7 +336,7 @@ for _, name in pairs(snow_nodes) do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- from clear up at the top, the MoreBlocks check. "Else", if MoreBlocks wasn't found, skip
|
else -- from clear up at the top, the MoreBlocks check. "Else", if MoreBlocks wasn't found, skip
|
||||||
-- down to here, "return" nothing and "end" this script. ~ LazyJ
|
-- down to here, "return" nothing and "end" this script. ~ LazyJ
|
||||||
|
return
|
||||||
|
end
|
||||||
|
6
src/util.lua
Normal file → Executable file
@ -103,8 +103,9 @@ do
|
|||||||
--Create config file.
|
--Create config file.
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
io.close(file)
|
||||||
config = {}
|
config = {}
|
||||||
for line in file:lines() do
|
for line in io.lines(path) do
|
||||||
if line:sub(1,1) ~= "#" then
|
if line:sub(1,1) ~= "#" then
|
||||||
local i, v = line:match("^(%S*) = (%S*)")
|
local i, v = line:match("^(%S*) = (%S*)")
|
||||||
if i and v then
|
if i and v then
|
||||||
@ -112,7 +113,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
io.close(file)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if config then
|
if config then
|
||||||
@ -132,7 +132,7 @@ end
|
|||||||
|
|
||||||
for i,v in pairs(snow) do
|
for i,v in pairs(snow) do
|
||||||
if allowed_types[type(v)] then
|
if allowed_types[type(v)] then
|
||||||
local v = minetest.settings:get("snow_"..i)
|
local v = minetest.setting_get("snow_"..i)
|
||||||
if v ~= nil then
|
if v ~= nil then
|
||||||
snow[i] = value_from_string(v)
|
snow[i] = value_from_string(v)
|
||||||
end
|
end
|
||||||
|
0
textures/character_snow_man.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
textures/character_snow_man_preview.png
Normal file → Executable file
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
0
textures/character_snow_man_preview_back.png
Normal file → Executable file
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 211 B |
0
textures/snow_apple.png
Normal file → Executable file
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
0
textures/snow_dandelion_white.png
Normal file → Executable file
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 122 B |
0
textures/snow_dandelion_yellow.png
Normal file → Executable file
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
0
textures/snow_geranium.png
Normal file → Executable file
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
0
textures/snow_ice_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 665 B After Width: | Height: | Size: 665 B |
0
textures/snow_leaves.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
0
textures/snow_moss.png
Normal file → Executable file
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |
0
textures/snow_needles.png
Normal file → Executable file
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 660 B |
0
textures/snow_needles_decorated.png
Normal file → Executable file
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 884 B |
0
textures/snow_needles_decorated_animated.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
textures/snow_rose.png
Normal file → Executable file
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
0
textures/snow_sapling_pine.png
Normal file → Executable file
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 272 B |
0
textures/snow_shrub.png
Normal file → Executable file
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
0
textures/snow_shrub_covering.png
Normal file → Executable file
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 297 B |
0
textures/snow_sled.png
Normal file → Executable file
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
0
textures/snow_snow_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 484 B |
0
textures/snow_snow_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
0
textures/snow_star.png
Normal file → Executable file
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
0
textures/snow_star_lit.png
Normal file → Executable file
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 302 B |
0
textures/snow_tulip.png
Normal file → Executable file
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 124 B |
0
textures/snow_viola.png
Normal file → Executable file
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 117 B |
0
textures/snow_xmas_tree.png
Normal file → Executable file
Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 299 B |
0
textures/weather_snow.png
Normal file → Executable file
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 588 B |