1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-09-27 23:10:33 +02:00

Updated snow mod

- New textures, and many new nodes
This commit is contained in:
LeMagnesium 2015-06-20 20:26:36 +02:00
parent f29ea87d00
commit 986ee7e7ad
25 changed files with 761 additions and 683 deletions

View File

@ -1,3 +1,3 @@
default default
flowers?
moreblocks? moreblocks?
technic_worldgen?

View File

@ -50,7 +50,6 @@ http://github.com/Splizard/minetest-mod-snow/
-- Original init.lua File Broken into Smaller Files -- Original init.lua File Broken into Smaller Files
dofile(minetest.get_modpath("snow").."/src/abms.lua") dofile(minetest.get_modpath("snow").."/src/abms.lua")
dofile(minetest.get_modpath("snow").."/src/aliases.lua") dofile(minetest.get_modpath("snow").."/src/aliases.lua")
dofile(minetest.get_modpath("snow").."/src/basic_stairs_slabs.lua")
dofile(minetest.get_modpath("snow").."/src/crafting.lua") dofile(minetest.get_modpath("snow").."/src/crafting.lua")
dofile(minetest.get_modpath("snow").."/src/snowball.lua") dofile(minetest.get_modpath("snow").."/src/snowball.lua")
@ -63,6 +62,7 @@ dofile(minetest.get_modpath("snow").."/src/util.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(minetest.get_modpath("snow").."/src/nodes.lua") dofile(minetest.get_modpath("snow").."/src/nodes.lua")
dofile(minetest.get_modpath("snow").."/src/basic_stairs_slabs.lua")
dofile(minetest.get_modpath("snow").."/src/mapgen.lua") dofile(minetest.get_modpath("snow").."/src/mapgen.lua")
dofile(minetest.get_modpath("snow").."/src/sled.lua") dofile(minetest.get_modpath("snow").."/src/sled.lua")
-- dofile(minetest.get_modpath("snow").."/src/falling_snow.lua") -- dofile(minetest.get_modpath("snow").."/src/falling_snow.lua")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

View File

@ -4,7 +4,7 @@ minetest.register_abm({
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
minetest.add_node(pos,{name="default:snow"}) minetest.add_node(pos, {name="default:snow"})
minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1)))) minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1))))
end, end,
}) })
@ -42,15 +42,17 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:melts"}, nodenames = {"group:melts"},
neighbors = {"group:igniter","default:torch","default:furnace_active","group:hot"}, neighbors = {"group:igniter", "default:torch", "default:furnace_active", "group:hot"},
interval = 2, interval = 10,
chance = 2, chance = 2,
action = function(pos, node) action = function(pos, node)
local intensity = minetest.get_item_group(node.name,"melts") local intensity = minetest.get_item_group(node.name,"melts")
if intensity == 1 then if intensity == 1 then
minetest.add_node(pos,{name="default:water_source"}) minetest.set_node(pos, {name="default:water_source"})
elseif intensity == 2 then elseif intensity == 2 then
minetest.add_node(pos,{name="default:water_flowing", param2=7}) minetest.set_node(pos, {name="default:water_flowing", param2=7})
elseif intensity == 3 then
minetest.set_node(pos, {name="default:water_flowing", param2=3})
--[[ LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06 --[[ LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06
This was causing "melts=2" nodes to just disappear so I changed it to replace the This was causing "melts=2" nodes to just disappear so I changed it to replace the
node with a water_source for a couple seconds and then replace the water_source with node with a water_source for a couple seconds and then replace the water_source with
@ -76,7 +78,9 @@ minetest.register_abm({
end end
end) end)
--]] --]]
end else
return
end
nodeupdate(pos) nodeupdate(pos)
end, end,
}) })
@ -184,7 +188,7 @@ minetest.register_abm({
nodenames = {"snow:xmas_tree"}, nodenames = {"snow:xmas_tree"},
interval = 10, interval = 10,
chance = 50, chance = 50,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node)
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ -- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
for i = 1,8 do for i = 1,8 do

View File

@ -6,77 +6,86 @@
-- ADD CHECK FOR MOREBLOCKS/SKIP IF NOT FOUND CODE STUFF HERE -- ADD CHECK FOR MOREBLOCKS/SKIP IF NOT FOUND CODE STUFF HERE
-- what of the recipeitem can be copied
local recipe_values = {
"description", "tiles", "groups", "sounds", "use_texture_alpha", "sunlight_propagates",
"freezemelt", "liquidtype", "sunlight_propagates",
"stair_desc", "slab_desc"
}
local stairdef = {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
dig = {name="default_dig_crumbly", gain=0.4},
dug = {name="default_snow_footstep", gain=0.75},
place = {name="default_place_node", gain=1.0}
}),
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
snow_stairs = {} -- This is a little trick. Without it Minetest will complain local placer_pos = placer:getpos()
-- "attempt to index global 'snow' (a nil value)" and if placer_pos then
-- refuse to load. So a value without definition "={}"is assigned to snow. local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
on_construct = function(pos)
pos.y = pos.y - 1
local node = minetest.get_node(pos)
if node.name == "default:dirt_with_grass"
-- 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
or node.name == "default:dirt" then
node.name = "default:dirt_with_snow"
minetest.set_node(pos, node)
end
end
}
-- Node will be called snow:stair_<subname> -- Node will be called snow:stair_<subname>
function snow_stairs.register_stair(subname, recipeitem, groups, images, description, sounds) local function register_stair(subname, recipeitem, newdef)
minetest.register_node("snow:stair_" .. subname, { local def = table.copy(stairdef)
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
groups = groups,
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
dig = {name="default_dig_crumbly", gain=0.4},
dug = {name="default_snow_footstep", gain=0.75},
place = {name="default_place_node", gain=1.0}
}),
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos() for n,i in pairs(newdef) do
if placer_pos then def[n] = i
local dir = { end
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y-1 == p1.y then local name = "snow:stair_" .. subname
param2 = param2 + 20 minetest.register_node(name, def)
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
on_construct = function(pos)
pos.y = pos.y - 1
if minetest.get_node(pos).name == "default:dirt_with_grass"
-- 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
or minetest.get_node(pos).name == "default:dirt" then
minetest.set_node(pos, {name="default:dirt_with_snow"})
end
end
})
--[[ --[[
-- for replace ABM -- for replace ABM
minetest.register_node("snow:stair_" .. subname.."upside_down", { minetest.register_node("snow:stair_" .. subname.."upside_down", {
@ -85,7 +94,7 @@ function snow_stairs.register_stair(subname, recipeitem, groups, images, descrip
}) })
--]] --]]
minetest.register_craft({ minetest.register_craft({
output = 'snow:stair_' .. subname .. ' 6', output = name .. " 6",
recipe = { recipe = {
{recipeitem, "", ""}, {recipeitem, "", ""},
{recipeitem, recipeitem, ""}, {recipeitem, recipeitem, ""},
@ -95,7 +104,7 @@ function snow_stairs.register_stair(subname, recipeitem, groups, images, descrip
-- Flipped recipe -- Flipped recipe
minetest.register_craft({ minetest.register_craft({
output = 'snow:stair_' .. subname .. ' 6', output = name .. " 6",
recipe = { recipe = {
{"", "", recipeitem}, {"", "", recipeitem},
{"", recipeitem, recipeitem}, {"", recipeitem, recipeitem},
@ -104,59 +113,76 @@ function snow_stairs.register_stair(subname, recipeitem, groups, images, descrip
}) })
end end
local slabdef = table.copy(stairdef)
slabdef.node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
}
slabdef.on_place = nil
-- Node will be called snow:slab_<subname> -- Node will be called snow:slab_<subname>
function snow_stairs.register_slab(subname, recipeitem, groups, images, description, sounds) local function register_slab(subname, recipeitem, newdef)
minetest.register_node("snow:slab_" .. subname, { local def = table.copy(slabdef)
description = description,
drawtype = "nodebox", local name = "snow:slab_" .. subname
tiles = images, def.on_place = function(itemstack, placer, pointed_thing)
paramtype = "light", if pointed_thing.type ~= "node" then
paramtype2 = "facedir", return itemstack
is_ground_content = true, end
groups = groups,
sounds = default.node_sound_dirt_defaults({ -- If it's being placed on an another similar one, replace it with
footstep = {name="default_snow_footstep", gain=0.25}, -- a full block
dig = {name="default_dig_crumbly", gain=0.4}, local slabpos, slabnode
dug = {name="default_snow_footstep", gain=0.75}, local p0 = pointed_thing.under
place = {name="default_place_node", gain=1.0} local p1 = pointed_thing.above
}), local n0 = minetest.get_node(p0)
node_box = { local n1 = minetest.get_node(p1)
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, local n0_is_upside_down = (n0.name == name and
}, n0.param2 >= 20)
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then if n0.name == name
return itemstack and not n0_is_upside_down
and p0.y+1 == p1.y then
slabpos = p0
slabnode = n0
elseif n1.name == name then
slabpos = p1
slabnode = n1
end
if slabpos then
-- Remove the slab at slabpos
minetest.remove_node(slabpos)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
fakestack:set_count(itemstack:get_count())
pointed_thing.above = slabpos
local success
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
-- If the item was taken from the fake stack, decrement original
if success then
itemstack:set_count(fakestack:get_count())
-- Else put old node back
else
minetest.set_node(slabpos, slabnode)
end end
return itemstack
end
-- If it's being placed on an another similar one, replace it with local param2
-- a full block -- Upside down slabs
local slabpos = nil if p0.y-1 == p1.y then
local slabnode = nil -- Turn into full block if pointing at a existing slab
local p0 = pointed_thing.under if n0_is_upside_down then
local p1 = pointed_thing.above -- Remove the slab at the position of the slab
local n0 = minetest.get_node(p0) minetest.remove_node(p0)
local n1 = minetest.get_node(p1)
local param2 = 0
local n0_is_upside_down = (n0.name == "snow:slab_" .. subname and
n0.param2 >= 20)
if n0.name == "snow:slab_" .. subname and not n0_is_upside_down and p0.y+1 == p1.y then
slabpos = p0
slabnode = n0
elseif n1.name == "snow:slab_" .. subname then
slabpos = p1
slabnode = n1
end
if slabpos then
-- Remove the slab at slabpos
minetest.remove_node(slabpos)
-- Make a fake stack of a single item and try to place it -- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem) local fakestack = ItemStack(recipeitem)
fakestack:set_count(itemstack:get_count()) fakestack:set_count(itemstack:get_count())
pointed_thing.above = slabpos pointed_thing.above = p0
local success local success
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing) fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
-- If the item was taken from the fake stack, decrement original -- If the item was taken from the fake stack, decrement original
@ -164,57 +190,27 @@ function snow_stairs.register_slab(subname, recipeitem, groups, images, descript
itemstack:set_count(fakestack:get_count()) itemstack:set_count(fakestack:get_count())
-- Else put old node back -- Else put old node back
else else
minetest.set_node(slabpos, slabnode) minetest.set_node(p0, n0)
end end
return itemstack return itemstack
end end
-- Upside down slabs -- Place upside down slab
if p0.y-1 == p1.y then param2 = 20
-- Turn into full block if pointing at a existing slab elseif n0_is_upside_down
if n0_is_upside_down then and p0.y+1 ~= p1.y then
-- Remove the slab at the position of the slab
minetest.remove_node(p0)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
fakestack:set_count(itemstack:get_count())
pointed_thing.above = p0
local success
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
-- If the item was taken from the fake stack, decrement original
if success then
itemstack:set_count(fakestack:get_count())
-- Else put old node back
else
minetest.set_node(p0, n0)
end
return itemstack
end
-- Place upside down slab
param2 = 20
end
-- If pointing at the side of a upside down slab -- If pointing at the side of a upside down slab
if n0_is_upside_down and p0.y+1 ~= p1.y then param2 = 20
param2 = 20 end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2) return minetest.item_place(itemstack, placer, pointed_thing, param2)
end, end
on_construct = function(pos) for n,i in pairs(newdef) do
pos.y = pos.y - 1 def[n] = i
if minetest.get_node(pos).name == "default:dirt_with_grass" end
-- 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
or minetest.get_node(pos).name == "default:dirt" then
minetest.set_node(pos, {name="default:dirt_with_snow"})
end
end
}) minetest.register_node(name, def)
--[[ --[[
-- for replace ABM -- for replace ABM
minetest.register_node("snow:slab_" .. subname.."upside_down", { minetest.register_node("snow:slab_" .. subname.."upside_down", {
@ -224,7 +220,7 @@ function snow_stairs.register_slab(subname, recipeitem, groups, images, descript
--]] --]]
minetest.register_craft({ minetest.register_craft({
output = 'snow:slab_' .. subname .. ' 6', output = name .. " 6",
recipe = { recipe = {
{recipeitem, recipeitem, recipeitem}, {recipeitem, recipeitem, recipeitem},
}, },
@ -259,9 +255,31 @@ minetest.register_abm({
-- features (freezing, melting, and how they change dirt and dirt_with_grass). ~ LazyJ -- features (freezing, melting, and how they change dirt and dirt_with_grass). ~ LazyJ
-- Nodes will be called snow:{stair,slab}_<subname> -- Nodes will be called snow:{stair,slab}_<subname>
function snow_stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, freezemelt, liquidtype, paramtype, sunlight_propagates) local function register_stair_and_slab(subname, recipeitem, def)
snow_stairs.register_stair(subname, recipeitem, groups, images, desc_stair, freezemelt, liquidtype, paramtype, sunlight_propagates) local recipedef = minetest.registered_nodes[recipeitem]
snow_stairs.register_slab(subname, recipeitem, groups, images, desc_slab, freezemelt, liquidtype, paramtype, sunlight_propagates) for _,i in pairs(recipe_values) do
if def[i] == nil
and recipedef[i] ~= nil then
def[i] = recipedef[i]
end
end
local groups = table.copy(def.groups)
groups.cooks_into_ice = nil
if groups.melts then
groups.melts = math.min(groups.melts+1, 3)
end
def.groups = groups
local stair_desc = def.stair_desc
def.stair_desc = nil
local slab_desc = def.slab_desc
def.slab_desc = nil
def.description = stair_desc
register_stair(subname, recipeitem, def)
def.description = slab_desc
register_slab(subname, recipeitem, def)
end end
@ -269,58 +287,16 @@ list_of_snow_stuff = {
--{"row[1] = first item in row", --{"row[1] = first item in row",
-- "row[2] = second item in row", -- "row[2] = second item in row",
-- "row[3] = third item in row", and so on, and so on...}, ~ LazyJ -- "row[3] = third item in row", and so on, and so on...}, ~ LazyJ
{"ice", "default:ice", "default_ice.png", "Ice Stairs", "Ice Slabs"}, {"ice", "default:ice", "Ice Stairs", "Ice Slabs"},
{"snowblock", "default:snowblock", "default_snow.png", "Snowblock Stairs", "Snowblock Slabs"}, {"snowblock", "default:snowblock", "Snowblock Stairs", "Snowblock Slabs"},
{"snow_cobble", "snow:snow_cobble", "snow_snow_cobble.png", "Snow Cobble Stairs", "Snow Cobble Slabs"}, {"snow_cobble", "snow:snow_cobble", "Snow Cobble Stairs", "Snow Cobble Slabs"},
{"snow_brick", "snow:snow_brick", "snow_snow_brick.png", "Snow Brick Stair", "Snow Brick Slab"}, {"snow_brick", "snow:snow_brick", "Snow Brick Stair", "Snow Brick Slab"},
{"ice_brick", "snow:ice_brick", "Ice Brick Stair", "Ice Brick Slab"},
} }
for _, row in ipairs(list_of_snow_stuff) do for _, row in pairs(list_of_snow_stuff) do
local snow_subname = row[1] register_stair_and_slab(row[1], row[2], {
local snow_recipeitem = row[2] stair_desc = row[3],
local snow_images = row[3] slab_desc = row[4],
local snow_desc_stair = row[4] })
local snow_desc_slab = row[5] end
snow_stairs.register_stair_and_slab(snow_subname, snow_recipeitem,
{cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1, icemaker=1},
{snow_images},
snow_desc_stair,
snow_desc_slab,
"default:water_source",
"none",
"light",
true
)
end -- End the "list of snow stuff" part of the above section. ~ LazyJ
-- Snow stairs and slabs should be easier to break than the more dense and
-- manufactured, other snow-type nodes in the list above. ~ lazyJ
minetest.override_item("snow:stair_snowblock", {
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=2, icemaker=1},
})
minetest.override_item("snow:slab_snowblock", {
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=2, icemaker=1},
})
-- Everything above is made of snow and uses snow sounds, ice, however, should sound more like glass
-- and be harder to dig. ~ LazyJ
minetest.override_item("snow:stair_ice", {
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, melts=2, icemaker=1},
use_texture_alpha = true,
sounds = default.node_sound_glass_defaults(),
})
minetest.override_item("snow:slab_ice", {
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, melts=2, icemaker=1},
use_texture_alpha = true,
sounds = default.node_sound_glass_defaults(),
})

View File

@ -1,51 +1,17 @@
--[[ --[[
Crafting Sections (in order, top to bottom): Crafting Sections (in order, top to bottom):
1. Fuel 1. Cooking
2. Cooking 2. Crafting and Recycling
3. Crafting and Recycling
The crafting recipe for the sled is in the sled.lua file. The crafting recipe for the sled is in the sled.lua file.
~ LazyJ ~ LazyJ
--]] ]]
-- 1. Fuel
minetest.register_craft({
type = "fuel",
recipe = "snow:needles",
burntime = 1,
})
-- 1. Cooking
minetest.register_craft({
type = "fuel",
recipe = "snow:sapling_pine",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "snow:needles_decorated",
burntime = 1,
})
minetest.register_craft({
type = "fuel",
recipe = "snow:xmas_tree",
burntime = 10,
})
-- 2. Cooking
--[[ --[[
"Cooks_into_ice" is a custom group I assigned to full-sized, snow-stuff nodes "Cooks_into_ice" is a custom group I assigned to full-sized, snow-stuff nodes
@ -53,7 +19,7 @@ minetest.register_craft({
recipe for each one. recipe for each one.
~ LazyJ ~ LazyJ
--]] ]]
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
@ -67,17 +33,17 @@ minetest.register_craft({
-- 3. Crafting and Recycling -- 2. Crafting and Recycling
-- Let's make moss craftable so players can more easily create mossycobble and -- Let's make moss craftable so players can more easily create mossycobble and
-- gives another useful purpose to pine needles. ~ LazyJ -- gives another useful purpose to pine needles. ~ LazyJ
minetest.register_craft({ minetest.register_craft({
output = 'snow:moss', output = "snow:moss",
recipe = { recipe = {
{'snow:needles', 'snow:needles'}, {"snow:needles", "snow:needles"},
{'snow:needles', 'snow:needles'}, {"snow:needles", "snow:needles"},
}, },
}) })
@ -95,91 +61,107 @@ of snowblocks (and then use them to water-grief by melting the snow blocks).
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'default:snowblock 2', output = "default:snowblock 2",
recipe = { recipe = {
'snow:snow_cobble', "snow:snow_cobble",
'snow:snow_cobble' "snow:snow_cobble"
} }
}) })
--[[minetest.register_craft({ --[[minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'default:snowblock 3', output = "default:snowblock 3",
recipe = { recipe = {
'default:snowblock', "default:snowblock",
'default:snowblock' "default:snowblock"
} }
})]] })]]
minetest.register_craft({ minetest.register_craft({
output = 'snow:snow_brick', output = "snow:snow_brick",
recipe = { recipe = {
{'default:snowblock', 'default:snowblock'}, {"default:snowblock", "default:snowblock"},
{'default:snowblock', 'default:snowblock'} {"default:snowblock", "default:snowblock"}
} }
}) })
-- Why not recycle snow_bricks back into snowblocks? ~ LazyJ
minetest.register_craft({
output = "default:snowblock 4",
recipe = {
{"snow:snow_brick"}
}
})
minetest.register_craft({
output = "snow:ice_brick",
recipe = {
{"default:ice", "default:ice"},
{"default:ice", "default:ice"}
}
})
minetest.register_craft({
output = "snow:snow_cobble 6",
recipe = {
{"snow:ice_brick"}
}
})
--Craft icy snow. --Craft icy snow.
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'snow:snow_cobble 6', output = "snow:snow_cobble 6",
recipe = { recipe = {
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:ice', "default:ice",
'default:ice', "default:ice",
'default:ice' "default:ice"
} }
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'snow:snow_cobble 4', output = "snow:snow_cobble 4",
recipe = { recipe = {
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:ice', "default:ice",
'default:ice' "default:ice"
} }
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'snow:snow_cobble 2', output = "snow:snow_cobble 2",
recipe = { recipe = {
'default:snow', "default:snow",
'default:snow', "default:snow",
'default:ice' "default:ice"
} }
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'snow:snow_cobble', output = "snow:snow_cobble",
recipe = { recipe = {
'default:snow', "default:snow",
'default:ice' "default:ice"
} }
})
-- Why not recycle snow_bricks back into snowblocks? ~ LazyJ
minetest.register_craft({
output = 'default:snowblock 4',
recipe = {
{'snow:snow_brick'}
}
}) })

View File

@ -74,17 +74,6 @@ function snow.make_pine(pos,snow,xmas)
minetest.add_node(pos, node) minetest.add_node(pos, node)
end end
end end
--Clear ground.
for z = -1,1 do
for x = -1,1 do
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
local nd = minetest.get_node(p).name
if nd == "default:snow"
or nd == "default:snowblock" then
minetest.remove_node(p)
end
end
end
if xmas then if xmas then
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.spawn_tree(pos, xmas_tree) minetest.spawn_tree(pos, xmas_tree)
@ -126,18 +115,10 @@ function snow.voxelmanip_pine(pos,a,data)
for x = -1,1 do for x = -1,1 do
local x = pos.x + x local x = pos.x + x
--Clear ground.
local node = a:index(x,pos.y,z)
if data[node] == c_snow then
data[node] = c_air
end
--Make tree. --Make tree.
for i = 1,2 do for i = 1,2 do
local node = a:index(x,pos.y+i,z) data[a:index(x,pos.y+i,z)] = c_pine_needles
data[node] = c_pine_needles if x ~= 0
if snow
and x ~= 0
and z ~= 0 and z ~= 0
and perlin1:get2d({x=x,y=z}) > 0.53 then and perlin1:get2d({x=x,y=z}) > 0.53 then
local abovenode = a:index(x,pos.y+i+1,z) local abovenode = a:index(x,pos.y+i+1,z)
@ -154,19 +135,17 @@ function snow.voxelmanip_pine(pos,a,data)
data[a:index(x-1,y,z)] = c_pine_needles data[a:index(x-1,y,z)] = c_pine_needles
data[a:index(x,y,z+1)] = c_pine_needles data[a:index(x,y,z+1)] = c_pine_needles
data[a:index(x,y,z-1)] = c_pine_needles data[a:index(x,y,z-1)] = c_pine_needles
if snow then if perlin1:get2d({x=x+1,y=z}) > 0.53 then
if perlin1:get2d({x=x+1,y=z}) > 0.53 then data[a:index(x+1,y+1,z)] = c_snow
data[a:index(x+1,y+1,z)] = c_snow end
end if perlin1:get2d({x=x+1,y=z}) > 0.53 then
if perlin1:get2d({x=x+1,y=z}) > 0.53 then data[a:index(x-1,y+1,z)] = c_snow
data[a:index(x-1,y+1,z)] = c_snow end
end if perlin1:get2d({x=x,y=z+1}) > 0.53 then
if perlin1:get2d({x=x,y=z+1}) > 0.53 then data[a:index(x,y+1,z+1)] = c_snow
data[a:index(x,y+1,z+1)] = c_snow end
end if perlin1:get2d({x=x,y=z-1}) > 0.53 then
if perlin1:get2d({x=x,y=z-1}) > 0.53 then data[a:index(x,y+1,z-1)] = c_snow
data[a:index(x,y+1,z-1)] = c_snow
end
end end
end end
for i=0, 4 do for i=0, 4 do
@ -174,8 +153,7 @@ function snow.voxelmanip_pine(pos,a,data)
end end
data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles
data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles
if snow if perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
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

View File

@ -1,3 +1,14 @@
-- https://github.com/paramat/meru/blob/master/init.lua#L52
-- Parameters must match mgv6 biome noise
local np_default = {
offset = 0,
scale = 1,
spread = {x=250, y=250, z=250},
seed = 9130,
octaves = 3,
persist = 0.5
}
-- 2D noise for coldness -- 2D noise for coldness
local np_cold = { local np_cold = {
@ -31,32 +42,85 @@ local function biome_to_string(num,num2)
return biome return biome
end end
local function do_ws_func(a, x) local function do_ws_func(a, x)
local n = x/(16000) local n = x/(16000)
local y = 0 local y = 0
for k=1,1000 do for k=1,1000 do
y = y + 1000*(math.sin(math.pi * k^a * n)/(math.pi * k^a)) y = y + 1000*math.sin(math.pi * k^a * n)/(math.pi * k^a)
end end
return y return y
end end
local ws_lists = {}
local function get_ws_list(a,x) local plantlike_ids = {}
ws_lists[a] = ws_lists[a] or {} local function is_plantlike(id)
local v = ws_lists[a][x] if plantlike_ids[id] ~= nil then
if v then return plantlike_ids[id]
return v end
end local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
v = {} if not node then
for x=x,x + (80 - 1) do plantlike_ids[id] = false
local y = do_ws_func(a, x) return false
v[x] = y end
end local drawtype = node.drawtype
ws_lists[a][x] = v if not drawtype
return v or drawtype ~= "plantlike" then
plantlike_ids[id] = false
return false
end
plantlike_ids[id] = true
return true
end end
-- On generated function local snowable_ids = {}
local function is_snowable(id)
if snowable_ids[id] ~= nil then
return snowable_ids[id]
end
local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not node then
snowable_ids[id] = false
return false
end
local drawtype = node.drawtype
if drawtype
and drawtype ~= "normal"
and drawtype ~= "allfaces_optional"
and drawtype ~= "glasslike" then
snowable_ids[id] = false
return false
end
snowable_ids[id] = true
return true
end
local c, replacements
local function define_contents()
c = {
dirt_with_grass = minetest.get_content_id("default:dirt_with_grass"),
dirt = minetest.get_content_id("default:dirt"),
tree = minetest.get_content_id("default:tree"),
apple = minetest.get_content_id("default:apple"),
snow = minetest.get_content_id("default:snow"),
snow_block = minetest.get_content_id("default:snowblock"),
dirt_with_snow = minetest.get_content_id("default:dirt_with_snow"),
air = minetest.get_content_id("air"),
ignore = minetest.get_content_id("ignore"),
stone = minetest.get_content_id("default:stone"),
dry_shrub = minetest.get_content_id("default:dry_shrub"),
snow_shrub = minetest.get_content_id("snow:shrub_covered"),
leaves = minetest.get_content_id("default:leaves"),
jungleleaves = minetest.get_content_id("default:jungleleaves"),
junglegrass = minetest.get_content_id("default:junglegrass"),
ice = minetest.get_content_id("default:ice"),
water = minetest.get_content_id("default:water_source"),
papyrus = minetest.get_content_id("default:papyrus"),
sand = minetest.get_content_id("default:sand"),
desert_sand = minetest.get_content_id("default:desert_sand"),
}
replacements = snow.known_plants or {}
end
minetest.register_on_generated(function(minp, maxp, seed) minetest.register_on_generated(function(minp, maxp, seed)
local t1 = os.clock() local t1 = os.clock()
@ -66,45 +130,30 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = maxp.x local x1 = maxp.x
local z1 = maxp.z local z1 = maxp.z
local spawn_pine = snow.voxelmanip_pine
local smooth = snow.smooth_biomes local smooth = snow.smooth_biomes
local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass") if not c then
local c_dirt = minetest.get_content_id("default:dirt") define_contents()
local c_tree = minetest.get_content_id("default:tree") end
local c_apple = minetest.get_content_id("default:apple")
local c_snow = minetest.get_content_id("default:snow")
local c_snow_block = minetest.get_content_id("default:snowblock")
local c_dirt_with_snow = minetest.get_content_id("default:dirt_with_snow")
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_stone = minetest.get_content_id("default:stone")
local c_dry_shrub = minetest.get_content_id("default:dry_shrub")
local c_leaves = minetest.get_content_id("default:leaves")
local c_jungleleaves = minetest.get_content_id("default:jungleleaves")
local c_junglegrass = minetest.get_content_id("default:junglegrass")
local c_ice = minetest.get_content_id("default:ice")
local c_water = minetest.get_content_id("default:water_source")
local c_papyrus = minetest.get_content_id("default:papyrus")
local c_sand = minetest.get_content_id("default:sand")
local vm = minetest.get_voxel_manip() local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local emin, emax = vm:read_from_map(minp, maxp)
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 param2s = vm:get_param2_data()
local snow_tab,num = {},1 local snow_tab,num = {},1
local pines_tab,pnum = {},1
local sidelen = x1 - x0 + 1 local sidelen = x1 - x0 + 1
local chulens = {x=sidelen, y=sidelen, z=sidelen} local chulens = {x=sidelen, y=sidelen, z=sidelen}
local nvals_cold = minetest.get_perlin_map(np_cold, chulens):get2dMap_flat({x=x0, y=z0}) local nvals_default = minetest.get_perlin_map(np_default, chulens):get2dMap_flat({x=x0+150, y=z0+50})
local nvals_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat({x=x0, y=z0}) local nvals_cold, nvals_ice
-- Choose biomes -- Choose biomes
local pr = PseudoRandom(seed+57) local pr = PseudoRandom(seed+57)
-- Land biomes -- Land biomes
local biome = pr:next(1, 5) local biome = pr:next(1, 5)
local snowy = biome == 1 -- spawns alot of snow local snowy = biome == 1 -- spawns snow
local alpine = biome == 3 -- rocky terrain local alpine = biome == 3 -- rocky terrain
-- Misc biome settings -- Misc biome settings
local icy = pr:next(1, 2) == 2 -- if enabled spawns ice in sand instead of snow blocks local icy = pr:next(1, 2) == 2 -- if enabled spawns ice in sand instead of snow blocks
@ -119,21 +168,32 @@ minetest.register_on_generated(function(minp, maxp, seed)
for z = z0, z1 do for z = z0, z1 do
for x = x0, x1 do for x = x0, x1 do
local in_biome = false local in_biome = false
local test = nvals_cold[ni] local test
if smooth and (not snowy) if nvals_default[ni] < 0.35 then
and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then if not nvals_cold then
in_biome = true nvals_cold = minetest.get_perlin_map(np_cold, chulens):get2dMap_flat({x=x0, y=z0})
elseif (not smooth or snowy) and test > 0.53 then end
in_biome = true test = math.min(nvals_cold[ni], 1)
end if smooth
and not snowy then
if (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then
in_biome = true
end
elseif test > 0.53 then
in_biome = true
end
end
if not in_biome then if not in_biome then
if alpine and test > 0.43 then if alpine
and test
and test > 0.43 then
-- remove trees near alpine
local ground_y = nil local ground_y = nil
for y = maxp.y, minp.y, -1 do for y = maxp.y, minp.y, -1 do
local nodid = data[area:index(x, y, z)] local nodid = data[area:index(x, y, z)]
if nodid ~= c_air if nodid ~= c.air
and nodid ~= c_ignore then and nodid ~= c.ignore then
ground_y = y ground_y = y
break break
end end
@ -141,16 +201,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local vi = area:index(x, ground_y, z) local vi = area:index(x, ground_y, z)
if data[vi] == c_leaves or data[vi] == c_jungleleaves then if data[vi] == c.leaves
or data[vi] == c.jungleleaves then
for y = ground_y, -16, -1 do for y = ground_y, -16, -1 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
local id = data[vi] local id = data[vi]
if id ~= c_air then if id ~= c.air then
if id == c_leaves if id == c.leaves
or id == c_jungleleaves or id == c.jungleleaves
or id == c_tree or id == c.tree
or id == c_apple then or id == c.apple then
data[vi] = c_air data[vi] = c.air
else else
break break
end end
@ -159,8 +220,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
elseif in_biome then else
write_to_map = true write_to_map = true
if not nvals_ice then
nvals_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat({x=x0, y=z0})
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
local icebergs = icetype > -0.2 and icetype <= 0 local icebergs = icetype > -0.2 and icetype <= 0
@ -168,10 +232,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
local icesheet = icetype > -0.6 and icetype <= -0.4 local icesheet = icetype > -0.6 and icetype <= -0.4
local icecave = icetype <= -0.6 local icecave = icetype <= -0.6
local ground_y = nil local ground_y
for y = maxp.y, minp.y, -1 do for y = maxp.y, minp.y, -1 do
local nodid = data[area:index(x, y, z)] local nodid = data[area:index(x, y, z)]
if nodid ~= c_air and nodid ~= c_ignore then if nodid ~= c.air and nodid ~= c.ignore then
ground_y = y ground_y = y
break break
end end
@ -179,98 +243,68 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local node = area:index(x, ground_y, z) local node = area:index(x, ground_y, z)
local abovenode = area:index(x, ground_y+1, z) local c_ground = data[node]
local belownode = area:index(x, ground_y-1, z)
if ground_y and data[node] == c_dirt_with_grass then if c_ground == c.dirt_with_grass then
if alpine and test > 0.53 then if alpine
snow_tab[num] = {abovenode, z, x, test} and test > 0.53 then
snow_tab[num] = {ground_y, z, x, test}
num = num+1 num = num+1
for y = ground_y, -6, -1 do -- generate stone ground
for y = ground_y, math.max(-6, minp.y-6), -1 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
if data[vi] == c_stone then if data[vi] == c.stone then
break break
else
data[vi] = c_stone
end end
data[vi] = c.stone
end end
elseif (shrubs and pr:next(1,28) == 1) then elseif pines
data[node] = c_dirt_with_snow and pr:next(1,36) == 1 then
data[abovenode] = c_dry_shrub pines_tab[pnum] = {x=x, y=ground_y+1, z=z}
elseif pines and pr:next(1,36) == 1 then pnum = pnum+1
data[node] = c_dirt_with_snow elseif shrubs
spawn_pine({x=x, y=ground_y+1, z=z}, area, data) and pr:next(1,928) == 1 then
elseif snowy and test > 0.63 then data[node] = c.dirt_with_snow
data[abovenode] = c_snow_block data[area:index(x, ground_y+1, z)] = c.dry_shrub
else else
data[node] = c_dirt_with_snow if snowy
snow_tab[num] = {abovenode, z, x, test} or test > 0.8 then
num = num+1 -- more, deeper snow
end data[node] = c.snow_block
elseif ground_y and data[node] == c_sand then else
if not icy then data[node] = c.dirt_with_snow
snow_tab[num] = {abovenode, z, x, test}
num = num+1
else
data[node] = c_ice
end
elseif ground_y and data[node] == c_leaves
or data[node] == c_jungleleaves or data[node] == c_apple then
if alpine then
snow_tab[num] = {abovenode, z, x, test}
num = num+1
for y = ground_y, -6, -1 do
local stone = area:index(x, y, z)
if data[stone] == c_stone then
break
else
data[stone] = c_stone
end
end end
else snow_tab[num] = {ground_y, z, x, test}
snow_tab[num] = {abovenode, z, x, test}
num = num+1 num = num+1
end end
elseif ground_y elseif c_ground == c.water then
and data[node] == c_junglegrass then
data[node] = c_dry_shrub
elseif ground_y
and data[node] == c_papyrus then
for y = ground_y, ground_y-4, -1 do
local vi = area:index(x, y, z)
if data[vi] == c_papyrus then
snow_tab[num] = {area:index(x, ground_y, z), z, x, test}
num = num+1
data[vi] = c_snow_block
end
end
elseif ground_y
and data[node] == c_water then
if not icesheet if not icesheet
and not icecave and not icecave
and not icehole then and not icehole then
local x1 = data[area:index(x+1, ground_y, z)] local nds = {
local z1 = data[area:index(x, ground_y, z+1)] data[area:index(x+1, ground_y, z)],
local xz1 = data[area:index(x+1, ground_y, z+1)] data[area:index(x, ground_y, z+1)],
local xz2 = data[area:index(x-1, ground_y, z-1)] data[area:index(x+1, ground_y, z+1)],
local x2 = data[area:index(x-1, ground_y, z)] data[area:index(x-1, ground_y, z-1)],
local z2 = data[area:index(x, ground_y, z-1)] data[area:index(x-1, ground_y, z)],
local rand = (pr:next(1,4) == 1) and (cool or icebergs) data[area:index(x, ground_y, z-1)],
}
local ice local ice
if rand then if pr:next(1,4) == 1
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do and (cool or icebergs) then
if i == c_ice then for _,i in ipairs(nds) do
if i == c.ice then
ice = true ice = true
break break
end end
end end
end end
if not ice then if not ice then
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do for _,i in ipairs(nds) do
if i ~= c_water if i ~= c.water
and i ~= c_ice and i ~= c.ice
and i ~= c_air and i ~= c.air
and i ~= c_ignore then and i ~= c.ignore then
ice = true ice = true
break break
end end
@ -278,26 +312,94 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
local y = data[area:index(x, ground_y-1, z)] 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 (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
else else
if (icehole and pr:next(1,10) > 1) if icesheet
or icecave or icecave
or icesheet then or (icehole and pr:next(1,10) > 1) then
data[node] = c_ice data[node] = c.ice
end end
if icecave then if icecave then
for y = ground_y-1, -33, -1 do for y = ground_y-1, -33, -1 do
local vi = area:index(x, y, z) local vi = area:index(x, y, z)
if data[vi] ~= c_water then if data[vi] ~= c.water then
break break
else
data[vi] = c_air
end end
data[vi] = c.air
end end
end end
if icesheet then
-- put snow onto icesheets
snow_tab[num] = {ground_y, z, x, test}
num = num+1
end
end
elseif c_ground == c.sand then
if icy then
data[node] = c.ice
end
snow_tab[num] = {ground_y, z, x, test}
num = num+1
elseif c_ground == c.papyrus then
snow_tab[num] = {ground_y, z, x, test}
num = num+1
-- replace papyrus plants with snowblocks
local y = ground_y
for _ = 1,7 do
local vi = area:index(x, y, z)
if data[vi] == c.papyrus then
data[vi] = c.snow_block
y = y-1
else
break
end
end
elseif alpine then
-- make stone pillars out of trees and other stuff
for y = ground_y, math.max(-6, minp.y-6), -1 do
local stone = area:index(x, y, z)
if data[stone] == c.stone then
break
end
data[stone] = c.stone
end
-- put snow onto it
snow_tab[num] = {ground_y, z, x, test}
num = num+1
elseif c_ground ~= c.desert_sand then
if is_snowable(c_ground) then
-- put snow onto it
snow_tab[num] = {ground_y, z, x, test}
num = num+1
end
for y = 0, 12 do
y = ground_y-y
local vi = area:index(x, y, z)
local nd = data[vi]
local plantlike = is_plantlike(nd)
if replacements[nd] then
data[vi] = replacements[nd]
if plantlike then
param2s[vi] = pr:next(0,179)
end
elseif nd == c.dirt_with_grass then
data[vi] = c.dirt_with_snow
break
elseif plantlike then
local under = area:index(x, y-1, z)
if data[under] == c.dirt_with_grass then
-- replace other plants with shrubs
data[vi] = c.snow_shrub
param2s[vi] = pr:next(0,179)
data[under] = c.dirt_with_snow
break
end
elseif nd == c.stone then
break
end
end end
end end
end end
@ -306,37 +408,64 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
local param2s
if num ~= 1 then if num ~= 1 then
for _,i in pairs(snow_tab) do
-- set snow
data[area:index(i[3], i[1]+1, i[2])] = c.snow
end
local wsz, wsx local wsz, wsx
for _,i in pairs(snow_tab) do for _,i in pairs(snow_tab) do
local p,z,x,test = unpack(i) local y,z,x,test = unpack(i)
data[p] = c_snow test = (test-0.53)/0.47 -- /(1-0.53)
test = test-0.73
if test > 0 then if test > 0 then
local minh = math.floor(test*4*9)%9+1 local maxh = math.floor(test*10)%10+1
if minh ~= 1 then if maxh ~= 1 then
if not wsz then local h = math.floor( do_ws_func(2, x) + do_ws_func(5, z)*5)%10+1
wsz = get_ws_list(5, z0)
wsx = get_ws_list(2, x0)
param2s = vm:get_param2_data()
end
local h = math.min(minh, math.floor(wsx[x]+wsz[z]*5)%9+1)
if h ~= 1 then if h ~= 1 then
if h == 9 then -- search for nearby snow
h = 4 y = y+1
for i = -1,1,2 do
for _,cord in pairs({{x+i,z}, {x,z+i}}) do
local nd = data[area:index(cord[1], y, cord[2])]
if nd == c.air
or is_plantlike(nd) then
h = h/2
end
end
end
h = math.floor(h+0.5)
if h > 1 then
-- make snowdrifts walkable
if h == 10 then
h = 5
end
h = math.min(maxh, h)
local vi = area:index(x, y, z)
if h == 9 then
-- replace the snow with a snowblock because its a full node
data[vi] = c.snow_block
else
-- set a specific snow height
param2s[vi] = h*7
end
end end
param2s[p] = h*7
end end
end end
end end
end end
end end
vm:set_data(data) -- spawn pines
if param2s then if pines
vm:set_param2_data(param2s) and pnum ~= 1 then
local spawn_pine = snow.voxelmanip_pine
for _,pos in pairs(pines_tab) do
spawn_pine(pos, area, data)
end
end end
vm:set_data(data)
vm:set_param2_data(param2s)
vm:set_lighting({day=0, night=0}) vm:set_lighting({day=0, night=0})
vm:calc_lighting() vm:calc_lighting()
vm:write_to_map() vm:write_to_map()

View File

@ -1,7 +1,7 @@
-- NODES -- NODES
-- Pine Needles -- Pine Needles
minetest.register_node("snow:needles",{ local nodedef = {
description = "Pine Needles", description = "Pine Needles",
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
@ -9,6 +9,7 @@ minetest.register_node("snow:needles",{
waving = 1, waving = 1,
paramtype = "light", paramtype = "light",
groups = {snappy=3, leafdecay=5}, groups = {snappy=3, leafdecay=5},
furnace_burntime = 1,
drop = { drop = {
max_items = 1, max_items = 1,
items = { items = {
@ -18,14 +19,12 @@ minetest.register_node("snow:needles",{
rarity = 20, rarity = 20,
}, },
{ {
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles'}, items = {'snow:needles'},
} }
} }
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) }
--[[ --[[
If christmas_content is enabled, then this next part will override the pine needles' drop code If christmas_content is enabled, then this next part will override the pine needles' drop code
@ -33,36 +32,20 @@ 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
--Christmas trees table.insert(nodedef.drop.items, 1, {
-- player will get xmas tree with 1/120 chance
minetest.override_item("snow:needles", { items = {'snow:xmas_tree'},
drop = { rarity = 120,
max_items = 1,
items = {
{
-- player will get xmas tree with 1/120 chance
items = {'snow:xmas_tree'},
rarity = 120,
},
{
-- player will get sapling with 1/20 chance
items = {'snow:sapling_pine'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles'},
}
}
}
}) })
end end
minetest.register_node("snow:needles", table.copy(nodedef))
--Christmas easter egg --Christmas easter egg
minetest.register_on_mapgen_init( function() minetest.register_on_mapgen_init( function()
@ -73,102 +56,28 @@ end
) )
--[[
Original, static Xmas lights. Keep so people can "turn off" the
animation if it is too much for them. ~ LazyJ
--Decorated Pine leaves
minetest.register_node("snow:needles_decorated", {
description = "Decorated Pine Needles",
drawtype = "allfaces_optional",
tiles = {"snow_needles_decorated.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3},
drop = {
max_items = 1,
items = {
{
-- player will get xmas tree with 1/20 chance
items = {'snow:xmas_tree'},
rarity = 50,
},
{
-- player will get sapling with 1/20 chance
items = {'snow:sapling_pine'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles_decorated'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
--]]
-- Animated, "blinking lights" version. ~ LazyJ
-- Decorated Pine Leaves -- Decorated Pine Leaves
minetest.register_node("snow:needles_decorated", {
description = "Decorated Pine Needles", nodedef.description ="Decorated "..nodedef.description
drawtype = "allfaces_optional", nodedef.light_source = 5
light_source = 5, nodedef.waving = nil
inventory_image = minetest.inventorycube("snow_needles_decorated.png"), if snow.disable_deco_needle_ani then
--tiles = {"snow_needles_decorated.png"}, nodedef.tiles = {"snow_needles_decorated.png"}
tiles = { else
-- Animated, "blinking lights" version. ~ LazyJ
nodedef.inventory_image = minetest.inventorycube("snow_needles_decorated.png")
nodedef.tiles = {
{name="snow_needles_decorated_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=20.0}} {name="snow_needles_decorated_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=20.0}}
}, }
paramtype = "light", end
groups = {snappy=3, leafdecay=5}, nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
drop = {
max_items = 1, minetest.register_node("snow:needles_decorated", nodedef)
items = {
{
-- player will get xmas tree with 1/120 chance
items = {'snow:xmas_tree'},
rarity = 120,
},
{
-- player will get sapling with 1/20 chance
items = {'snow:sapling_pine'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles_decorated'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
-- Saplings
nodedef = {
-- Xmas Tree Sapling
minetest.register_node("snow:xmas_tree", {
description = "Christmas Tree",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"snow_xmas_tree.png"},
inventory_image = "snow_xmas_tree.png",
wield_image = "snow_xmas_tree.png",
paramtype = "light",
walkable = false,
groups = {snappy=2,dig_immediate=3},
sounds = default.node_sound_defaults(),
})
-- Pine Sapling
minetest.register_node("snow:sapling_pine", {
description = "Pine Sapling", description = "Pine Sapling",
drawtype = "plantlike", drawtype = "plantlike",
visual_scale = 1.0, visual_scale = 1.0,
@ -178,55 +87,62 @@ minetest.register_node("snow:sapling_pine", {
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
groups = {snappy=2,dig_immediate=3}, groups = {snappy=2,dig_immediate=3},
furnace_burntime = 10,
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}
}) -- Pine Sapling
minetest.register_node("snow:sapling_pine", table.copy(nodedef))
-- Xmas Tree Sapling
nodedef.description = "Christmas Tree"
nodedef.tiles = {"snow_xmas_tree.png"}
nodedef.inventory_image = "snow_xmas_tree.png"
nodedef.wield_image = "snow_xmas_tree.png"
minetest.register_node("snow:xmas_tree", nodedef)
nodedef = {
-- Star on Xmas Trees
minetest.register_node("snow:star", {
description = "Star", description = "Star",
--drawtype = "torchlike", drawtype = "plantlike",
drawtype = "plantlike", -- Stars disappeared when viewed at the right angle. "Plantlike" solved the visual problem. ~ LazyJ
tiles = {"snow_star.png"}, tiles = {"snow_star.png"},
inventory_image = "snow_star.png", inventory_image = "snow_star.png",
wield_image = "snow_star.png", wield_image = "snow_star.png",
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
--groups = {snappy=2,dig_immediate=3}, -- Don't want the ornament breaking too easily because you have to punch it to turn it on and off. ~ LazyJ
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1}, -- Don't want the ornament breaking too easily because you have to punch it to turn it on and off. ~ LazyJ groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1},
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}), -- Breaking "glass" sound makes it sound like a real, broken, Xmas tree ornament (Sorry, Mom!). ;)- ~ LazyJ -- Breaking "glass" sound makes it sound like a real, broken, Xmas tree ornament (Sorry, Mom!). ;)- ~ LazyJ
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}),
on_punch = function(pos, node) -- Added a "lit" star that can be punched on or off depending on your preference. ~ LazyJ on_punch = function(pos, node) -- Added a "lit" star that can be punched on or off depending on your preference. ~ LazyJ
node.name = "snow:star_lit" node.name = "snow:star_lit"
minetest.set_node(pos, node) minetest.set_node(pos, node)
nodeupdate(pos) nodeupdate(pos)
end, end,
}) }
-- Star on Xmas Trees
minetest.register_node("snow:star", table.copy(nodedef))
-- Star (Lit Version) on Xmas Trees -- Star (Lit Version) on Xmas Trees
minetest.register_node("snow:star_lit", { nodedef.description = nodedef.description.." Lighted"
description = "Star Lighted", nodedef.light_source = LIGHT_MAX
drawtype = "plantlike", nodedef.tiles = {"snow_star_lit.png"}
light_source = LIGHT_MAX, nodedef.drop = "snow:star"
tiles = {"snow_star_lit.png"}, nodedef.groups.not_in_creative_inventory = 1
wield_image = "snow_star.png", nodedef.on_punch = function(pos, node)
paramtype = "light", node.name = "snow:star"
walkable = false, minetest.set_node(pos, node)
drop = "snow:star", nodeupdate(pos)
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, end
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}),
on_punch = function(pos, node) minetest.register_node("snow:star_lit", nodedef)
node.name = "snow:star"
minetest.set_node(pos, node)
nodeupdate(pos)
end,
})
-- Plants
-- Moss -- Moss
minetest.register_node("snow:moss", { minetest.register_node("snow:moss", {
description = "Moss", description = "Moss",
@ -241,8 +157,101 @@ minetest.register_node("snow:moss", {
}, },
is_ground_content = true, is_ground_content = true,
groups = {crumbly=3, attached_node=1}, groups = {crumbly=3, attached_node=1},
furnace_burntime = 3,
}) })
-- Shrub(s)
nodedef = {
description = "Snow Shrub",
tiles = {"snow_shrub.png"},
inventory_image = "snow_shrub.png",
wield_image = "snow_shrub.png",
drawtype = "plantlike",
paramtype = "light",
waving = 1,
sunlight_propagates = true,
walkable = false,
is_ground_content = true,
buildable_to = true,
groups = {snappy=3,flammable=3,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -5/16, 0.3},
},
furnace_burntime = 5,
}
minetest.register_node("snow:shrub", table.copy(nodedef))
nodedef.tiles = {"snow_shrub.png^snow_shrub_covering.png"}
nodedef.inventory_image = "snow_shrub.png^snow_shrub_covering.png"
nodedef.wield_image = "snow_shrub.png^snow_shrub_covering.png"
nodedef.drop = "snow:shrub"
nodedef.furnace_burntime = 3
minetest.register_node("snow:shrub_covered", nodedef)
-- Flowers
if rawget(_G, "flowers") then
-- broken flowers
snow.known_plants = {}
for _,name in pairs({"dandelion_yellow", "geranium", "rose", "tulip", "dandelion_white", "viola"}) do
local flowername = "flowers:"..name
local newname = "snow:flower_"..name
local flower = minetest.registered_nodes[flowername]
minetest.register_node(newname, {
drawtype = "plantlike",
tiles = { "snow_" .. name .. ".png" },
sunlight_propagates = true,
paramtype = "light",
walkable = false,
drop = "",
groups = {snappy=3, attached_node = 1},
sounds = default.node_sound_leaves_defaults(),
selection_box = flower.selection_box
})
snow.known_plants[minetest.get_content_id(flowername)] = minetest.get_content_id(newname)
end
end
-- Leaves
local leaves = minetest.registered_nodes["default:leaves"]
nodedef = {
description = "Snow Leaves",
tiles = {"snow_leaves.png"},
waving = 1,
visual_scale = leaves.visual_scale,
drawtype = leaves.drawtype,
paramtype = leaves.paramtype,
groups = leaves.groups,
drop = leaves.drop,
sounds = leaves.sounds,
}
nodedef.groups.flammable = 1
minetest.register_node("snow:leaves", nodedef)
snow.known_plants[minetest.get_content_id("default:leaves")] = minetest.get_content_id("snow:leaves")
local apple = minetest.registered_nodes["default:apple"]
nodedef = {
description = "Snow Apple",
drawtype = "plantlike",
tiles = {"snow_apple.png"},
paramtype = "light",
walkable = false,
sunlight_propagates = apple.sunlight_propagates,
selection_box = apple.selection_box,
groups = apple.groups,
sounds = apple.sounds,
drop = apple.drop,
}
nodedef.groups.flammable = 1
minetest.register_node("snow:apple", nodedef)
snow.known_plants[minetest.get_content_id("default:apple")] = minetest.get_content_id("snow:apple")
-- TODO
snow.known_plants[minetest.get_content_id("default:jungleleaves")] = minetest.get_content_id("default:jungleleaves")
local function snow_onto_dirt(pos) local function snow_onto_dirt(pos)
@ -257,12 +266,13 @@ end
-- Snow Brick -- Bricks
minetest.register_node("snow:snow_brick", {
nodedef = {
description = "Snow Brick", description = "Snow Brick",
tiles = {"snow_snow_brick.png"}, tiles = {"snow_snow_brick.png"},
is_ground_content = true, is_ground_content = true,
freezemelt = "default:water_source", --freezemelt = "default:water_source", -- deprecated
liquidtype = "none", liquidtype = "none",
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
@ -281,33 +291,32 @@ minetest.register_node("snow:snow_brick", {
-- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could also -- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could also
-- double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ -- double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
on_construct = snow_onto_dirt on_construct = snow_onto_dirt
}
-- Snow Brick
minetest.register_node("snow:snow_brick", table.copy(nodedef))
-- hard Ice Brick, original texture from LazyJ
local ibdef = table.copy(nodedef)
ibdef.description = "Ice Brick"
ibdef.tiles = {"snow_ice_brick.png"}
ibdef.use_texture_alpha = true
ibdef.drawtype = "glasslike"
ibdef.groups = {cracky=1, crumbly=1, choppy=1, melts=1}
ibdef.sounds = default.node_sound_glass_defaults({
dug = {name="default_hard_footstep", gain=1}
}) })
minetest.register_node("snow:ice_brick", ibdef)
-- Snow Cobble ~ LazyJ -- Snow Cobble ~ LazyJ
-- Described as Icy Snow -- Described as Icy Snow
minetest.register_node("snow:snow_cobble", { nodedef.description = "Icy Snow"
description = "Icy Snow", nodedef.tiles = {"snow_snow_cobble.png"}
tiles = {"snow_snow_cobble.png"},
is_ground_content = true, minetest.register_node("snow:snow_cobble", nodedef)
liquidtype = "none",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
-- I made this a little harder to dig than snow blocks because
-- I imagine snow brick as being much more dense and solid than fluffy snow. ~ LazyJ
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1, icemaker=1, cooks_into_ice=1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_snow_footstep", gain=0.25},
dig = {name="default_dig_crumbly", gain=0.4},
dug = {name="default_snow_footstep", gain=0.75},
place = {name="default_place_node", gain=1.0}
}),
-- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could also
-- double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
on_construct = snow_onto_dirt
})

View File

@ -98,7 +98,7 @@ local function leave_sled(self, player)
local name = player:get_player_name() local name = player:get_player_name()
players_sled[name] = false players_sled[name] = false
self.driver = nil self.driver = nil
player:set_detach() self.object:set_detach()
default.player_attached[name] = false default.player_attached[name] = false
default.player_set_animation(player, "stand" , 30) default.player_set_animation(player, "stand" , 30)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

After

Width:  |  Height:  |  Size: 643 B

BIN
mods/snow/textures/snow_apple.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

BIN
mods/snow/textures/snow_rose.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

BIN
mods/snow/textures/snow_shrub.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

BIN
mods/snow/textures/snow_tulip.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

BIN
mods/snow/textures/snow_viola.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B