mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00:37 +01:00
parent
e4ef41d7af
commit
b8e61fd763
3
mods/snow/.gitignore
vendored
Normal file
3
mods/snow/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
config.txt
|
||||||
|
debug.txt
|
||||||
|
*~
|
@ -1,2 +1,3 @@
|
|||||||
default
|
default
|
||||||
moreblocks?
|
moreblocks?
|
||||||
|
technic_worldgen?
|
||||||
|
@ -71,7 +71,7 @@ dofile(minetest.get_modpath("snow").."/src/sled.lua")
|
|||||||
|
|
||||||
-- Check for "MoreBlocks". If not found, skip this next "dofile".
|
-- Check for "MoreBlocks". If not found, skip this next "dofile".
|
||||||
|
|
||||||
if (minetest.get_modpath("moreblocks")) then
|
if minetest.get_modpath("moreblocks") then
|
||||||
|
|
||||||
dofile(minetest.get_modpath("snow").."/src/stairsplus.lua")
|
dofile(minetest.get_modpath("snow").."/src/stairsplus.lua")
|
||||||
|
|
||||||
@ -82,34 +82,52 @@ end
|
|||||||
function snow.place(pos)
|
function snow.place(pos)
|
||||||
if pos.y < -19000 then return end -- Don't put anything in the nether!
|
if pos.y < -19000 then return end -- Don't put anything in the nether!
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
local drawtype = ""
|
|
||||||
if node and minetest.registered_nodes[node.name] then
|
|
||||||
drawtype = minetest.registered_nodes[node.name].drawtype
|
|
||||||
end
|
|
||||||
|
|
||||||
--Oops, maybe there is no node?
|
--Oops, maybe there is no node?
|
||||||
if node == nil then
|
if not node
|
||||||
|
or not minetest.registered_nodes[node.name] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local bnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
local bnode = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||||
if node.name == "default:snow" and minetest.get_node_level(pos) < 63 then
|
if node.name == "default:snow" then
|
||||||
if minetest.get_item_group(bnode.name, "leafdecay") == 0 and snow.is_uneven(pos) ~= true then
|
local level = minetest.get_node_level(pos)
|
||||||
|
if level < 63 then
|
||||||
|
if minetest.get_item_group(bnode.name, "leafdecay") == 0
|
||||||
|
and not snow.is_uneven(pos) then
|
||||||
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
||||||
minetest.add_node_level(pos, 7)
|
minetest.add_node_level(pos, 7)
|
||||||
end
|
end
|
||||||
elseif node.name == "default:snow" and minetest.get_node_level(pos) == 63 then
|
elseif level == 63 then
|
||||||
local p = minetest.find_node_near(pos, 10, "default:dirt_with_grass")
|
local p = minetest.find_node_near(pos, 10, "default:dirt_with_grass")
|
||||||
if p and minetest.get_node_light(p, 0.5) == 15 then
|
if p
|
||||||
|
and minetest.get_node_light(p, 0.5) == 15 then
|
||||||
|
minetest.sound_play("default_grass_footstep", {pos=pos})
|
||||||
minetest.place_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:snow"})
|
minetest.place_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:snow"})
|
||||||
else
|
else
|
||||||
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
||||||
minetest.add_node(pos, {name="default:snowblock"})
|
minetest.add_node(pos, {name="default:snowblock"})
|
||||||
end
|
end
|
||||||
elseif node.name ~= "default:ice" and bnode.name ~= "air" then
|
end
|
||||||
if drawtype == "normal" or drawtype == "allfaces_optional" then
|
elseif node.name ~= "default:ice"
|
||||||
minetest.place_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="default:snow"})
|
and bnode.name ~= "air" then
|
||||||
|
local data = minetest.registered_nodes[node.name]
|
||||||
|
local drawtype = data.drawtype
|
||||||
|
if drawtype == "normal"
|
||||||
|
or drawtype == "allfaces_optional" then
|
||||||
|
pos.y = pos.y+1
|
||||||
|
local sound = data.sounds
|
||||||
|
if sound then
|
||||||
|
sound = sound.footstep
|
||||||
|
if sound then
|
||||||
|
minetest.sound_play(sound.name, {pos=pos, gain=sound.gain})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.place_node(pos, {name="default:snow"})
|
||||||
elseif drawtype == "plantlike" then
|
elseif drawtype == "plantlike" then
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
||||||
|
minetest.sound_play("default_grass_footstep", {pos=pos})
|
||||||
minetest.add_node(pos, {name="default:dirt_with_snow"})
|
minetest.add_node(pos, {name="default:dirt_with_snow"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -118,9 +136,7 @@ end
|
|||||||
|
|
||||||
-- Checks if the snow level is even at any given pos.
|
-- Checks if the snow level is even at any given pos.
|
||||||
-- Smooth Snow
|
-- Smooth Snow
|
||||||
local smooth_snow = snow.smooth_snow
|
local function is_uneven(pos)
|
||||||
snow.is_uneven = function(pos)
|
|
||||||
if smooth_snow then
|
|
||||||
local num = minetest.get_node_level(pos)
|
local num = minetest.get_node_level(pos)
|
||||||
local get_node = minetest.get_node
|
local get_node = minetest.get_node
|
||||||
local add_node = minetest.add_node
|
local add_node = minetest.add_node
|
||||||
@ -128,40 +144,48 @@ snow.is_uneven = function(pos)
|
|||||||
local foundx
|
local foundx
|
||||||
local foundy
|
local foundy
|
||||||
local foundz
|
local foundz
|
||||||
for x=-1,1 do
|
|
||||||
for z = -1,1 do
|
for z = -1,1 do
|
||||||
local node = get_node({x=pos.x+x,y=pos.y,z=pos.z+z})
|
for x = -1,1 do
|
||||||
local bnode = get_node({x=pos.x+x,y=pos.y-1,z=pos.z+z})
|
local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
|
||||||
local drawtype
|
local node = get_node(p)
|
||||||
if node and minetest.registered_nodes[node.name] then
|
p.y = p.y-1
|
||||||
drawtype = minetest.registered_nodes[node.name].drawtype
|
local bnode = get_node(p)
|
||||||
end
|
|
||||||
|
|
||||||
if drawtype == "plantlike" then
|
if node
|
||||||
if bnode.name == "default:dirt_with_grass" then
|
and minetest.registered_nodes[node.name]
|
||||||
add_node({x=pos.x+x,y=pos.y-1,z=pos.z+z}, {name="default:dirt_with_snow"})
|
and minetest.registered_nodes[node.name].drawtype == "plantlike"
|
||||||
|
and bnode.name == "default:dirt_with_grass" then
|
||||||
|
add_node(p, {name="default:dirt_with_snow"})
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if (not(x == 0 and y == 0)) and node.name == "default:snow" and minetest.get_node_level({x=pos.x+x,y=pos.y,z=pos.z+z}) < num then
|
p.y = p.y+1
|
||||||
|
if not (x == 0 and z == 0)
|
||||||
|
and node.name == "default:snow"
|
||||||
|
and minetest.get_node_level(p) < num then
|
||||||
found = true
|
found = true
|
||||||
foundx = x
|
foundx = x
|
||||||
foundz = z
|
foundz = z
|
||||||
elseif node.name == "air" and bnode.name ~= "air" then
|
elseif node.name == "air"
|
||||||
if not (bnode.name == "default:snow") then
|
and bnode.name ~= "air"
|
||||||
snow.place({x=pos.x+x,y=pos.y-1,z=pos.z+z})
|
and bnode.name ~= "default:snow" then
|
||||||
|
p.y = p.y-1
|
||||||
|
snow.place(p)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if found then
|
if found then
|
||||||
local node = get_node({x=pos.x+foundx,y=pos.y,z=pos.z+foundz})
|
local p = {x=pos.x+foundx, y=pos.y, z=pos.z+foundz}
|
||||||
if snow.is_uneven({x=pos.x+foundx,y=pos.y,z=pos.z+foundz}) ~= true then
|
if is_uneven(p) ~= true then
|
||||||
minetest.add_node_level({x=pos.x+foundx,y=pos.y,z=pos.z+foundz}, 7)
|
minetest.add_node_level(p, 7)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function snow.is_uneven(pos)
|
||||||
|
if snow.smooth_snow then
|
||||||
|
return is_uneven(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,10 +40,6 @@ near torches and lava.
|
|||||||
--=============================================================
|
--=============================================================
|
||||||
|
|
||||||
|
|
||||||
if not snow.enable_snowfall then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local weather_legacy
|
local weather_legacy
|
||||||
|
|
||||||
local read_weather_legacy = function ()
|
local read_weather_legacy = function ()
|
||||||
@ -84,7 +80,7 @@ local PERSISTENCE3 = 0.5 -- 0.5
|
|||||||
local SCALE3 = 250 -- 250
|
local SCALE3 = 250 -- 250
|
||||||
|
|
||||||
--Get snow at position.
|
--Get snow at position.
|
||||||
local get_snow = function(pos)
|
local function get_snow(pos)
|
||||||
--Legacy support.
|
--Legacy support.
|
||||||
if weather_legacy == "snow" then
|
if weather_legacy == "snow" then
|
||||||
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
||||||
@ -106,14 +102,19 @@ end
|
|||||||
local addvectors = vector and vector.add
|
local addvectors = vector and vector.add
|
||||||
|
|
||||||
--Returns a random position between minp and maxp.
|
--Returns a random position between minp and maxp.
|
||||||
local randpos = function (minp, maxp)
|
local function randpos(minp, maxp)
|
||||||
local x,y,z
|
local x,z
|
||||||
if minp.x > maxp.x then
|
if minp.x > maxp.x then
|
||||||
x = math.random(maxp.x,minp.x) else x = math.random(minp.x,maxp.x) end
|
x = math.random(maxp.x,minp.x)
|
||||||
y = minp.y
|
else
|
||||||
|
x = math.random(minp.x,maxp.x)
|
||||||
|
end
|
||||||
if minp.z > maxp.z then
|
if minp.z > maxp.z then
|
||||||
z = math.random(maxp.z,minp.z) else z = math.random(minp.z,maxp.z) end
|
z = math.random(maxp.z,minp.z)
|
||||||
return {x=x,y=y,z=z}
|
else
|
||||||
|
z = math.random(minp.z,maxp.z)
|
||||||
|
end
|
||||||
|
return {x=x,y=minp.y,z=z}
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_snow_particle = {
|
local default_snow_particle = {
|
||||||
@ -152,22 +153,20 @@ local function snow_fall(pos, player, animate)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not ground_y then return end
|
if not ground_y then
|
||||||
pos = {x=pos.x, y=ground_y, z=pos.z}
|
return
|
||||||
local spos = {x=pos.x, y=ground_y+10, z=pos.z}
|
end
|
||||||
|
|
||||||
|
pos = {x=pos.x, y=ground_y, z=pos.z}
|
||||||
|
|
||||||
if get_snow(pos) then
|
if get_snow(pos) then
|
||||||
if animate then
|
if animate then
|
||||||
local minp = addvectors(spos, {x=-9, y=3, z=-9})
|
local spos = {x=pos.x, y=ground_y+10, z=pos.z}
|
||||||
local maxp = addvectors(spos, {x= 9, y=5, z= 9})
|
|
||||||
local vel = {x=0, y= -1, z=-1}
|
|
||||||
local acc = {x=0, y= 0, z=0}
|
|
||||||
minetest.add_particlespawner(get_snow_particledef({
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
minpos = minp,
|
minpos = addvectors(spos, {x=-9, y=3, z=-9}),
|
||||||
maxpos = maxp,
|
maxpos = addvectors(spos, {x= 9, y=5, z= 9}),
|
||||||
vel = vel,
|
vel = {x=0, y=-1, z=-1},
|
||||||
acc = acc,
|
acc = {x=0, y=0, z=0},
|
||||||
playername = player:get_player_name()
|
playername = player:get_player_name()
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
@ -177,30 +176,21 @@ local function snow_fall(pos, player, animate)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Snow
|
-- Snow
|
||||||
minetest.register_globalstep(function(dtime)
|
local function calc_snowfall()
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local ppos = player:getpos()
|
local ppos = player:getpos()
|
||||||
|
|
||||||
local sminp = addvectors(ppos, {x=-20, y=0, z=-20})
|
|
||||||
local smaxp = addvectors(ppos, {x= 20, y=0, z= 20})
|
|
||||||
|
|
||||||
-- Make sure player is not in a cave/house...
|
-- Make sure player is not in a cave/house...
|
||||||
if get_snow(ppos) and minetest.get_node_light(ppos, 0.5) == 15 then
|
if get_snow(ppos)
|
||||||
|
and minetest.get_node_light(ppos, 0.5) == 15 then
|
||||||
local minp = addvectors(ppos, {x=-9, y=3, z=-9})
|
local animate
|
||||||
local maxp = addvectors(ppos, {x= 9, y=5, z= 9})
|
if not snow.lighter_snowfall then
|
||||||
|
|
||||||
local minp_deep = addvectors(ppos, {x=-5, y=3.2, z=-5})
|
|
||||||
local maxp_deep = addvectors(ppos, {x= 5, y=1.6, z= 5})
|
|
||||||
|
|
||||||
local vel = {x=0, y=-1, z=-1}
|
local vel = {x=0, y=-1, z=-1}
|
||||||
local acc = {x=0, y=0, z=0}
|
local acc = {x=0, y=0, z=0}
|
||||||
|
|
||||||
if not snow.lighter_snowfall then
|
|
||||||
minetest.add_particlespawner(get_snow_particledef({
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
amount = 5,
|
amount = 5,
|
||||||
minpos = minp,
|
minpos = addvectors(ppos, {x=-9, y=3, z=-9}),
|
||||||
maxpos = maxp,
|
maxpos = addvectors(ppos, {x= 9, y=5, z= 9}),
|
||||||
vel = vel,
|
vel = vel,
|
||||||
acc = acc,
|
acc = acc,
|
||||||
size = 25,
|
size = 25,
|
||||||
@ -209,8 +199,8 @@ minetest.register_globalstep(function(dtime)
|
|||||||
|
|
||||||
minetest.add_particlespawner(get_snow_particledef({
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
amount = 4,
|
amount = 4,
|
||||||
minpos = minp_deep,
|
minpos = addvectors(ppos, {x=-5, y=3.2, z=-5}),
|
||||||
maxpos = maxp_deep,
|
maxpos = addvectors(ppos, {x= 5, y=1.6, z= 5}),
|
||||||
vel = vel,
|
vel = vel,
|
||||||
acc = acc,
|
acc = acc,
|
||||||
exptime = 4,
|
exptime = 4,
|
||||||
@ -218,14 +208,27 @@ minetest.register_globalstep(function(dtime)
|
|||||||
playername = player:get_player_name()
|
playername = player:get_player_name()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if math.random(1,5) == 4 then
|
animate = false
|
||||||
snow_fall(randpos(sminp, smaxp), player)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
|
animate = true
|
||||||
|
end
|
||||||
|
|
||||||
if math.random(1,5) == 4 then
|
if math.random(1,5) == 4 then
|
||||||
snow_fall(randpos(sminp, smaxp), player, true)
|
snow_fall(
|
||||||
|
randpos(
|
||||||
|
addvectors(ppos, {x=-20, y=0, z=-20}),
|
||||||
|
addvectors(ppos, {x= 20, y=0, z= 20})
|
||||||
|
),
|
||||||
|
player,
|
||||||
|
animate
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
if snow.enable_snowfall then
|
||||||
|
calc_snowfall()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -13,13 +13,10 @@ saplings grow into trees. --]]
|
|||||||
-- Part 1: To disable the mapgen, add the *starting* comment under this line.
|
-- Part 1: To disable the mapgen, add the *starting* comment under this line.
|
||||||
|
|
||||||
|
|
||||||
local mgname = ""
|
|
||||||
|
|
||||||
--Identify the mapgen.
|
--Identify the mapgen.
|
||||||
minetest.register_on_mapgen_init(function(MapgenParams)
|
minetest.register_on_mapgen_init(function(MapgenParams)
|
||||||
if MapgenParams.mgname then
|
local mgname = MapgenParams.mgname
|
||||||
mgname = MapgenParams.mgname
|
if not mgname then
|
||||||
else
|
|
||||||
io.write("[MOD] Snow Biomes: WARNING! mapgen could not be identifyed!\n")
|
io.write("[MOD] Snow Biomes: WARNING! mapgen could not be identifyed!\n")
|
||||||
end
|
end
|
||||||
if mgname == "v7" then
|
if mgname == "v7" then
|
||||||
@ -72,18 +69,19 @@ function snow.make_pine(pos,snow,xmas)
|
|||||||
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
||||||
local try_node = function(pos, node)
|
local try_node = function(pos, node)
|
||||||
local n = minetest.get_node(pos).name
|
local n = minetest.get_node(pos).name
|
||||||
if n == "air" or n == "ignore" then
|
if n == "air"
|
||||||
|
or n == "ignore" then
|
||||||
minetest.add_node(pos, node)
|
minetest.add_node(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--Clear ground.
|
--Clear ground.
|
||||||
for x=-1,1 do
|
|
||||||
for z = -1,1 do
|
for z = -1,1 do
|
||||||
if minetest.get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "default:snow" then
|
for x = -1,1 do
|
||||||
minetest.remove_node({x=pos.x+x,y=pos.y,z=pos.z+z})
|
local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
|
||||||
end
|
local nd = minetest.get_node(p).name
|
||||||
if minetest.get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "default:snowblock" then
|
if nd == "default:snow"
|
||||||
minetest.remove_node({x=pos.x+x,y=pos.y,z=pos.z+z})
|
or nd == "default:snowblock" then
|
||||||
|
minetest.remove_node(p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -107,7 +105,8 @@ function snow.make_pine(pos,snow,xmas)
|
|||||||
end
|
end
|
||||||
if xmas then
|
if xmas then
|
||||||
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star_lit"}) -- Added lit star. ~ LazyJ
|
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star_lit"}) -- Added lit star. ~ LazyJ
|
||||||
elseif snow and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
|
elseif snow
|
||||||
|
and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
|
||||||
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="default:snow"})
|
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="default:snow"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -122,32 +121,32 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
|
||||||
--Clear ground.
|
|
||||||
for x=-1,1 do
|
|
||||||
for z = -1,1 do
|
for z = -1,1 do
|
||||||
local node = a:index(pos.x+x,pos.y,pos.z+z)
|
local z = pos.z + z
|
||||||
|
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
|
if data[node] == c_snow then
|
||||||
data[node] = c_air
|
data[node] = c_air
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
--Make tree.
|
--Make tree.
|
||||||
for i=0, 4 do
|
for i = 1,2 do
|
||||||
if i==1 or i==2 then
|
|
||||||
for x=-1,1 do
|
|
||||||
for z=-1,1 do
|
|
||||||
local x = pos.x + x
|
|
||||||
local z = pos.z + z
|
|
||||||
local node = a:index(x,pos.y+i,z)
|
local node = a:index(x,pos.y+i,z)
|
||||||
data[node] = c_pine_needles
|
data[node] = c_pine_needles
|
||||||
if snow and x ~= 0 and z ~= 0 and perlin1:get2d({x=x,y=z}) > 0.53 then
|
if snow
|
||||||
|
and 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)
|
local abovenode = a:index(x,pos.y+i+1,z)
|
||||||
data[abovenode] = c_snow
|
data[abovenode] = c_snow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if i==3 or i==4 then
|
for i=3, 4 do
|
||||||
local x = pos.x
|
local x = pos.x
|
||||||
local y = pos.y+i
|
local y = pos.y+i
|
||||||
local z = pos.z
|
local z = pos.z
|
||||||
@ -170,11 +169,13 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for i=0, 4 do
|
||||||
data[a:index(pos.x,pos.y+i,pos.z)] = c_pinetree
|
data[a:index(pos.x,pos.y+i,pos.z)] = c_pinetree
|
||||||
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 and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
|
if snow
|
||||||
|
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
|
||||||
|
@ -22,33 +22,38 @@ local np_ice = {
|
|||||||
|
|
||||||
-- Debugging function
|
-- Debugging function
|
||||||
|
|
||||||
local biome_to_string = function(num,num2)
|
local biome_strings = {
|
||||||
local biome, biome2
|
{"snowy", "plain", "alpine", "normal", "normal"},
|
||||||
if num == 1 then
|
{"cool", "icebergs", "icesheet", "icecave", "icehole"}
|
||||||
biome = "snowy"
|
}
|
||||||
elseif num == 2 then
|
local function biome_to_string(num,num2)
|
||||||
biome = "plain"
|
local biome = biome_strings[1][num] or "unknown "..num
|
||||||
elseif num == 3 then
|
return biome
|
||||||
biome = "alpine"
|
|
||||||
elseif num == 4 or num == 5 then
|
|
||||||
biome = "normal"
|
|
||||||
else
|
|
||||||
biome = "unknown "..num
|
|
||||||
end
|
end
|
||||||
if num2 == 1 then
|
|
||||||
biome2 = "cool"
|
local function do_ws_func(a, x)
|
||||||
elseif num2 == 2 then
|
local n = x/(16000)
|
||||||
biome2 = "icebergs"
|
local y = 0
|
||||||
elseif num2 == 3 then
|
for k=1,1000 do
|
||||||
biome2 = "icesheet"
|
y = y + 1000*(math.sin(math.pi * k^a * n)/(math.pi * k^a))
|
||||||
elseif num2 == 4 then
|
|
||||||
biome2 = "icecave"
|
|
||||||
elseif num2 == 5 then
|
|
||||||
biome2 = "icehole"
|
|
||||||
else
|
|
||||||
biome2 = "unknown "..num
|
|
||||||
end
|
end
|
||||||
return biome, biome2
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
-- On generated function
|
-- On generated function
|
||||||
@ -61,11 +66,8 @@ 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 debug = snow.debug
|
|
||||||
local min_height = snow.min_height
|
|
||||||
local spawn_pine = snow.voxelmanip_pine
|
local spawn_pine = snow.voxelmanip_pine
|
||||||
local smooth = snow.smooth_biomes
|
local smooth = snow.smooth_biomes
|
||||||
local legacy = snow.legacy
|
|
||||||
|
|
||||||
local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass")
|
local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass")
|
||||||
local c_dirt = minetest.get_content_id("default:dirt")
|
local c_dirt = minetest.get_content_id("default:dirt")
|
||||||
@ -91,30 +93,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
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 snow_tab,num = {},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 minpos = {x=x0, y=z0}
|
|
||||||
local nvals_cold = minetest.get_perlin_map(np_cold, chulens):get2dMap_flat({x=x0, y=z0})
|
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_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat({x=x0, y=z0})
|
||||||
|
|
||||||
-- Choose biomes
|
-- Choose biomes
|
||||||
local pr = PseudoRandom(seed+57)
|
local pr = PseudoRandom(seed+57)
|
||||||
local biome
|
|
||||||
-- Land biomes
|
-- Land biomes
|
||||||
biome = pr:next(1, 5)
|
local biome = pr:next(1, 5)
|
||||||
local snowy = biome == 1 -- spawns alot of snow
|
local snowy = biome == 1 -- spawns alot of snow
|
||||||
local plain = biome == 2 -- spawns not much
|
|
||||||
local alpine = biome == 3 -- rocky terrain
|
local alpine = biome == 3 -- rocky terrain
|
||||||
-- Water biomes
|
|
||||||
local biome2 = pr:next(1, 5)
|
|
||||||
local cool = biome == 1 -- only spawns ice on edge of water
|
|
||||||
local icebergs = biome == 2
|
|
||||||
local icesheet = biome == 3
|
|
||||||
local icecave = biome == 4
|
|
||||||
local icehole = biome == 5 -- icesheet with holes
|
|
||||||
-- 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
|
||||||
local mossy = pr:next(1,2) == 1 -- spawns moss in snow
|
|
||||||
local shrubs = pr:next(1,2) == 1 -- spawns dry shrubs in snow
|
local shrubs = pr:next(1,2) == 1 -- spawns dry shrubs in snow
|
||||||
local pines = pr:next(1,2) == 1 -- spawns pines
|
local pines = pr:next(1,2) == 1 -- spawns pines
|
||||||
-- Reseed random
|
-- Reseed random
|
||||||
@ -135,11 +128,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not in_biome then
|
if not in_biome then
|
||||||
if alpine == true and test > 0.43 then
|
if alpine and test > 0.43 then
|
||||||
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 and nodid ~= c_ignore then
|
if nodid ~= c_air
|
||||||
|
and nodid ~= c_ignore then
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -155,7 +149,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
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_air
|
|
||||||
or id == c_apple then
|
or id == c_apple then
|
||||||
data[vi] = c_air
|
data[vi] = c_air
|
||||||
else
|
else
|
||||||
@ -169,9 +162,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
elseif in_biome then
|
elseif in_biome then
|
||||||
write_to_map = true
|
write_to_map = true
|
||||||
local icetype = nvals_ice[ni]
|
local icetype = nvals_ice[ni]
|
||||||
local cool = icetype > 0
|
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
|
||||||
local icehole = icetype > -0.4 and icetype <= -0.2
|
local icehole = icetype > -0.4 and icetype <= -0.2 -- icesheet with holes
|
||||||
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
|
||||||
|
|
||||||
@ -191,7 +184,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
|
|
||||||
if ground_y and data[node] == c_dirt_with_grass then
|
if ground_y and data[node] == c_dirt_with_grass then
|
||||||
if alpine and test > 0.53 then
|
if alpine and test > 0.53 then
|
||||||
data[abovenode] = c_snow
|
snow_tab[num] = {abovenode, z, x, test}
|
||||||
|
num = num+1
|
||||||
for y = ground_y, -6, -1 do
|
for y = ground_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
|
||||||
@ -210,18 +204,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[abovenode] = c_snow_block
|
data[abovenode] = c_snow_block
|
||||||
else
|
else
|
||||||
data[node] = c_dirt_with_snow
|
data[node] = c_dirt_with_snow
|
||||||
data[abovenode] = c_snow
|
snow_tab[num] = {abovenode, z, x, test}
|
||||||
|
num = num+1
|
||||||
end
|
end
|
||||||
elseif ground_y and data[node] == c_sand then
|
elseif ground_y and data[node] == c_sand then
|
||||||
if not icy then
|
if not icy then
|
||||||
data[abovenode] = c_snow
|
snow_tab[num] = {abovenode, z, x, test}
|
||||||
|
num = num+1
|
||||||
else
|
else
|
||||||
data[node] = c_ice
|
data[node] = c_ice
|
||||||
end
|
end
|
||||||
elseif ground_y and data[node] == c_leaves
|
elseif ground_y and data[node] == c_leaves
|
||||||
or data[node] == c_jungleleaves or data[node] == c_apple then
|
or data[node] == c_jungleleaves or data[node] == c_apple then
|
||||||
if alpine then
|
if alpine then
|
||||||
data[abovenode] = c_snow
|
snow_tab[num] = {abovenode, z, x, test}
|
||||||
|
num = num+1
|
||||||
for y = ground_y, -6, -1 do
|
for y = ground_y, -6, -1 do
|
||||||
local stone = area:index(x, y, z)
|
local stone = area:index(x, y, z)
|
||||||
if data[stone] == c_stone then
|
if data[stone] == c_stone then
|
||||||
@ -231,54 +228,64 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
data[abovenode] = c_snow
|
snow_tab[num] = {abovenode, z, x, test}
|
||||||
|
num = num+1
|
||||||
end
|
end
|
||||||
elseif ground_y and data[node] == c_junglegrass then
|
elseif ground_y
|
||||||
|
and data[node] == c_junglegrass then
|
||||||
data[node] = c_dry_shrub
|
data[node] = c_dry_shrub
|
||||||
elseif ground_y and data[node] == c_papyrus then
|
elseif ground_y
|
||||||
|
and data[node] == c_papyrus then
|
||||||
for y = ground_y, ground_y-4, -1 do
|
for y = ground_y, ground_y-4, -1 do
|
||||||
local vi = area:index(x, y, z)
|
local vi = area:index(x, y, z)
|
||||||
if data[vi] == c_papyrus then
|
if data[vi] == c_papyrus then
|
||||||
local via = area:index(x, ground_y, z)
|
snow_tab[num] = {area:index(x, ground_y, z), z, x, test}
|
||||||
data[via] = c_snow
|
num = num+1
|
||||||
data[vi] = c_snow_block
|
data[vi] = c_snow_block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif ground_y and data[node] == c_water then
|
elseif ground_y
|
||||||
if not icesheet and not icecave and not icehole then
|
and data[node] == c_water then
|
||||||
|
if not icesheet
|
||||||
|
and not icecave
|
||||||
|
and not icehole then
|
||||||
local x1 = data[area:index(x+1, ground_y, z)]
|
local x1 = data[area:index(x+1, ground_y, z)]
|
||||||
local z1 = data[area:index(x, ground_y, z+1)]
|
local z1 = data[area:index(x, ground_y, z+1)]
|
||||||
local xz1 = data[area:index(x+1, 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 xz2 = data[area:index(x-1, ground_y, z-1)]
|
||||||
local x2 = data[area:index(x-1, ground_y, z)]
|
local x2 = data[area:index(x-1, ground_y, z)]
|
||||||
local z2 = data[area:index(x, ground_y, z-1)]
|
local z2 = data[area:index(x, ground_y, z-1)]
|
||||||
|
local rand = (pr:next(1,4) == 1) and (cool or icebergs)
|
||||||
|
local ice
|
||||||
|
if rand then
|
||||||
|
for _,i in ipairs({x1,z1,xz1,xz2,x2,z2}) 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
|
||||||
|
ice = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local y = data[area:index(x, ground_y-1, z)]
|
local y = data[area:index(x, ground_y-1, z)]
|
||||||
local rand = pr:next(1,4) == 1
|
if ice
|
||||||
if ((x1 and x1 ~= c_water and x1 ~= c_ice
|
|
||||||
and x1 ~= c_air and x1 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and x1 == c_ice))
|
|
||||||
or ((z1 and z1 ~= c_water and z1 ~= c_ice
|
|
||||||
and z1 ~= c_air and z1 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and z1 == c_ice))
|
|
||||||
or ((xz1 and xz1 ~= c_water and xz1 ~= c_ice
|
|
||||||
and xz1 ~= c_air and xz1 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and xz1 == c_ice))
|
|
||||||
or ((xz2 and xz2 ~= c_water and xz2 ~= c_ice
|
|
||||||
and xz2 ~= c_air and xz2 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and xz2 == c_ice))
|
|
||||||
or ((x2 and x2 ~= c_water and x2 ~= c_ice
|
|
||||||
and x2 ~= c_air and x2 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and x2 == c_ice))
|
|
||||||
or ((z2 and z2 ~= c_water and z2 ~= c_ice
|
|
||||||
and z2 ~= c_air and z2 ~= c_ignore)
|
|
||||||
or (rand and (cool or icebergs) and z2 == c_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 (icehole and pr:next(1,10) > 1)
|
||||||
or icecave or icesheet then
|
or icecave
|
||||||
|
or icesheet then
|
||||||
data[node] = c_ice
|
data[node] = c_ice
|
||||||
end
|
end
|
||||||
if icecave then
|
if icecave then
|
||||||
@ -299,15 +306,46 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local param2s
|
||||||
|
if num ~= 1 then
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
if h ~= 1 then
|
||||||
|
if h == 9 then
|
||||||
|
h = 4
|
||||||
|
end
|
||||||
|
param2s[p] = h*7
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
|
if param2s then
|
||||||
|
vm:set_param2_data(param2s)
|
||||||
|
end
|
||||||
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()
|
||||||
|
|
||||||
if write_to_map and debug then -- print if any column of mapchunk was snow biome
|
if write_to_map
|
||||||
local biome_string,biome2_string = biome_to_string(biome,biome2)
|
and snow.debug then -- print if any column of mapchunk was snow biome
|
||||||
|
local biome_string = biome_to_string(biome)
|
||||||
local chugent = math.ceil((os.clock() - t1) * 1000)
|
local chugent = math.ceil((os.clock() - t1) * 1000)
|
||||||
print("[snow] "..biome_string.." and "..biome2_string.." x "..minp.x.." z "..minp.z.." time "..chugent.." ms")
|
print("[snow] "..biome_string.." x "..minp.x.." z "..minp.z.." time "..chugent.." ms")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -197,8 +197,9 @@ minetest.register_node("snow:star", {
|
|||||||
--groups = {snappy=2,dig_immediate=3},
|
--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
|
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
|
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
|
||||||
on_punch = function(pos, node, puncher) -- 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
|
||||||
minetest.set_node(pos, {name = "snow:star_lit"})
|
node.name = "snow:star_lit"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -217,8 +218,9 @@ minetest.register_node("snow:star_lit", {
|
|||||||
drop = "snow:star",
|
drop = "snow:star",
|
||||||
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
|
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}}),
|
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}),
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node)
|
||||||
minetest.set_node(pos, {name = "snow:star"})
|
node.name = "snow:star"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -328,7 +330,7 @@ minetest.override_item("default:ice", {
|
|||||||
on_construct = snow_onto_dirt,
|
on_construct = snow_onto_dirt,
|
||||||
liquids_pointable = true,
|
liquids_pointable = true,
|
||||||
--Make ice freeze over when placed by a maximum of 10 blocks.
|
--Make ice freeze over when placed by a maximum of 10 blocks.
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos)
|
||||||
minetest.set_node(pos, {name="default:ice", param2=math.random(0,10)})
|
minetest.set_node(pos, {name="default:ice", param2=math.random(0,10)})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -39,6 +39,7 @@ scattered in my note-taking program. This "Oh, I'll just make a little tweak her
|
|||||||
little tweak there" project has evolved into something much bigger and more complex
|
little tweak there" project has evolved into something much bigger and more complex
|
||||||
than I originally planned. :p ~ LazyJ
|
than I originally planned. :p ~ LazyJ
|
||||||
|
|
||||||
|
* find out why the sled disappears after rightclicking it ~ HybridDog
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
@ -52,9 +53,19 @@ than I originally planned. :p ~ LazyJ
|
|||||||
-- Helper functions
|
-- 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
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function is_water(pos)
|
local function is_water(pos)
|
||||||
local nn = minetest.get_node(pos).name
|
return minetest.get_item_group(minetest.get_node(pos).name, "water") ~= 0
|
||||||
return minetest.get_item_group(nn, "water") ~= 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -63,45 +74,58 @@ end
|
|||||||
--
|
--
|
||||||
|
|
||||||
local sled = {
|
local sled = {
|
||||||
physical = false,
|
physical = true,
|
||||||
collisionbox = {-0.6,-0.25,-0.6, 0.6,0.3,0.6},
|
collisionbox = {-0.6,-0.25,-0.6, 0.6,0.3,0.6},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "sled.x",
|
mesh = "sled.x",
|
||||||
textures = {"sled.png"},
|
textures = {"sled.png"},
|
||||||
nil,
|
|
||||||
|
|
||||||
driver = nil,
|
|
||||||
sliding = false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local players_sled = {}
|
local players_sled = {}
|
||||||
|
local function join_sled(self, player)
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
player:setpos(pos)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
players_sled[name] = true
|
||||||
|
default.player_attached[name] = true
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
function sled:on_rightclick(clicker)
|
local function leave_sled(self, player)
|
||||||
if (not self.driver) and snow.sleds then
|
local name = player:get_player_name()
|
||||||
players_sled[clicker:get_player_name()] = true
|
players_sled[name] = false
|
||||||
self.driver = clicker
|
self.driver = nil
|
||||||
self.object:set_attach(clicker, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
|
player:set_detach()
|
||||||
clicker:set_physics_override({
|
default.player_attached[name] = false
|
||||||
|
default.player_set_animation(player, "stand" , 30)
|
||||||
|
|
||||||
|
player:set_physics_override({
|
||||||
|
speed = 1,
|
||||||
|
jump = 1,
|
||||||
|
})
|
||||||
|
player:hud_remove(self.HUD) -- And here is part 2. ~ LazyJ
|
||||||
|
self.object:remove()
|
||||||
|
|
||||||
|
--Give the sled back again
|
||||||
|
player:get_inventory():add_item("main", "snow:sled")
|
||||||
|
end
|
||||||
|
|
||||||
|
function sled:on_rightclick(player)
|
||||||
|
if self.driver
|
||||||
|
or not snow.sleds then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
join_sled(self, player)
|
||||||
|
player:set_physics_override({
|
||||||
speed = 2, -- multiplier to default value
|
speed = 2, -- multiplier to default value
|
||||||
jump = 0, -- multiplier to default value
|
jump = 0, -- multiplier to default value
|
||||||
gravity = 1
|
|
||||||
})
|
})
|
||||||
--[[
|
|
||||||
local HUD =
|
|
||||||
{
|
|
||||||
hud_elem_type = "text", -- see HUD element types
|
|
||||||
position = {x=0.5, y=0.89},
|
|
||||||
name = "sled",
|
|
||||||
scale = {x=2, y=2},
|
|
||||||
text = "You are sledding, hold sneak to stop.",
|
|
||||||
direction = 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
clicker:hud_add(HUD)
|
|
||||||
--]]
|
|
||||||
|
|
||||||
-- Here is part 1 of the fix. ~ LazyJ
|
-- Here is part 1 of the fix. ~ LazyJ
|
||||||
self.HUD = clicker:hud_add({
|
self.HUD = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = {x=0.5, y=0.89},
|
position = {x=0.5, y=0.89},
|
||||||
name = "sled",
|
name = "sled",
|
||||||
@ -111,57 +135,55 @@ function sled:on_rightclick(clicker)
|
|||||||
})
|
})
|
||||||
-- End part 1
|
-- End part 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function sled:on_activate(staticdata, dtime_s)
|
function sled:on_activate(staticdata, dtime_s)
|
||||||
self.object:set_armor_groups({immortal=1})
|
self.object:set_armor_groups({immortal=1})
|
||||||
|
self.object:setacceleration({x=0, y=-10, z=0})
|
||||||
if staticdata then
|
if staticdata then
|
||||||
self.v = tonumber(staticdata)
|
self.v = tonumber(staticdata)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function sled:get_staticdata()
|
function sled:get_staticdata()
|
||||||
return tostring(v)
|
return tostring(self.v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sled:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
function sled:on_punch(puncher)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
if puncher and puncher:is_player() then
|
if puncher
|
||||||
|
and puncher:is_player() then
|
||||||
puncher:get_inventory():add_item("main", "snow:sled")
|
puncher:get_inventory():add_item("main", "snow:sled")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local driveable_nodes = {"default:snow","default:snowblock","default:ice","default:dirt_with_snow", "group:icemaker"}
|
||||||
minetest.register_globalstep(function(dtime)
|
local function accelerating_possible(pos)
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
if is_water(pos) then
|
||||||
if players_sled[player:get_player_name()] then
|
return false
|
||||||
default.player_set_animation(player, "sit", 0)
|
|
||||||
end
|
end
|
||||||
|
if table_find(driveable_nodes, minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
|
|
||||||
|
local timer = 0
|
||||||
function sled:on_step(dtime)
|
function sled:on_step(dtime)
|
||||||
if self.driver then
|
if not self.driver then
|
||||||
local p = self.object:getpos()
|
return
|
||||||
p.y = p.y+0.4
|
|
||||||
local s = self.object:getpos()
|
|
||||||
s.y = s.y -0.5
|
|
||||||
local keys = self.driver:get_player_control()
|
|
||||||
if keys["sneak"] or is_water(p) or (not minetest.find_node_near(s, 1, {"default:snow","default:snowblock","default:ice","default:dirt_with_snow", "group:icemaker"})) then -- LazyJ
|
|
||||||
self.driver:set_physics_override({
|
|
||||||
speed = 1, -- multiplier to default value
|
|
||||||
jump = 1, -- multiplier to default value
|
|
||||||
gravity = 1
|
|
||||||
})
|
|
||||||
|
|
||||||
players_sled[self.driver:get_player_name()] = false
|
|
||||||
self.object:set_detach()
|
|
||||||
--self.driver:hud_remove("sled")
|
|
||||||
self.driver:hud_remove(self.HUD) -- And here is part 2. ~ LazyJ
|
|
||||||
self.driver = nil
|
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
timer = timer+dtime
|
||||||
|
if timer < 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
timer = 0
|
||||||
|
local player = minetest.get_player_by_name(self.driver)
|
||||||
|
if not player then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if player:get_player_control().sneak
|
||||||
|
or not accelerating_possible(vector.round(self.object:getpos())) then
|
||||||
|
leave_sled(self, player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -177,14 +199,16 @@ minetest.register_craftitem("snow:sled", {
|
|||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
|
||||||
on_use = function(itemstack, placer)
|
on_use = function(itemstack, placer)
|
||||||
local pos = {x=0,y=-1000, z=0}
|
if players_sled[placer:get_player_name()] then
|
||||||
local name = placer:get_player_name()
|
return
|
||||||
local player_pos = placer:getpos()
|
|
||||||
if not players_sled[name] then
|
|
||||||
if minetest.get_node(player_pos).name == "default:snow" then
|
|
||||||
local sled = minetest.add_entity(pos, "snow:sled")
|
|
||||||
sled:get_luaentity():on_rightclick(placer)
|
|
||||||
end
|
end
|
||||||
|
local pos = placer:getpos()
|
||||||
|
if accelerating_possible(vector.round(pos)) then
|
||||||
|
pos.y = pos.y+0.5
|
||||||
|
|
||||||
|
--Get on the sled and remove it from inventory.
|
||||||
|
minetest.add_entity(pos, "snow:sled"):right_click(placer)
|
||||||
|
itemstack:take_item(); return itemstack
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -6,60 +6,148 @@
|
|||||||
-- Quite a bit of trial-and-error learning here and it boiled down to a
|
-- Quite a bit of trial-and-error learning here and it boiled down to a
|
||||||
-- small handful of code lines making the difference. ~ LazyJ
|
-- small handful of code lines making the difference. ~ LazyJ
|
||||||
|
|
||||||
local snowball_GRAVITY=9
|
local creative_mode = minetest.setting_getbool("creative_mode")
|
||||||
local snowball_VELOCITY=19
|
|
||||||
|
local function get_gravity()
|
||||||
|
local grav = tonumber(minetest.setting_get("movement_gravity")) or 9.81
|
||||||
|
return grav*snow.snowball_gravity
|
||||||
|
end
|
||||||
|
|
||||||
|
local someone_throwing
|
||||||
|
local timer = 0
|
||||||
|
|
||||||
--Shoot snowball
|
--Shoot snowball
|
||||||
local snow_shoot_snowball=function (item, player, pointed_thing)
|
local function snow_shoot_snowball(item, player)
|
||||||
local playerpos=player:getpos()
|
local addp = {y = 1.625} -- + (math.random()-0.5)/5}
|
||||||
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "snow:snowball_entity")
|
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
|
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
||||||
obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
|
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 obj = minetest.add_entity(pos, "snow:snowball_entity")
|
||||||
|
obj:setvelocity(vector.multiply(dir, snow.snowball_velocity))
|
||||||
|
obj:setacceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3})
|
||||||
|
if creative_mode then
|
||||||
|
if not someone_throwing then
|
||||||
|
someone_throwing = true
|
||||||
|
timer = -0.5
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
item:take_item()
|
item:take_item()
|
||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if creative_mode then
|
||||||
|
local function update_step(dtime)
|
||||||
|
timer = timer+dtime
|
||||||
|
if timer < 0.006 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
timer = 0
|
||||||
|
|
||||||
|
local active
|
||||||
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
|
if player:get_player_control().LMB then
|
||||||
|
local item = player:get_wielded_item()
|
||||||
|
local itemname = item:get_name()
|
||||||
|
if itemname == "default:snow" then
|
||||||
|
snow_shoot_snowball(nil, player)
|
||||||
|
active = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- disable the function if noone currently throws them
|
||||||
|
if not active then
|
||||||
|
someone_throwing = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- do automatic throwing using a globalstep
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
-- only if one holds left click
|
||||||
|
if someone_throwing then
|
||||||
|
update_step(dtime)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
--The snowball Entity
|
--The snowball Entity
|
||||||
snow_snowball_ENTITY={
|
local snow_snowball_ENTITY = {
|
||||||
physical = false,
|
physical = false,
|
||||||
timer = 0,
|
timer = 0,
|
||||||
textures = {"default_snowball.png"},
|
collisionbox = {-5/16,-5/16,-5/16, 5/16,5/16,5/16},
|
||||||
lastpos={},
|
|
||||||
collisionbox = {0,0,0,0,0,0},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--Snowball_entity.on_step()--> called when snowball is moving.
|
function snow_snowball_ENTITY.on_activate(self)
|
||||||
snow_snowball_ENTITY.on_step = function(self, dtime)
|
self.object:set_properties({textures = {"default_snowball.png^[transform"..math.random(0,7)}})
|
||||||
self.timer=self.timer+dtime
|
self.object:setacceleration({x=0, y=-get_gravity(), z=0})
|
||||||
local pos = self.object:getpos()
|
self.lastpos = self.object:getpos()
|
||||||
local node = minetest.get_node(pos)
|
minetest.after(0.1, function(obj)
|
||||||
|
if not obj then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local vel = obj:getvelocity()
|
||||||
|
if vel
|
||||||
|
and vel.y ~= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.after(0, function(obj)
|
||||||
|
if not obj then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local vel = obj:getvelocity()
|
||||||
|
if not vel
|
||||||
|
or vel.y == 0 then
|
||||||
|
obj:remove()
|
||||||
|
end
|
||||||
|
end, obj)
|
||||||
|
end, self.object)
|
||||||
|
end
|
||||||
|
|
||||||
--Become item when hitting a node.
|
--Snowball_entity.on_step()--> called when snowball is moving.
|
||||||
if self.lastpos.x~=nil then --If there is no lastpos for some reason. ~ Splizard
|
function snow_snowball_ENTITY.on_step(self, dtime)
|
||||||
-- Check to see what is one node above where the snow is
|
self.timer = self.timer+dtime
|
||||||
-- going to be placed. ~ LazyJ, 2014_04_08
|
if self.timer > 600 then
|
||||||
local abovesnowballtarget = {x=pos.x, y=pos.y+1, z=pos.z}
|
-- 10 minutes are too long for a snowball to fly somewhere
|
||||||
-- Identify the name of the node that was found above. ~ LazyJ, 2014_04_08
|
|
||||||
local findwhatisabove = minetest.get_node(abovesnowballtarget).name
|
|
||||||
-- If the node above is air, then it's OK to go on to the next step. ~ LazyJ, 2014_04_08
|
|
||||||
if findwhatisabove == "air" then
|
|
||||||
-- If the node where the snow is going is anything except air, then it's OK to put
|
|
||||||
-- the snow on it. ~ Original line of code by Splizard, comment by LazyJ so I can
|
|
||||||
-- keep track of what this code does. ~ LazyJ, 2014_04_07
|
|
||||||
if node.name ~= "air" then
|
|
||||||
snow.place(pos) -- this is the original code, I replaced it with
|
|
||||||
-- minetest.place_node and bumped the y position up by 2 (make the snow drop
|
|
||||||
-- from a node above and pile up). ~ LazyJ, 2014_04_07
|
|
||||||
--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"})
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
else -- If findwhatisabove is not equal to "air" then cancel the snowball
|
|
||||||
-- with self.object:remove() ~ LazyJ, 2014_04_08
|
if self.physical then
|
||||||
|
local fell = self.object:getvelocity().y == 0
|
||||||
|
if not fell then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = vector.round(self.object:getpos())
|
||||||
|
if minetest.get_node(pos).name == "air" then
|
||||||
|
pos.y = pos.y-1
|
||||||
|
if minetest.get_node(pos).name == "air" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
snow.place(pos)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local pos = vector.round(self.object:getpos())
|
||||||
|
if vector.equals(pos, self.lastpos) then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
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})
|
||||||
|
pos = self.lastpos
|
||||||
|
self.object:setpos(pos)
|
||||||
|
local gain = vector.length(self.object:getvelocity())/30
|
||||||
|
minetest.sound_play("default_snow_footstep", {pos=pos, gain=gain})
|
||||||
|
self.object:set_properties({physical = true})
|
||||||
|
self.physical = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.lastpos = vector.new(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -118,16 +206,8 @@ minetest.override_item("default:snow", {
|
|||||||
drop = {
|
drop = {
|
||||||
max_items = 2,
|
max_items = 2,
|
||||||
items = {
|
items = {
|
||||||
{
|
{items = {'snow:moss'}, rarity = 20,},
|
||||||
-- player will get sapling with 1/20 chance
|
{items = {'default:snow'},}
|
||||||
items = {'snow:moss'},
|
|
||||||
rarity = 20,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- player will get leaves only if he get no saplings,
|
|
||||||
-- this is because max_items is 1
|
|
||||||
items = {'default:snow'},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leveled = 7,
|
leveled = 7,
|
||||||
@ -142,73 +222,64 @@ minetest.override_item("default:snow", {
|
|||||||
--Disable placement prediction for snow.
|
--Disable placement prediction for snow.
|
||||||
node_placement_prediction = "",
|
node_placement_prediction = "",
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt_with_grass"
|
pos.y = pos.y-1
|
||||||
or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then
|
local node = minetest.get_node(pos)
|
||||||
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
|
if node.name == "default:dirt_with_grass"
|
||||||
|
or node.name == "default:dirt" then
|
||||||
|
node.name = "default:dirt_with_snow"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
--Remove dirt_with_snow and replace with dirt_with_grass.
|
|
||||||
--[[after_destruct = function(pos)
|
|
||||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt_with_snow" then
|
|
||||||
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_grass"})
|
|
||||||
end
|
|
||||||
end,]]
|
|
||||||
--Handle node drops due to node level.
|
--Handle node drops due to node level.
|
||||||
on_dig = function(pos, node, digger)
|
on_dig = function(pos, node, digger)
|
||||||
local level = minetest.get_node_level(pos)
|
local level = minetest.get_node_level(pos)
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
if minetest.get_node(pos).name ~= node.name then
|
if minetest.get_node(pos).name ~= node.name then
|
||||||
if digger:get_inventory() then
|
local inv = digger:get_inventory()
|
||||||
local _, dropped_item
|
if not inv then
|
||||||
local left = digger:get_inventory():add_item("main", "default:snow "..tostring(level/7-1))
|
return
|
||||||
|
end
|
||||||
|
local left = inv:add_item("main", "default:snow "..tostring(level/7-1))
|
||||||
if not left:is_empty() then
|
if not left:is_empty() then
|
||||||
local p = {
|
minetest.add_item({
|
||||||
x = pos.x + math.random()/2-0.25,
|
x = pos.x + math.random()/2-0.25,
|
||||||
y = pos.y + math.random()/2-0.25,
|
y = pos.y + math.random()/2-0.25,
|
||||||
z = pos.z + math.random()/2-0.25,
|
z = pos.z + math.random()/2-0.25,
|
||||||
}
|
}, left)
|
||||||
minetest.add_item(p, left)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
--Manage snow levels.
|
--Manage snow levels.
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local node
|
|
||||||
local above
|
|
||||||
local level
|
|
||||||
|
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local oldnode_under = minetest.get_node_or_nil(under)
|
local oldnode_under = minetest.get_node_or_nil(under)
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local oldnode_above = minetest.get_node_or_nil(above)
|
|
||||||
|
|
||||||
if not oldnode_under or not oldnode_above then
|
if not oldnode_under
|
||||||
|
or not above then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
|
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
|
||||||
olddef_under = olddef_under or minetest.nodedef_default
|
olddef_under = olddef_under or minetest.nodedef_default
|
||||||
local olddef_above = ItemStack({name=oldnode_above.name}):get_definition()
|
|
||||||
olddef_above = olddef_above or minetest.nodedef_default
|
|
||||||
|
|
||||||
-- Place above pointed node
|
|
||||||
local place_to = {x = above.x, y = above.y, z = above.z}
|
|
||||||
|
|
||||||
|
local place_to
|
||||||
-- If node under is buildable_to, place into it instead (eg. snow)
|
-- If node under is buildable_to, place into it instead (eg. snow)
|
||||||
if olddef_under.buildable_to then
|
if olddef_under.buildable_to then
|
||||||
place_to = {x = under.x, y = under.y, z = under.z}
|
place_to = under
|
||||||
|
else
|
||||||
|
-- Place above pointed node
|
||||||
|
place_to = above
|
||||||
end
|
end
|
||||||
|
|
||||||
node = minetest.get_node(place_to)
|
local level = minetest.get_node_level(place_to)
|
||||||
level = minetest.get_node_level(place_to)
|
|
||||||
if level == 63 then
|
if level == 63 then
|
||||||
minetest.set_node(place_to, {name="default:snowblock"})
|
minetest.set_node(place_to, {name="default:snowblock"})
|
||||||
else
|
else
|
||||||
minetest.set_node_level(place_to, level+7)
|
minetest.set_node_level(place_to, level+7)
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "default:snow" then
|
if minetest.get_node(place_to).name ~= "default:snow" then
|
||||||
local itemstack, placed = minetest.item_place_node(itemstack, placer, pointed_thing)
|
local itemstack, placed = minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
return itemstack, placed
|
return itemstack, placed
|
||||||
end
|
end
|
||||||
@ -217,8 +288,7 @@ minetest.override_item("default:snow", {
|
|||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_use = snow_shoot_snowball -- This line is from the 'Snow' mod,
|
on_use = snow_shoot_snowball
|
||||||
-- the reset is default Minetest. ~ LazyJ
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--Global config and function table.
|
--Global config and function table.
|
||||||
snow = {
|
snow = {
|
||||||
legacy = true,
|
snowball_gravity = 100/109,
|
||||||
|
snowball_velocity = 19,
|
||||||
sleds = true,
|
sleds = true,
|
||||||
enable_snowfall = true,
|
enable_snowfall = true,
|
||||||
lighter_snowfall = false,
|
lighter_snowfall = false,
|
||||||
@ -8,20 +9,21 @@ snow = {
|
|||||||
smooth_biomes = true,
|
smooth_biomes = true,
|
||||||
christmas_content = true,
|
christmas_content = true,
|
||||||
smooth_snow = true,
|
smooth_snow = true,
|
||||||
min_height = 50,
|
min_height = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
--Config documentation.
|
--Config documentation.
|
||||||
local doc = {
|
local doc = {
|
||||||
legacy = "Whether you are running a legacy minetest version (auto-detected).",
|
snowball_gravity = "The gravity of thrown snowballs",
|
||||||
|
snowball_velocity = "How fast players throw snowballs",
|
||||||
sleds = "Disable this to prevent sleds from being riden.",
|
sleds = "Disable this to prevent sleds from being riden.",
|
||||||
enable_snowfall = "Enables falling snow.",
|
enable_snowfall = "Enables falling snow.",
|
||||||
lighter_snowfall = "Reduces the amount of resources and fps used by snowfall.",
|
lighter_snowfall = "Reduces the amount of resources and fps used by snowfall.",
|
||||||
debug = "Enables debug output.",
|
debug = "Enables debug output. Currently it only prints mgv6 info.",
|
||||||
smooth_biomes = "Enables smooth transition of biomes",
|
smooth_biomes = "Enables smooth transition of biomes (mgv6)",
|
||||||
christmas_content = "Disable this to remove christmas saplings from being found.",
|
|
||||||
smooth_snow = "Disable this to stop snow from being smoothed.",
|
smooth_snow = "Disable this to stop snow from being smoothed.",
|
||||||
min_height = "The minumum height a snow biome will generate.",
|
christmas_content = "Disable this to remove christmas saplings from being found.",
|
||||||
|
min_height = "The minumum height a snow biome will generate (mgv7)",
|
||||||
}
|
}
|
||||||
|
|
||||||
--Manage config.
|
--Manage config.
|
||||||
@ -64,7 +66,9 @@ local function loadConfig(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_shutdown(function() saveConfig(minetest.get_modpath("snow").."/config.txt", snow, doc) end)
|
minetest.register_on_shutdown(function()
|
||||||
|
saveConfig(minetest.get_modpath("snow").."/config.txt", snow, doc)
|
||||||
|
end)
|
||||||
|
|
||||||
local config = loadConfig(minetest.get_modpath("snow").."/config.txt")
|
local config = loadConfig(minetest.get_modpath("snow").."/config.txt")
|
||||||
if config then
|
if config then
|
||||||
@ -79,7 +83,9 @@ end
|
|||||||
|
|
||||||
for i,v in pairs(snow) do
|
for i,v in pairs(snow) do
|
||||||
local t = type(v)
|
local t = type(v)
|
||||||
if t == "string" or t == "number" or t == "boolean" then
|
if t == "string"
|
||||||
|
or t == "number"
|
||||||
|
or t == "boolean" then
|
||||||
local v = minetest.setting_get("snow_"..i)
|
local v = minetest.setting_get("snow_"..i)
|
||||||
if v ~= nil then
|
if v ~= nil then
|
||||||
if v == "true" then v = true end
|
if v == "true" then v = true end
|
||||||
@ -90,18 +96,6 @@ for i,v in pairs(snow) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--AUTO DETECT and/or OVERIDEN values--
|
|
||||||
|
|
||||||
--legacy--
|
|
||||||
--Detect if we are running the latest minetest.
|
|
||||||
if minetest.register_on_mapgen_init then
|
|
||||||
snow.legacy = false
|
|
||||||
else
|
|
||||||
snow.legacy = true
|
|
||||||
end
|
|
||||||
if config and snow.legacy ~= config.legacy then
|
|
||||||
saveConfig(minetest.get_modpath("snow").."/config.txt", snow, doc)
|
|
||||||
end
|
|
||||||
|
|
||||||
--MENU
|
--MENU
|
||||||
|
|
||||||
@ -110,7 +104,8 @@ local get_formspec = function()
|
|||||||
local formspec = "label[0,-0.3;Settings:]"
|
local formspec = "label[0,-0.3;Settings:]"
|
||||||
for i,v in pairs(snow) do
|
for i,v in pairs(snow) do
|
||||||
local t = type(v)
|
local t = type(v)
|
||||||
if t == "string" or t == "number" then
|
if t == "string"
|
||||||
|
or t == "number" then
|
||||||
p = p + 1.5
|
p = p + 1.5
|
||||||
formspec = formspec.."field[0.3,"..p..";2,1;snow:"..i..";"..i..";"..v.."]"
|
formspec = formspec.."field[0.3,"..p..";2,1;snow:"..i..";"..i..";"..v.."]"
|
||||||
elseif t == "boolean" then
|
elseif t == "boolean" then
|
||||||
@ -124,20 +119,25 @@ local get_formspec = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "snow:menu" then
|
if formname ~= "snow:menu" then
|
||||||
|
return
|
||||||
|
end
|
||||||
for i,v in pairs(snow) do
|
for i,v in pairs(snow) do
|
||||||
local t = type(v)
|
local t = type(v)
|
||||||
if t == "string" or t == "number" or t == "boolean" then
|
if t == "string" or t == "number" or t == "boolean" then
|
||||||
if fields["snow:"..i] then
|
local field = fields["snow:"..i]
|
||||||
|
if field then
|
||||||
if t == "string" then
|
if t == "string" then
|
||||||
snow[i] = fields["snow:"..i]
|
snow[i] = field
|
||||||
end
|
end
|
||||||
if t == "number" then
|
if t == "number" then
|
||||||
snow[i] = tonumber(fields["snow:"..i])
|
snow[i] = tonumber(field)
|
||||||
end
|
end
|
||||||
if t == "boolean" then
|
if t == "boolean" then
|
||||||
if fields["snow:"..i] == "true" then snow[i] = true end
|
if field == "true" then
|
||||||
if fields["snow:"..i] == "false" then snow[i] = false end
|
snow[i] = true
|
||||||
|
elseif field == "false" then
|
||||||
|
snow[i] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -149,7 +149,8 @@ end)
|
|||||||
minetest.register_chatcommand("snow", {
|
minetest.register_chatcommand("snow", {
|
||||||
description = "Show a menu for various actions",
|
description = "Show a menu for various actions",
|
||||||
privs = {server=true},
|
privs = {server=true},
|
||||||
func = function(name, param)
|
func = function(name)
|
||||||
|
minetest.chat_send_player(name, "Showing snow menu…")
|
||||||
minetest.show_formspec(name, "snow:menu", get_formspec())
|
minetest.show_formspec(name, "snow:menu", get_formspec())
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Binary file not shown.
BIN
mods/snow/textures/default_snowball.png
Normal file
BIN
mods/snow/textures/default_snowball.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 211 B |
@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
id="svg2"
|
|
||||||
version="1.1"
|
|
||||||
inkscape:version="0.48.4 r9939"
|
|
||||||
sodipodi:docname="inkscape_default_ice.svg">
|
|
||||||
<defs
|
|
||||||
id="defs4" />
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="45.4375"
|
|
||||||
inkscape:cx="6.8335626"
|
|
||||||
inkscape:cy="8"
|
|
||||||
inkscape:document-units="px"
|
|
||||||
inkscape:current-layer="layer1"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:showpageshadow="false"
|
|
||||||
inkscape:window-width="1328"
|
|
||||||
inkscape:window-height="895"
|
|
||||||
inkscape:window-x="197"
|
|
||||||
inkscape:window-y="70"
|
|
||||||
inkscape:window-maximized="0" />
|
|
||||||
<metadata
|
|
||||||
id="metadata7">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:title></dc:title>
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(0,-1036.3622)">
|
|
||||||
<rect
|
|
||||||
style="fill:#91d2ff;fill-rule:evenodd;stroke:none;fill-opacity:1;opacity:0.90000000000000002"
|
|
||||||
id="rect2985"
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
x="0"
|
|
||||||
y="1036.3622"
|
|
||||||
inkscape:export-xdpi="90"
|
|
||||||
inkscape:export-ydpi="90"
|
|
||||||
inkscape:export-filename="/home/trickpaint/Minetest/Minetest_game_stuff/049_modtest/worlds/developing_snow_overhaul/worldmods/snow_developing/snow/textures/default_ice.png" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 206 B |
Binary file not shown.
Before Width: | Height: | Size: 189 B |
Binary file not shown.
Before Width: | Height: | Size: 350 B |
Binary file not shown.
Loading…
Reference in New Issue
Block a user