1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01: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
flowers?
moreblocks?
technic_worldgen?

View File

@ -50,7 +50,6 @@ http://github.com/Splizard/minetest-mod-snow/
-- Original init.lua File Broken into Smaller Files
dofile(minetest.get_modpath("snow").."/src/abms.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/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.
-- 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/basic_stairs_slabs.lua")
dofile(minetest.get_modpath("snow").."/src/mapgen.lua")
dofile(minetest.get_modpath("snow").."/src/sled.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,
chance = 1,
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))))
end,
})
@ -42,15 +42,17 @@ minetest.register_abm({
minetest.register_abm({
nodenames = {"group:melts"},
neighbors = {"group:igniter","default:torch","default:furnace_active","group:hot"},
interval = 2,
neighbors = {"group:igniter", "default:torch", "default:furnace_active", "group:hot"},
interval = 10,
chance = 2,
action = function(pos, node)
local intensity = minetest.get_item_group(node.name,"melts")
if intensity == 1 then
minetest.add_node(pos,{name="default:water_source"})
minetest.set_node(pos, {name="default:water_source"})
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
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
@ -76,7 +78,9 @@ minetest.register_abm({
end
end)
--]]
end
else
return
end
nodeupdate(pos)
end,
})
@ -184,7 +188,7 @@ minetest.register_abm({
nodenames = {"snow:xmas_tree"},
interval = 10,
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
for i = 1,8 do

View File

@ -6,77 +6,86 @@
-- 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
-- "attempt to index global 'snow' (a nil value)" and
-- refuse to load. So a value without definition "={}"is assigned to snow.
local placer_pos = placer:getpos()
if placer_pos then
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>
function snow_stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
minetest.register_node("snow:stair_" .. subname, {
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 function register_stair(subname, recipeitem, newdef)
local def = table.copy(stairdef)
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
local placer_pos = placer:getpos()
if placer_pos then
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
for n,i in pairs(newdef) do
def[n] = i
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
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
})
local name = "snow:stair_" .. subname
minetest.register_node(name, def)
--[[
-- for replace ABM
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({
output = 'snow:stair_' .. subname .. ' 6',
output = name .. " 6",
recipe = {
{recipeitem, "", ""},
{recipeitem, recipeitem, ""},
@ -95,7 +104,7 @@ function snow_stairs.register_stair(subname, recipeitem, groups, images, descrip
-- Flipped recipe
minetest.register_craft({
output = 'snow:stair_' .. subname .. ' 6',
output = name .. " 6",
recipe = {
{"", "", recipeitem},
{"", recipeitem, recipeitem},
@ -104,59 +113,76 @@ function snow_stairs.register_stair(subname, recipeitem, groups, images, descrip
})
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>
function snow_stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
minetest.register_node("snow:slab_" .. subname, {
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},
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
local function register_slab(subname, recipeitem, newdef)
local def = table.copy(slabdef)
local name = "snow:slab_" .. subname
def.on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
-- If it's being placed on an another similar one, replace it with
-- a full block
local slabpos, slabnode
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.get_node(p0)
local n1 = minetest.get_node(p1)
local n0_is_upside_down = (n0.name == name and
n0.param2 >= 20)
if n0.name == name
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
return itemstack
end
-- If it's being placed on an another similar one, replace it with
-- a full block
local slabpos = nil
local slabnode = nil
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.get_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)
local param2
-- Upside down slabs
if p0.y-1 == p1.y then
-- Turn into full block if pointing at a existing slab
if n0_is_upside_down 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 = slabpos
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
@ -164,57 +190,27 @@ function snow_stairs.register_slab(subname, recipeitem, groups, images, descript
itemstack:set_count(fakestack:get_count())
-- Else put old node back
else
minetest.set_node(slabpos, slabnode)
minetest.set_node(p0, n0)
end
return itemstack
end
-- Upside down slabs
if p0.y-1 == p1.y then
-- Turn into full block if pointing at a existing slab
if n0_is_upside_down 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
-- Place upside down slab
param2 = 20
elseif n0_is_upside_down
and p0.y+1 ~= p1.y then
-- If pointing at the side of a upside down slab
if n0_is_upside_down and p0.y+1 ~= p1.y then
param2 = 20
end
param2 = 20
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
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 n,i in pairs(newdef) do
def[n] = i
end
})
minetest.register_node(name, def)
--[[
-- for replace ABM
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({
output = 'snow:slab_' .. subname .. ' 6',
output = name .. " 6",
recipe = {
{recipeitem, recipeitem, recipeitem},
},
@ -259,9 +255,31 @@ minetest.register_abm({
-- features (freezing, melting, and how they change dirt and dirt_with_grass). ~ LazyJ
-- 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)
snow_stairs.register_stair(subname, recipeitem, groups, images, desc_stair, freezemelt, liquidtype, paramtype, sunlight_propagates)
snow_stairs.register_slab(subname, recipeitem, groups, images, desc_slab, freezemelt, liquidtype, paramtype, sunlight_propagates)
local function register_stair_and_slab(subname, recipeitem, def)
local recipedef = minetest.registered_nodes[recipeitem]
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
@ -269,58 +287,16 @@ list_of_snow_stuff = {
--{"row[1] = first item in row",
-- "row[2] = second item in row",
-- "row[3] = third item in row", and so on, and so on...}, ~ LazyJ
{"ice", "default:ice", "default_ice.png", "Ice Stairs", "Ice Slabs"},
{"snowblock", "default:snowblock", "default_snow.png", "Snowblock Stairs", "Snowblock Slabs"},
{"snow_cobble", "snow:snow_cobble", "snow_snow_cobble.png", "Snow Cobble Stairs", "Snow Cobble Slabs"},
{"snow_brick", "snow:snow_brick", "snow_snow_brick.png", "Snow Brick Stair", "Snow Brick Slab"},
{"ice", "default:ice", "Ice Stairs", "Ice Slabs"},
{"snowblock", "default:snowblock", "Snowblock Stairs", "Snowblock Slabs"},
{"snow_cobble", "snow:snow_cobble", "Snow Cobble Stairs", "Snow Cobble Slabs"},
{"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
local snow_subname = row[1]
local snow_recipeitem = row[2]
local snow_images = row[3]
local snow_desc_stair = row[4]
local snow_desc_slab = row[5]
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(),
})
for _, row in pairs(list_of_snow_stuff) do
register_stair_and_slab(row[1], row[2], {
stair_desc = row[3],
slab_desc = row[4],
})
end

View File

@ -1,51 +1,17 @@
--[[
Crafting Sections (in order, top to bottom):
1. Fuel
2. Cooking
3. Crafting and Recycling
1. Cooking
2. Crafting and Recycling
The crafting recipe for the sled is in the sled.lua file.
~ LazyJ
--]]
-- 1. Fuel
minetest.register_craft({
type = "fuel",
recipe = "snow:needles",
burntime = 1,
})
]]
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
-- 1. Cooking
--[[
"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.
~ LazyJ
--]]
]]
minetest.register_craft({
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
-- gives another useful purpose to pine needles. ~ LazyJ
minetest.register_craft({
output = 'snow:moss',
recipe = {
{'snow:needles', 'snow:needles'},
{'snow:needles', 'snow:needles'},
},
output = "snow:moss",
recipe = {
{"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({
type = "shapeless",
output = 'default:snowblock 2',
output = "default:snowblock 2",
recipe = {
'snow:snow_cobble',
'snow:snow_cobble'
}
"snow:snow_cobble",
"snow:snow_cobble"
}
})
--[[minetest.register_craft({
type = "shapeless",
output = 'default:snowblock 3',
output = "default:snowblock 3",
recipe = {
'default:snowblock',
'default:snowblock'
}
"default:snowblock",
"default:snowblock"
}
})]]
minetest.register_craft({
output = 'snow:snow_brick',
recipe = {
{'default:snowblock', 'default:snowblock'},
{'default:snowblock', 'default:snowblock'}
}
output = "snow:snow_brick",
recipe = {
{"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.
minetest.register_craft({
type = "shapeless",
output = 'snow:snow_cobble 6',
output = "snow:snow_cobble 6",
recipe = {
'default:snow',
'default:snow',
'default:snow',
'default:snow',
'default:snow',
'default:snow',
'default:ice',
'default:ice',
'default:ice'
}
"default:snow",
"default:snow",
"default:snow",
"default:snow",
"default:snow",
"default:snow",
"default:ice",
"default:ice",
"default:ice"
}
})
minetest.register_craft({
type = "shapeless",
output = 'snow:snow_cobble 4',
output = "snow:snow_cobble 4",
recipe = {
'default:snow',
'default:snow',
'default:snow',
'default:snow',
'default:ice',
'default:ice'
}
"default:snow",
"default:snow",
"default:snow",
"default:snow",
"default:ice",
"default:ice"
}
})
minetest.register_craft({
type = "shapeless",
output = 'snow:snow_cobble 2',
output = "snow:snow_cobble 2",
recipe = {
'default:snow',
'default:snow',
'default:ice'
}
"default:snow",
"default:snow",
"default:ice"
}
})
minetest.register_craft({
type = "shapeless",
output = 'snow:snow_cobble',
output = "snow:snow_cobble",
recipe = {
'default:snow',
'default:ice'
}
})
-- Why not recycle snow_bricks back into snowblocks? ~ LazyJ
minetest.register_craft({
output = 'default:snowblock 4',
recipe = {
{'snow:snow_brick'}
}
"default:snow",
"default:ice"
}
})

View File

@ -74,17 +74,6 @@ function snow.make_pine(pos,snow,xmas)
minetest.add_node(pos, node)
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
minetest.remove_node(pos)
minetest.spawn_tree(pos, xmas_tree)
@ -126,18 +115,10 @@ function snow.voxelmanip_pine(pos,a,data)
for x = -1,1 do
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.
for i = 1,2 do
local node = a:index(x,pos.y+i,z)
data[node] = c_pine_needles
if snow
and x ~= 0
data[a:index(x,pos.y+i,z)] = c_pine_needles
if x ~= 0
and z ~= 0
and perlin1:get2d({x=x,y=z}) > 0.53 then
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,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
data[a:index(x+1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x-1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x,y=z+1}) > 0.53 then
data[a:index(x,y+1,z+1)] = c_snow
end
if perlin1:get2d({x=x,y=z-1}) > 0.53 then
data[a:index(x,y+1,z-1)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x+1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x+1,y=z}) > 0.53 then
data[a:index(x-1,y+1,z)] = c_snow
end
if perlin1:get2d({x=x,y=z+1}) > 0.53 then
data[a:index(x,y+1,z+1)] = c_snow
end
if perlin1:get2d({x=x,y=z-1}) > 0.53 then
data[a:index(x,y+1,z-1)] = c_snow
end
end
for i=0, 4 do
@ -174,8 +153,7 @@ function snow.voxelmanip_pine(pos,a,data)
end
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
if snow
and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
if perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
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
local np_cold = {
@ -31,32 +42,85 @@ local function biome_to_string(num,num2)
return biome
end
local function do_ws_func(a, x)
local n = x/(16000)
local y = 0
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
return y
end
local ws_lists = {}
local function get_ws_list(a,x)
ws_lists[a] = ws_lists[a] or {}
local v = ws_lists[a][x]
if v then
return v
end
v = {}
for x=x,x + (80 - 1) do
local y = do_ws_func(a, x)
v[x] = y
end
ws_lists[a][x] = v
return v
local plantlike_ids = {}
local function is_plantlike(id)
if plantlike_ids[id] ~= nil then
return plantlike_ids[id]
end
local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not node then
plantlike_ids[id] = false
return false
end
local drawtype = node.drawtype
if not drawtype
or drawtype ~= "plantlike" then
plantlike_ids[id] = false
return false
end
plantlike_ids[id] = true
return true
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)
local t1 = os.clock()
@ -66,45 +130,30 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = maxp.x
local z1 = maxp.z
local spawn_pine = snow.voxelmanip_pine
local smooth = snow.smooth_biomes
local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass")
local c_dirt = minetest.get_content_id("default:dirt")
local c_tree = minetest.get_content_id("default:tree")
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")
if not c then
define_contents()
end
local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(minp, maxp)
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
local data = vm:get_data()
local param2s = vm:get_param2_data()
local snow_tab,num = {},1
local pines_tab,pnum = {},1
local sidelen = x1 - x0 + 1
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_ice = minetest.get_perlin_map(np_ice, 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_cold, nvals_ice
-- Choose biomes
local pr = PseudoRandom(seed+57)
-- Land biomes
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
-- Misc biome settings
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 x = x0, x1 do
local in_biome = false
local test = nvals_cold[ni]
if smooth and (not snowy)
and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then
in_biome = true
elseif (not smooth or snowy) and test > 0.53 then
in_biome = true
end
local test
if nvals_default[ni] < 0.35 then
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)
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 alpine and test > 0.43 then
if alpine
and test
and test > 0.43 then
-- remove trees near alpine
local ground_y = nil
for y = maxp.y, minp.y, -1 do
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
break
end
@ -141,16 +201,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then
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
local vi = area:index(x, y, z)
local id = data[vi]
if id ~= c_air then
if id == c_leaves
or id == c_jungleleaves
or id == c_tree
or id == c_apple then
data[vi] = c_air
if id ~= c.air then
if id == c.leaves
or id == c.jungleleaves
or id == c.tree
or id == c.apple then
data[vi] = c.air
else
break
end
@ -159,8 +220,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
end
elseif in_biome then
else
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 cool = icetype > 0 -- only spawns ice on edge of water
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 icecave = icetype <= -0.6
local ground_y = nil
local ground_y
for y = maxp.y, minp.y, -1 do
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
break
end
@ -179,98 +243,68 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then
local node = area:index(x, ground_y, z)
local abovenode = area:index(x, ground_y+1, z)
local belownode = area:index(x, ground_y-1, z)
local c_ground = data[node]
if ground_y and data[node] == c_dirt_with_grass then
if alpine and test > 0.53 then
snow_tab[num] = {abovenode, z, x, test}
if c_ground == c.dirt_with_grass then
if alpine
and test > 0.53 then
snow_tab[num] = {ground_y, z, x, test}
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)
if data[vi] == c_stone then
if data[vi] == c.stone then
break
else
data[vi] = c_stone
end
data[vi] = c.stone
end
elseif (shrubs and pr:next(1,28) == 1) then
data[node] = c_dirt_with_snow
data[abovenode] = c_dry_shrub
elseif pines and pr:next(1,36) == 1 then
data[node] = c_dirt_with_snow
spawn_pine({x=x, y=ground_y+1, z=z}, area, data)
elseif snowy and test > 0.63 then
data[abovenode] = c_snow_block
elseif pines
and pr:next(1,36) == 1 then
pines_tab[pnum] = {x=x, y=ground_y+1, z=z}
pnum = pnum+1
elseif shrubs
and pr:next(1,928) == 1 then
data[node] = c.dirt_with_snow
data[area:index(x, ground_y+1, z)] = c.dry_shrub
else
data[node] = c_dirt_with_snow
snow_tab[num] = {abovenode, z, x, test}
num = num+1
end
elseif ground_y and data[node] == c_sand then
if not icy then
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
if snowy
or test > 0.8 then
-- more, deeper snow
data[node] = c.snow_block
else
data[node] = c.dirt_with_snow
end
else
snow_tab[num] = {abovenode, z, x, test}
snow_tab[num] = {ground_y, z, x, test}
num = num+1
end
elseif ground_y
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
elseif c_ground == c.water then
if not icesheet
and not icecave
and not icehole then
local x1 = data[area:index(x+1, ground_y, z)]
local z1 = data[area:index(x, ground_y, z+1)]
local xz1 = data[area:index(x+1, ground_y, z+1)]
local xz2 = data[area:index(x-1, ground_y, z-1)]
local x2 = data[area:index(x-1, ground_y, z)]
local z2 = data[area:index(x, ground_y, z-1)]
local rand = (pr:next(1,4) == 1) and (cool or icebergs)
local nds = {
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 rand then
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do
if i == c_ice then
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
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) do
if i ~= c_water
and i ~= c_ice
and i ~= c_air
and i ~= c_ignore then
for _,i in ipairs(nds) do
if i ~= c.water
and i ~= c.ice
and i ~= c.air
and i ~= c.ignore then
ice = true
break
end
@ -278,26 +312,94 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
local y = data[area:index(x, ground_y-1, z)]
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
data[node] = c_ice
data[node] = c.ice
end
else
if (icehole and pr:next(1,10) > 1)
if icesheet
or icecave
or icesheet then
data[node] = c_ice
or (icehole and pr:next(1,10) > 1) then
data[node] = c.ice
end
if icecave then
for y = ground_y-1, -33, -1 do
local vi = area:index(x, y, z)
if data[vi] ~= c_water then
if data[vi] ~= c.water then
break
else
data[vi] = c_air
end
data[vi] = c.air
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
@ -306,37 +408,64 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
local param2s
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
for _,i in pairs(snow_tab) do
local p,z,x,test = unpack(i)
data[p] = c_snow
test = test-0.73
local y,z,x,test = unpack(i)
test = (test-0.53)/0.47 -- /(1-0.53)
if test > 0 then
local minh = math.floor(test*4*9)%9+1
if minh ~= 1 then
if not wsz then
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)
local maxh = math.floor(test*10)%10+1
if maxh ~= 1 then
local h = math.floor( do_ws_func(2, x) + do_ws_func(5, z)*5)%10+1
if h ~= 1 then
if h == 9 then
h = 4
-- search for nearby snow
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
param2s[p] = h*7
end
end
end
end
end
vm:set_data(data)
if param2s then
vm:set_param2_data(param2s)
-- spawn pines
if pines
and pnum ~= 1 then
local spawn_pine = snow.voxelmanip_pine
for _,pos in pairs(pines_tab) do
spawn_pine(pos, area, data)
end
end
vm:set_data(data)
vm:set_param2_data(param2s)
vm:set_lighting({day=0, night=0})
vm:calc_lighting()
vm:write_to_map()

View File

@ -1,7 +1,7 @@
-- NODES
-- Pine Needles
minetest.register_node("snow:needles",{
local nodedef = {
description = "Pine Needles",
drawtype = "allfaces_optional",
visual_scale = 1.3,
@ -9,6 +9,7 @@ minetest.register_node("snow:needles",{
waving = 1,
paramtype = "light",
groups = {snappy=3, leafdecay=5},
furnace_burntime = 1,
drop = {
max_items = 1,
items = {
@ -18,14 +19,12 @@ minetest.register_node("snow:needles",{
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'snow:needles'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
}
--[[
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.
~ LazyJ
--]]
]]
if snow.christmas_content then
--Christmas trees
minetest.override_item("snow:needles", {
drop = {
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'},
}
}
}
table.insert(nodedef.drop.items, 1, {
-- player will get xmas tree with 1/120 chance
items = {'snow:xmas_tree'},
rarity = 120,
})
end
minetest.register_node("snow:needles", table.copy(nodedef))
--Christmas easter egg
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
minetest.register_node("snow:needles_decorated", {
description = "Decorated Pine Needles",
drawtype = "allfaces_optional",
light_source = 5,
inventory_image = minetest.inventorycube("snow_needles_decorated.png"),
--tiles = {"snow_needles_decorated.png"},
tiles = {
nodedef.description ="Decorated "..nodedef.description
nodedef.light_source = 5
nodedef.waving = nil
if snow.disable_deco_needle_ani then
nodedef.tiles = {"snow_needles_decorated.png"}
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}}
},
paramtype = "light",
groups = {snappy=3, leafdecay=5},
drop = {
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_decorated'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
}
end
nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
minetest.register_node("snow:needles_decorated", nodedef)
-- Saplings
-- 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", {
nodedef = {
description = "Pine Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
@ -178,55 +87,62 @@ minetest.register_node("snow:sapling_pine", {
paramtype = "light",
walkable = false,
groups = {snappy=2,dig_immediate=3},
furnace_burntime = 10,
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)
-- Star on Xmas Trees
minetest.register_node("snow:star", {
nodedef = {
description = "Star",
--drawtype = "torchlike",
drawtype = "plantlike", -- Stars disappeared when viewed at the right angle. "Plantlike" solved the visual problem. ~ LazyJ
drawtype = "plantlike",
tiles = {"snow_star.png"},
inventory_image = "snow_star.png",
wield_image = "snow_star.png",
paramtype = "light",
walkable = false,
--groups = {snappy=2,dig_immediate=3},
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
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
-- 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},
-- 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
node.name = "snow:star_lit"
minetest.set_node(pos, node)
nodeupdate(pos)
end,
})
}
-- Star on Xmas Trees
minetest.register_node("snow:star", table.copy(nodedef))
-- Star (Lit Version) on Xmas Trees
minetest.register_node("snow:star_lit", {
description = "Star Lighted",
drawtype = "plantlike",
light_source = LIGHT_MAX,
tiles = {"snow_star_lit.png"},
wield_image = "snow_star.png",
paramtype = "light",
walkable = false,
drop = "snow:star",
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}),
on_punch = function(pos, node)
node.name = "snow:star"
minetest.set_node(pos, node)
nodeupdate(pos)
end,
})
nodedef.description = nodedef.description.." Lighted"
nodedef.light_source = LIGHT_MAX
nodedef.tiles = {"snow_star_lit.png"}
nodedef.drop = "snow:star"
nodedef.groups.not_in_creative_inventory = 1
nodedef.on_punch = function(pos, node)
node.name = "snow:star"
minetest.set_node(pos, node)
nodeupdate(pos)
end
minetest.register_node("snow:star_lit", nodedef)
-- Plants
-- Moss
minetest.register_node("snow:moss", {
description = "Moss",
@ -241,8 +157,101 @@ minetest.register_node("snow:moss", {
},
is_ground_content = true,
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)
@ -257,12 +266,13 @@ end
-- Snow Brick
minetest.register_node("snow:snow_brick", {
-- Bricks
nodedef = {
description = "Snow Brick",
tiles = {"snow_snow_brick.png"},
is_ground_content = true,
freezemelt = "default:water_source",
--freezemelt = "default:water_source", -- deprecated
liquidtype = "none",
paramtype = "light",
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
-- double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
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
-- Described as Icy Snow
minetest.register_node("snow:snow_cobble", {
description = "Icy Snow",
tiles = {"snow_snow_cobble.png"},
is_ground_content = true,
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
})
nodedef.description = "Icy Snow"
nodedef.tiles = {"snow_snow_cobble.png"}
minetest.register_node("snow:snow_cobble", nodedef)

View File

@ -98,7 +98,7 @@ local function leave_sled(self, player)
local name = player:get_player_name()
players_sled[name] = false
self.driver = nil
player:set_detach()
self.object:set_detach()
default.player_attached[name] = false
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