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