forked from mtcontrib/minetest-mod-snow
Compare commits
13 Commits
nalc-1.2.0
...
master
Author | SHA1 | Date |
---|---|---|
bri cassa | d1d6a701fb | |
bri cassa | e3164a1963 | |
bri cassa | 253c7b25a9 | |
Emojigit | ce0442fe25 | |
bri cassa | f236cd705d | |
HybridDog | 58ac474139 | |
HybridDog | 9dc9ab3a39 | |
bri cassa | 4f4489fc93 | |
bri cassa | 73cf3790fa | |
bri cassa | 8dae0a0246 | |
Sys Quatre | db6bf1d1b2 | |
HybridDog | e8a15bf467 | |
HybridDog | 76981af958 |
|
@ -0,0 +1,11 @@
|
|||
on: [push, pull_request]
|
||||
name: luacheck
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: lint
|
||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
||||
with:
|
||||
luacheckrc_url: ""
|
|
@ -0,0 +1,25 @@
|
|||
read_globals = {
|
||||
"dump", "vector",
|
||||
"table", "math", "PseudoRandom", "VoxelArea",
|
||||
"stairs", "stairsplus", "skins", "treecapitator",
|
||||
default = {
|
||||
fields = {
|
||||
player_attached = {
|
||||
read_only = false,
|
||||
other_fields = true
|
||||
}
|
||||
},
|
||||
other_fields = true
|
||||
},
|
||||
minetest = {
|
||||
fields = {
|
||||
registered_nodes = {
|
||||
read_only = false,
|
||||
other_fields = true
|
||||
}
|
||||
},
|
||||
other_fields = true
|
||||
}
|
||||
}
|
||||
globals = {"snow"}
|
||||
-- ignore = {"421", "423"}
|
|
@ -1,6 +0,0 @@
|
|||
default
|
||||
christmas_craft?
|
||||
flowers?
|
||||
moreblocks?
|
||||
skins?
|
||||
treecapitator?
|
4
mod.conf
4
mod.conf
|
@ -1 +1,5 @@
|
|||
name = snow
|
||||
title = Snow
|
||||
description = Adds snow biomes and related nodes.
|
||||
depends = default
|
||||
optional_depends = christmas_craft,flowers,stairs,moreblocks,skins,treecapitator
|
||||
|
|
29
src/abms.lua
29
src/abms.lua
|
@ -1,10 +1,12 @@
|
|||
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
|
||||
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let
|
||||
-- light through (sunlight_propagates) or have a light paramtype and
|
||||
-- liquidtype combination. ~ LazyJ, 2014_03_08
|
||||
|
||||
--[[minetest.register_abm({
|
||||
nodenames = {"default:dirt_with_snow"},
|
||||
interval = 2,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
local name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
|
||||
local nodedef = minetest.registered_nodes[name]
|
||||
if name ~= "ignore"
|
||||
|
@ -37,9 +39,9 @@ minetest.register_abm({
|
|||
if intensity == 1 then
|
||||
minetest.set_node(pos, {name="default:water_source"})
|
||||
elseif intensity == 2 then
|
||||
minetest.set_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})
|
||||
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
|
||||
|
@ -61,11 +63,11 @@ minetest.register_abm({
|
|||
-- the water to flow and spread before the
|
||||
-- water_source is changed to air. ~ LazyJ
|
||||
if minetest.get_node(pos).name == "default:water_source" then
|
||||
minetest.add_node(pos,{name="air"})
|
||||
end
|
||||
end)
|
||||
minetest.add_node(pos,{name="air"})
|
||||
end
|
||||
end)
|
||||
--]]
|
||||
else
|
||||
else
|
||||
return
|
||||
end
|
||||
end,
|
||||
|
@ -79,7 +81,7 @@ minetest.register_abm({
|
|||
--[[
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:water_source"},
|
||||
-- Added "group:icemaker" and snowbrick. ~ LazyJ
|
||||
-- Added "group:icemaker" and snowbrick. ~ LazyJ
|
||||
neighbors = {"default:snow", "default:snowblock", "snow:snow_brick", "group:icemaker"},
|
||||
interval = 20,
|
||||
chance = 4,
|
||||
|
@ -107,7 +109,10 @@ minetest.register_abm({
|
|||
if math.random(2) == 2 then
|
||||
p.y = pos.y
|
||||
if minetest.get_node(p).name == "default:water_source" then
|
||||
minetest.add_node(p,{name="default:ice", param2 = math.random(0,node.param2-1)})
|
||||
minetest.add_node(p, {
|
||||
name = "default:ice",
|
||||
param2 = math.random(0,node.param2-1)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -145,7 +150,7 @@ minetest.register_abm({
|
|||
nodenames = {"snow:sapling_pine"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
|
||||
-- Check if there is enough vertical-space for the sapling to grow without
|
||||
-- hitting anything else. ~ LazyJ, 2014_04_10
|
||||
|
@ -177,7 +182,7 @@ minetest.register_abm({
|
|||
nodenames = {"snow:xmas_tree"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
|
||||
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
|
||||
for i = 1,8 do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- Parameters
|
||||
|
||||
function snow_fall(pos, player, animate)
|
||||
local function snow_fall(pos)
|
||||
local ground_y = nil
|
||||
for y=pos.y+10,pos.y+20,1 do
|
||||
local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name
|
||||
|
@ -32,8 +32,8 @@ local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
|||
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
||||
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
||||
local FLAKES = 32 -- Snowflakes per cycle
|
||||
local DROPS = 128 -- Raindrops per cycle
|
||||
local RAINGAIN = 0.2 -- Rain sound volume
|
||||
--~ local DROPS = 128 -- Raindrops per cycle
|
||||
--~ local RAINGAIN = 0.2 -- Rain sound volume
|
||||
local COLLIDE = false -- Whether particles collide with nodes
|
||||
local NISVAL = 39 -- Clouds RGB value at night
|
||||
local DASVAL = 175 -- Clouds RGB value in daytime
|
||||
|
@ -81,12 +81,6 @@ local grad = 14 / 95
|
|||
local yint = 1496 / 95
|
||||
|
||||
|
||||
-- Initialise noise objects to nil
|
||||
|
||||
local nobj_temp = nil
|
||||
local nobj_humid = nil
|
||||
local nobj_prec = nil
|
||||
|
||||
|
||||
-- Globalstep function
|
||||
local timer = 0
|
||||
|
@ -102,20 +96,20 @@ if snow.enable_snowfall then
|
|||
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
local ppos = player:getpos()
|
||||
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
||||
local pos_player = player:get_pos()
|
||||
local pposy = math.floor(pos_player.y) + 2 -- Precipitation when swimming
|
||||
if pposy >= YLIMIT - 2 then
|
||||
local pposx = math.floor(ppos.x)
|
||||
local pposz = math.floor(ppos.z)
|
||||
local pposx = math.floor(pos_player.x)
|
||||
local pposz = math.floor(pos_player.z)
|
||||
local ppos = {x = pposx, y = pposy, z = pposz}
|
||||
|
||||
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
||||
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
||||
local nobj_prec = nobj_prec or minetest.get_perlin(np_prec)
|
||||
local nobj_temp = minetest.get_perlin(np_temp)
|
||||
local nobj_humid = minetest.get_perlin(np_humid)
|
||||
local nobj_prec = minetest.get_perlin(np_prec)
|
||||
|
||||
local nval_temp = nobj_temp:get2d({x = pposx, y = pposz})
|
||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||
local nval_prec = nobj_prec:get2d({x = os.clock() / 60, y = 0})
|
||||
local nval_temp = nobj_temp:get_2d({x = pposx, y = pposz})
|
||||
local nval_humid = nobj_humid:get_2d({x = pposx, y = pposz})
|
||||
local nval_prec = nobj_prec:get_2d({x = os.clock() / 60, y = 0})
|
||||
|
||||
-- Biome system: Frozen biomes below heat 35,
|
||||
-- deserts below line 14 * t - 95 * h = -1496
|
||||
|
@ -128,7 +122,7 @@ if snow.enable_snowfall then
|
|||
local freeze = nval_temp < 35
|
||||
local precip = nval_prec < (nval_humid - 50) / 50 + PRECOFF and
|
||||
nval_humid - grad * nval_temp > yint
|
||||
|
||||
|
||||
if snow.debug then
|
||||
precip = true
|
||||
end
|
||||
|
@ -157,14 +151,13 @@ if snow.enable_snowfall then
|
|||
((time - 0.1875) / 0.0521) * difsval)
|
||||
end
|
||||
-- Set sky to overcast bluish-grey
|
||||
player:set_sky(
|
||||
{r = sval, g = sval, b = sval + 16, a = 255},
|
||||
"plain",
|
||||
{}
|
||||
)
|
||||
player:set_sky({
|
||||
base_color = {r = sval, g = sval, b = sval + 16, a = 255},
|
||||
type = "plain",
|
||||
})
|
||||
else
|
||||
-- Reset sky to normal
|
||||
player:set_sky({}, "regular", {})
|
||||
player:set_sky({type = "regular"})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,9 +166,9 @@ if snow.enable_snowfall then
|
|||
if freeze then
|
||||
-- Snowfall
|
||||
local extime = math.min((pposy + 12 - YLIMIT) / 2, 9)
|
||||
|
||||
|
||||
local x, y, z = pposx - 24 + math.random(0, 48), pposy + 12, pposz - 24 + math.random(0, 48)
|
||||
|
||||
|
||||
if not snow.lighter_snowfall then
|
||||
snow_fall({
|
||||
x = x,
|
||||
|
@ -183,11 +176,11 @@ if snow.enable_snowfall then
|
|||
z = z
|
||||
}, true)
|
||||
end
|
||||
|
||||
for flake = 1, FLAKES do
|
||||
|
||||
|
||||
for _ = 1, FLAKES do
|
||||
|
||||
x, y, z = pposx - 24 + math.random(0, 48), pposy + 12, pposz - 24 + math.random(0, 48)
|
||||
|
||||
|
||||
minetest.add_particle({
|
||||
pos = {
|
||||
x = x,
|
||||
|
@ -207,7 +200,7 @@ if snow.enable_snowfall then
|
|||
vertical = false,
|
||||
texture = "snowdrift_snowflake" ..
|
||||
math.random(1, 12) .. ".png",
|
||||
playername = player:get_player_name()
|
||||
playername = player_name
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,6 @@ if not snow.disable_mapgen then
|
|||
nosmooth_rarity = 1-rarity/50
|
||||
perlin_scale = size*100/rarity
|
||||
mg.perlin_scale = perlin_scale
|
||||
local smooth_rarity_max, smooth_rarity_min, smooth_rarity_dif
|
||||
if smooth then
|
||||
local smooth_trans_size = 4 --snow.smooth_trans_size
|
||||
mg.smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
|
||||
|
@ -110,11 +109,11 @@ local xmas_tree = {
|
|||
--Makes pine tree
|
||||
function snow.make_pine(pos,snow,xmas)
|
||||
local minetest = minetest
|
||||
local try_node = function(pos, node)
|
||||
local n = minetest.get_node(pos).name
|
||||
local function try_node(p, node)
|
||||
local n = minetest.get_node(p).name
|
||||
if n == "air"
|
||||
or n == "ignore" then
|
||||
minetest.add_node(pos, node)
|
||||
minetest.add_node(p, node)
|
||||
end
|
||||
end
|
||||
if xmas then
|
||||
|
@ -138,7 +137,7 @@ function snow.make_pine(pos,snow,xmas)
|
|||
if xmas then
|
||||
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star_lit"}) -- Added lit star. ~ LazyJ
|
||||
elseif snow
|
||||
and minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
||||
and minetest.get_perlin(112,3, 0.5, perlin_scale):get_2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
||||
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="default:snow"})
|
||||
end
|
||||
end
|
||||
|
@ -149,21 +148,20 @@ end
|
|||
function snow.voxelmanip_pine(pos,a,data)
|
||||
local c_snow = minetest.get_content_id("default:snow")
|
||||
local c_pine_needles = minetest.get_content_id("snow:needles")
|
||||
local c_pinetree = minetest.get_content_id("default:pine_tree")
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_pinetree = minetest.get_content_id("default:pinetree")
|
||||
|
||||
local perlin1 = minetest.get_perlin(112,3, 0.5, perlin_scale)
|
||||
for z = -1,1 do
|
||||
local z = pos.z + z
|
||||
for x = -1,1 do
|
||||
local x = pos.x + x
|
||||
for off_z = -1,1 do
|
||||
local z = pos.z + off_z
|
||||
for off_x = -1,1 do
|
||||
local x = pos.x + off_x
|
||||
|
||||
--Make tree.
|
||||
for i = 1,2 do
|
||||
data[a:index(x,pos.y+i,z)] = c_pine_needles
|
||||
if x ~= 0
|
||||
and z ~= 0
|
||||
and perlin1:get2d({x=x,y=z}) > nosmooth_rarity then
|
||||
and perlin1:get_2d({x=x,y=z}) > nosmooth_rarity then
|
||||
local abovenode = a:index(x,pos.y+i+1,z)
|
||||
data[abovenode] = c_snow
|
||||
end
|
||||
|
@ -178,16 +176,16 @@ 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 perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||
if perlin1:get_2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||
data[a:index(x+1,y+1,z)] = c_snow
|
||||
end
|
||||
if perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||
if perlin1:get_2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||
data[a:index(x-1,y+1,z)] = c_snow
|
||||
end
|
||||
if perlin1:get2d({x=x,y=z+1}) > nosmooth_rarity then
|
||||
if perlin1:get_2d({x=x,y=z+1}) > nosmooth_rarity then
|
||||
data[a:index(x,y+1,z+1)] = c_snow
|
||||
end
|
||||
if perlin1:get2d({x=x,y=z-1}) > nosmooth_rarity then
|
||||
if perlin1:get_2d({x=x,y=z-1}) > nosmooth_rarity then
|
||||
data[a:index(x,y+1,z-1)] = c_snow
|
||||
end
|
||||
end
|
||||
|
@ -196,7 +194,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 perlin1:get2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
||||
if perlin1:get_2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
||||
data[a:index(pos.x,pos.y+7,pos.z)] = c_snow
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,11 +14,11 @@ local np_default = {
|
|||
-- 2D noise for coldness
|
||||
|
||||
local mg = snow.mapgen
|
||||
local scale = mg.perlin_scale
|
||||
local scale_coldness = mg.perlin_scale
|
||||
local np_cold = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=scale, y=scale, z=scale},
|
||||
spread = {x=scale_coldness, y=scale_coldness, z=scale_coldness},
|
||||
seed = 112,
|
||||
octaves = 3,
|
||||
persist = 0.5
|
||||
|
@ -186,7 +186,9 @@ local function get_perlins(sidelen)
|
|||
}
|
||||
end
|
||||
|
||||
local nbuf_default, nbuf_cold, nbuf_ice
|
||||
local nbuf_default = {}
|
||||
local nbuf_cold = {}
|
||||
local nbuf_ice = {}
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local t1 = os.clock()
|
||||
|
||||
|
@ -210,7 +212,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local pines_tab,pnum = {},1
|
||||
|
||||
get_perlins(x1 - x0 + 1)
|
||||
local nvals_default = perlin_objs.default:get2dMap_flat({x=x0+150, y=z0+50}, nbuf_default)
|
||||
local nvals_default = perlin_objs.default:get_2dMap_flat({x=x0+150, y=z0+50}, nbuf_default)
|
||||
local nvals_cold, nvals_ice, ndia
|
||||
|
||||
-- Choose biomes
|
||||
|
@ -229,7 +231,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local nodes_added
|
||||
|
||||
-- Loop through columns in chunk
|
||||
local smooth = smooth and not snowy
|
||||
local is_smooth = smooth and not snowy
|
||||
local write_to_map = false
|
||||
local ni = 1
|
||||
for z = z0, z1 do
|
||||
|
@ -237,9 +239,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
local in_biome = false
|
||||
local test
|
||||
if nvals_default[ni] < 0.35 then
|
||||
nvals_cold = nvals_cold or perlin_objs.cold:get2dMap_flat({x=x0, y=z0}, nbuf_cold)
|
||||
nvals_cold = nvals_cold or perlin_objs.cold:get_2dMap_flat({x=x0, y=z0}, nbuf_cold)
|
||||
test = math.min(nvals_cold[ni], 1)
|
||||
if smooth then
|
||||
if is_smooth then
|
||||
if test >= smooth_rarity_max
|
||||
or (
|
||||
test > smooth_rarity_min
|
||||
|
@ -255,7 +257,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
if not in_biome then
|
||||
if alpine
|
||||
and test
|
||||
and test > (smooth and smooth_rarity_min or nosmooth_rarity) then
|
||||
and test > (is_smooth and smooth_rarity_min or nosmooth_rarity) then
|
||||
-- remove trees near alpine
|
||||
local ground_y
|
||||
if data[area:index(x, maxp.y, z)] == c.air then
|
||||
|
@ -289,7 +291,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
else
|
||||
if not nvals_ice then
|
||||
nvals_ice = perlin_objs.ice:get2dMap_flat({x=x0, y=z0}, nbuf_ice)
|
||||
nvals_ice = perlin_objs.ice:get_2dMap_flat({x=x0, y=z0}, nbuf_ice)
|
||||
|
||||
nodes_added = true
|
||||
write_to_map = true
|
||||
|
@ -345,7 +347,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
data[area:index(x, ground_y+1, z)] = c.dry_shrub
|
||||
else
|
||||
if snowy
|
||||
or test > (smooth and smooth_rarity_max or
|
||||
or test > (is_smooth and smooth_rarity_max or
|
||||
nosmooth_rarity) then
|
||||
-- more, deeper snow
|
||||
data[node] = c.snow_block
|
||||
|
@ -388,13 +390,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
and (cool or icebergs)
|
||||
and pr:next(1,4) == 1 then
|
||||
|
||||
local vi = node + 1
|
||||
local vi_ice = node + 1
|
||||
for i = 1,6 do
|
||||
if data[vi] == c.ice then
|
||||
if data[vi_ice] == c.ice then
|
||||
ice = true
|
||||
break
|
||||
end
|
||||
vi = vi + ndia[i]
|
||||
vi_ice = vi_ice + ndia[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -505,8 +507,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
-- set snow
|
||||
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
||||
end
|
||||
for i = 1, num-1 do
|
||||
i = snow_tab[i]
|
||||
for k = 1, num-1 do
|
||||
local i = snow_tab[k]
|
||||
local y,z,x,test = unpack(i)
|
||||
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
||||
if test > 0 then
|
||||
|
@ -516,8 +518,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
if h ~= 1 then
|
||||
-- search for nearby snow
|
||||
y = y+1
|
||||
for i = -1,1,2 do
|
||||
for _,cord in pairs({{x+i,z}, {x,z+i}}) do
|
||||
for off = -1,1,2 do
|
||||
for _,cord in pairs({{x+off,z}, {x,z+off}}) do
|
||||
local nd = data[area:index(cord[1], y, cord[2])]
|
||||
if nd == c.air
|
||||
or is_plantlike(nd) then
|
||||
|
@ -577,7 +579,7 @@ local biome_strings = {
|
|||
{"snowy", "plain", "alpine", "normal", "normal"},
|
||||
{"cool", "icebergs", "icesheet", "icecave", "icehole"}
|
||||
}
|
||||
function biome_to_string(num,num2)
|
||||
function biome_to_string(num)
|
||||
local biome = biome_strings[1][num] or "unknown "..num
|
||||
return biome
|
||||
end
|
||||
|
|
|
@ -108,8 +108,10 @@ snow.register_on_configuring(function(name, v)
|
|||
end
|
||||
end)
|
||||
|
||||
-- Christmas egg
|
||||
if minetest.global_exists("skins") then
|
||||
|
||||
|
||||
-- Christmas egg
|
||||
if minetest.get_modpath("skins") then
|
||||
skins.add("character_snow_man")
|
||||
end
|
||||
|
||||
|
@ -124,9 +126,11 @@ if snow.disable_deco_needle_ani then
|
|||
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}}
|
||||
}
|
||||
nodedef.tiles = {{
|
||||
name="snow_needles_decorated_animated.png",
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16,
|
||||
length=20.0}
|
||||
}}
|
||||
end
|
||||
nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
|
||||
|
||||
|
@ -193,9 +197,13 @@ nodedef = {
|
|||
walkable = false,
|
||||
-- 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
|
||||
-- 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}}),
|
||||
-- Added a "lit" star that can be punched on or off depending on your
|
||||
-- preference. ~ LazyJ
|
||||
on_punch = function(pos, node)
|
||||
node.name = "snow:star_lit"
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
|
@ -206,7 +214,7 @@ minetest.register_node("snow:star", table.copy(nodedef))
|
|||
|
||||
-- Star (Lit Version) on Xmas Trees
|
||||
nodedef.description = nodedef.description.." Lighted"
|
||||
nodedef.light_source = LIGHT_MAX
|
||||
nodedef.light_source = minetest.LIGHT_MAX
|
||||
nodedef.tiles = {"snow_star_lit.png"}
|
||||
nodedef.drop = "snow:star"
|
||||
nodedef.groups.not_in_creative_inventory = 1
|
||||
|
@ -349,8 +357,7 @@ local function snow_onto_dirt(pos)
|
|||
local node = minetest.get_node(pos)
|
||||
if node.name == "default:dirt_with_grass"
|
||||
or node.name == "default:dirt" then
|
||||
node.name = "default:dirt_with_snow"
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(pos, {name = "default:dirt_with_snow"})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -370,14 +377,10 @@ nodedef = {
|
|||
-- by player position. ~ LazyJ
|
||||
-- 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},
|
||||
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1,
|
||||
icemaker=1, cooks_into_ice=1, cools_lava = 1, snowy = 1},
|
||||
--Let's use the new snow sounds instead of the old grass sounds. ~ LazyJ
|
||||
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}
|
||||
}),
|
||||
sounds = default.node_sound_snow_defaults(),
|
||||
-- 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
|
||||
|
@ -387,17 +390,14 @@ nodedef = {
|
|||
-- 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.use_texture_alpha = "blend"
|
||||
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}
|
||||
})
|
||||
ibdef.groups = {cracky=1, crumbly=1, choppy=1, melts=1, cools_lava = 1, slippery = 3}
|
||||
ibdef.sounds = default.node_sound_ice_defaults()
|
||||
|
||||
minetest.register_node("snow:ice_brick", ibdef)
|
||||
|
||||
|
@ -409,43 +409,38 @@ nodedef.tiles = {"snow_snow_cobble.png"}
|
|||
|
||||
minetest.register_node("snow:snow_cobble", nodedef)
|
||||
|
||||
|
||||
|
||||
-- Override Default Nodes to Add Extra Functions
|
||||
|
||||
local groups = minetest.registered_nodes["default:ice"].groups
|
||||
groups["melt"] = 1
|
||||
minetest.override_item("default:ice", {
|
||||
use_texture_alpha = true,
|
||||
param2 = 0, --param2 is reserved for how much ice will freezeover.
|
||||
sunlight_propagates = true, -- necessary for dirt_with_grass/snow/just dirt ABMs
|
||||
drawtype = "glasslike",
|
||||
tiles = {"default_ice.png^[brighten"},
|
||||
use_texture_alpha = "blend",
|
||||
param2 = 0, --param2 is reserved for how much ice will freezeover.
|
||||
sunlight_propagates = true, -- necessary for dirt_with_grass/snow/just dirt ABMs
|
||||
tiles = {"snow_ice.png^[brighten"},
|
||||
liquidtype = "none",
|
||||
-- I made this a lot harder to dig than snow blocks because ice is much more dense
|
||||
-- and solid than fluffy snow. ~ LazyJ
|
||||
groups = {cracky=2, crumbly=1, choppy=1, --[[oddly_breakable_by_hand=1,]] melts=1},
|
||||
groups = groups,
|
||||
on_construct = snow_onto_dirt,
|
||||
liquids_pointable = true,
|
||||
--Make ice freeze over when placed by a maximum of 10 blocks.
|
||||
after_place_node = function(pos)
|
||||
minetest.set_node(pos, {name="default:ice", param2=math.random(0,10)})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
groups = minetest.registered_nodes["default:snowblock"].groups
|
||||
for g,v in pairs({melts=1, icemaker=1, cooks_into_ice=1, falling_node=1}) do
|
||||
groups[g] = v
|
||||
end
|
||||
minetest.override_item("default:snowblock", {
|
||||
-- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||
liquidtype = "none",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
-- Snow blocks should be easy to dig because they are just fluffy snow. ~ LazyJ
|
||||
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=1, icemaker=1, cooks_into_ice=1, falling_node=1},
|
||||
--drop = "snow:snow_cobble",
|
||||
on_construct = snow_onto_dirt
|
||||
-- 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
|
||||
on_construct = snow_onto_dirt,
|
||||
groups = groups,
|
||||
})
|
||||
|
||||
|
||||
minetest.override_item("default:snow", {
|
||||
drop = {
|
||||
max_items = 2,
|
||||
|
|
14
src/sled.lua
14
src/sled.lua
|
@ -53,8 +53,6 @@ than I originally planned. :p ~ LazyJ
|
|||
-- Helper functions
|
||||
--
|
||||
|
||||
vector.zero = vector.zero or {x=0, y=0, z=0}
|
||||
|
||||
local function table_find(t, v)
|
||||
for i = 1,#t do
|
||||
if t[i] == v then
|
||||
|
@ -83,7 +81,7 @@ local sled = {
|
|||
|
||||
local players_sled = {}
|
||||
local function join_sled(self, player)
|
||||
local pos = self.object:getpos()
|
||||
local pos = self.object:get_pos()
|
||||
player:setpos(pos)
|
||||
local name = player:get_player_name()
|
||||
players_sled[name] = true
|
||||
|
@ -91,7 +89,7 @@ local function join_sled(self, player)
|
|||
default.player_set_animation(player, "sit" , 30)
|
||||
self.driver = name
|
||||
self.object:set_attach(player, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
|
||||
self.object:setyaw(player:get_look_yaw())-- - math.pi/2)
|
||||
self.object:set_yaw(player:get_look_yaw())-- - math.pi/2)
|
||||
end
|
||||
|
||||
local function leave_sled(self, player)
|
||||
|
@ -156,9 +154,9 @@ function sled:on_rightclick(player)
|
|||
on_sled_click(self, player)
|
||||
end
|
||||
|
||||
function sled:on_activate(staticdata, dtime_s)
|
||||
function sled:on_activate(staticdata)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.object:set_acceleration({x=0, y=-10, z=0})
|
||||
if staticdata then
|
||||
self.v = tonumber(staticdata)
|
||||
end
|
||||
|
@ -202,7 +200,7 @@ function sled:on_step(dtime)
|
|||
return
|
||||
end
|
||||
if player:get_player_control().sneak
|
||||
or not accelerating_possible(vector.round(self.object:getpos())) then
|
||||
or not accelerating_possible(vector.round(self.object:get_pos())) then
|
||||
leave_sled(self, player)
|
||||
end
|
||||
end
|
||||
|
@ -222,7 +220,7 @@ minetest.register_craftitem("snow:sled", {
|
|||
if players_sled[placer:get_player_name()] then
|
||||
return
|
||||
end
|
||||
local pos = placer:getpos()
|
||||
local pos = placer:get_pos()
|
||||
if accelerating_possible(vector.round(pos)) then
|
||||
pos.y = pos.y+0.5
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ function snow.shoot_snowball(item, player)
|
|||
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
||||
addp.x = dir.z/dif -- + (math.random()-0.5)/5
|
||||
addp.z = -dir.x/dif -- + (math.random()-0.5)/5
|
||||
local pos = vector.add(player:getpos(), addp)
|
||||
local pos = vector.add(player:get_pos(), addp)
|
||||
local obj = minetest.add_entity(pos, "snow:snowball_entity")
|
||||
obj:setvelocity(vector.multiply(dir, snowball_velocity))
|
||||
obj:setacceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3})
|
||||
obj:set_velocity(vector.multiply(dir, snowball_velocity))
|
||||
obj:set_acceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3})
|
||||
obj:get_luaentity().thrower = player:get_player_name()
|
||||
if creative_mode then
|
||||
if not someone_throwing then
|
||||
|
@ -103,25 +103,25 @@ local snow_snowball_ENTITY = {
|
|||
|
||||
function snow_snowball_ENTITY.on_activate(self)
|
||||
self.object:set_properties({textures = {"default_snowball.png^[transform"..math.random(0,7)}})
|
||||
self.object:setacceleration({x=0, y=-get_gravity(), z=0})
|
||||
self.lastpos = self.object:getpos()
|
||||
self.object:set_acceleration({x=0, y=-get_gravity(), z=0})
|
||||
self.lastpos = self.object:get_pos()
|
||||
minetest.after(0.1, function(obj)
|
||||
if not obj then
|
||||
return
|
||||
end
|
||||
local vel = obj:getvelocity()
|
||||
local vel = obj:get_velocity()
|
||||
if vel
|
||||
and vel.y ~= 0 then
|
||||
return
|
||||
end
|
||||
minetest.after(0, function(obj)
|
||||
if not obj then
|
||||
minetest.after(0, function(object)
|
||||
if not object then
|
||||
return
|
||||
end
|
||||
local vel = obj:getvelocity()
|
||||
if not vel
|
||||
or vel.y == 0 then
|
||||
obj:remove()
|
||||
local vel_obj = object:get_velocity()
|
||||
if not vel_obj
|
||||
or vel_obj.y == 0 then
|
||||
object:remove()
|
||||
end
|
||||
end, obj)
|
||||
end, self.object)
|
||||
|
@ -137,7 +137,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||
end
|
||||
|
||||
if self.physical then
|
||||
local vel = self.object:getvelocity()
|
||||
local vel = self.object:get_velocity()
|
||||
local fell = vel.y == 0
|
||||
if not fell then
|
||||
if self.probably_stuck then
|
||||
|
@ -155,7 +155,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||
self.probably_stuck = nil
|
||||
return
|
||||
end
|
||||
local pos = vector.round(self.object:getpos())
|
||||
local pos = vector.round(self.object:get_pos())
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
pos.y = pos.y-1
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
|
@ -171,16 +171,16 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||
return
|
||||
end
|
||||
|
||||
local pos = vector.round(self.object:getpos())
|
||||
local pos = vector.round(self.object:get_pos())
|
||||
if vector.equals(pos, self.lastpos) then
|
||||
return
|
||||
end
|
||||
if minetest.get_node(pos).name ~= "air" then
|
||||
self.object:setacceleration({x=0, y=-get_gravity(), z=0})
|
||||
--self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:set_acceleration({x=0, y=-get_gravity(), z=0})
|
||||
--self.object:set_velocity({x=0, y=0, z=0})
|
||||
pos = self.lastpos
|
||||
self.object:setpos(pos)
|
||||
minetest.sound_play("default_snow_footstep", {pos=pos, gain=vector.length(self.object:getvelocity())/30})
|
||||
minetest.sound_play("default_snow_footstep", {pos=pos, gain=vector.length(self.object:get_velocity())/30})
|
||||
self.object:set_properties({physical = true})
|
||||
self.physical = true
|
||||
return
|
||||
|
@ -199,8 +199,8 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||
or (entity_name ~= "snow:snowball_entity"
|
||||
and entity_name ~= "__builtin:item"
|
||||
and entity_name ~= "gauges:hp_bar") then
|
||||
local vvel = v:getvelocity() or v:get_player_velocity()
|
||||
local veldif = self.object:getvelocity()
|
||||
local vvel = v:get_velocity() or v:get_player_velocity()
|
||||
local veldif = self.object:get_velocity()
|
||||
if vvel then
|
||||
veldif = vector.subtract(veldif, vvel)
|
||||
end
|
||||
|
@ -214,7 +214,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||
minetest.sound_play("default_snow_footstep", {pos=pos, gain=gain})
|
||||
|
||||
-- spawn_falling_node
|
||||
local obj = core.add_entity(pos, "__builtin:falling_node")
|
||||
local obj = minetest.add_entity(pos, "__builtin:falling_node")
|
||||
if obj then
|
||||
obj:get_luaentity():set_node{name = "default:snow"}
|
||||
else
|
||||
|
@ -265,11 +265,16 @@ minetest.register_node(":default:snow", {
|
|||
dug = {name="default_snow_footstep", gain=0.75},
|
||||
}),
|
||||
on_construct = function(pos)
|
||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt_with_grass" or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then
|
||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
== "default:dirt_with_grass"
|
||||
or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then
|
||||
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
|
||||
end
|
||||
-- Now, let's turn the snow pile into a snowblock. ~ LazyJ
|
||||
if minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name == "default:snow" and -- Minus 2 because at the end of this, the layer that triggers the change to a snowblock is the second layer more than a full block, starting into a second block (-2) ~ LazyJ, 2014_04_11
|
||||
if minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name == "default:snow"
|
||||
and -- Minus 2 because at the end of this, the layer that triggers
|
||||
--the change to a snowblock is the second layer more than a full block,
|
||||
--starting into a second block (-2) ~ LazyJ, 2014_04_11
|
||||
minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" then
|
||||
minetest.set_node({x=pos.x, y=pos.y-2, z=pos.z}, {name="default:snowblock"})
|
||||
end
|
||||
|
|
|
@ -45,7 +45,11 @@ if minetest.get_modpath("moreblocks") and
|
|||
ndef.groups.icemaker = nil
|
||||
ndef.groups.cooks_into_ice = nil
|
||||
ndef.after_place_node = nil
|
||||
|
||||
if string.find(name, "ice") then
|
||||
ndef.use_texture_alpha = "blend"
|
||||
else
|
||||
ndef.use_texture_alpha = "opaque"
|
||||
end
|
||||
stairsplus:register_all(mod, name, nodename, ndef)
|
||||
|
||||
if was_in_stairs[name] then
|
||||
|
|
|
@ -18,6 +18,8 @@ snow = {
|
|||
|
||||
-- functions for dynamically changing settings
|
||||
|
||||
snow.register_on_configuring = function() end
|
||||
--[[
|
||||
local on_configurings,n = {},1
|
||||
function snow.register_on_configuring(func)
|
||||
on_configurings[n] = func
|
||||
|
@ -50,3 +52,4 @@ local function value_from_string(v)
|
|||
end
|
||||
return v
|
||||
end
|
||||
--]]
|
||||
|
|
Before Width: | Height: | Size: 643 B After Width: | Height: | Size: 643 B |
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
Loading…
Reference in New Issue