Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
84561db68a |
11
.github/workflows/luacheck.yml
vendored
@ -1,11 +0,0 @@
|
|||||||
on: [push, pull_request]
|
|
||||||
name: luacheck
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
- name: lint
|
|
||||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
|
||||||
with:
|
|
||||||
luacheckrc_url: ""
|
|
0
.gitignore
vendored
Normal file → Executable file
25
.luacheckrc
@ -1,25 +0,0 @@
|
|||||||
read_globals = {
|
|
||||||
"dump", "vector",
|
|
||||||
"table", "math", "PseudoRandom", "VoxelArea",
|
|
||||||
"stairs", "stairsplus", "skins", "treecapitator",
|
|
||||||
default = {
|
|
||||||
fields = {
|
|
||||||
player_attached = {
|
|
||||||
read_only = false,
|
|
||||||
other_fields = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
other_fields = true
|
|
||||||
},
|
|
||||||
minetest = {
|
|
||||||
fields = {
|
|
||||||
registered_nodes = {
|
|
||||||
read_only = false,
|
|
||||||
other_fields = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
other_fields = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globals = {"snow"}
|
|
||||||
-- ignore = {"421", "423"}
|
|
0
LazyJ-changelog.txt
Normal file → Executable file
5
changelog.txt
Normal file → Executable file
@ -1,10 +1,5 @@
|
|||||||
CHANGELOG:
|
CHANGELOG:
|
||||||
------------
|
------------
|
||||||
Version 4.0
|
|
||||||
|
|
||||||
Snow mod is now a complimentary mod to the default snow found in minetest.
|
|
||||||
|
|
||||||
HybridDog's large changes, fixes and more (see commit log).
|
|
||||||
|
|
||||||
Version 3.2
|
Version 3.2
|
||||||
|
|
||||||
|
4
depends.txt
Normal file → Executable file
@ -1,6 +1,4 @@
|
|||||||
default
|
default
|
||||||
flowers?
|
flowers?
|
||||||
stairs?
|
|
||||||
moreblocks?
|
moreblocks?
|
||||||
skins?
|
watershed?
|
||||||
treecapitator?
|
|
||||||
|
55
init.lua
Normal file → Executable file
@ -47,35 +47,43 @@ http://github.com/Splizard/minetest-mod-snow/
|
|||||||
-- Until something else can be figured out, use paramat's "Snowdrift" mod instead.
|
-- Until something else can be figured out, use paramat's "Snowdrift" mod instead.
|
||||||
-- dofile(modpath.."/falling_snow.lua")
|
-- dofile(modpath.."/falling_snow.lua")
|
||||||
|
|
||||||
local load_time_start = minetest.get_us_time()
|
|
||||||
|
|
||||||
|
|
||||||
-- Original init.lua File Broken into Smaller Files
|
-- Original init.lua File Broken into Smaller Files
|
||||||
local srcpath = minetest.get_modpath"snow".."/src/"
|
local modpath = minetest.get_modpath("snow")
|
||||||
dofile(srcpath.."abms.lua")
|
dofile(modpath.."/src/abms.lua")
|
||||||
dofile(srcpath.."aliases.lua")
|
dofile(modpath.."/src/aliases.lua")
|
||||||
dofile(srcpath.."crafting.lua")
|
dofile(modpath.."/src/crafting.lua")
|
||||||
|
|
||||||
|
|
||||||
-- The formspec menu didn't work when util.lua was the very first "dofile" so I moved
|
-- 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
|
-- 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
|
-- 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
|
-- I put it lower on the list and that seems to do the trick. ~ LazyJ
|
||||||
dofile(srcpath.."util.lua")
|
dofile(modpath.."/src/util.lua")
|
||||||
dofile(srcpath.."snowball.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.
|
-- To get Xmas tree saplings, the "christmas_content", true or false, in "util.lua" has to be determined first.
|
||||||
-- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ
|
-- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ
|
||||||
dofile(srcpath.."nodes.lua")
|
dofile(modpath.."/src/nodes.lua")
|
||||||
dofile(srcpath.."stairs.lua")
|
dofile(modpath.."/src/basic_stairs_slabs.lua")
|
||||||
dofile(srcpath.."mapgen.lua")
|
-- dofile(modpath.."/src/mapgen.lua")
|
||||||
dofile(srcpath.."sled.lua")
|
dofile(modpath.."/src/sled.lua")
|
||||||
dofile(srcpath.."falling_snow.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
|
local is_uneven
|
||||||
--This function places snow checking at the same time for snow level and increasing as needed.
|
--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.
|
--This also takes into account sourrounding snow and makes snow even.
|
||||||
function snow.place(pos, disablesound)
|
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)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
|
||||||
--Oops, maybe there is no node?
|
--Oops, maybe there is no node?
|
||||||
@ -89,23 +97,17 @@ function snow.place(pos, disablesound)
|
|||||||
if level < 63 then
|
if level < 63 then
|
||||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "leafdecay") == 0
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "leafdecay") == 0
|
||||||
and not is_uneven(pos) then
|
and not is_uneven(pos) then
|
||||||
if not disablesound then
|
|
||||||
minetest.sound_play("default_snow_footstep", {pos=pos})
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
||||||
end
|
|
||||||
minetest.add_node_level(pos, 7)
|
minetest.add_node_level(pos, 7)
|
||||||
end
|
end
|
||||||
elseif level == 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
|
if p
|
||||||
and minetest.get_node_light(p, 0.5) == 15 then
|
and minetest.get_node_light(p, 0.5) == 15 then
|
||||||
if not disablesound then
|
|
||||||
minetest.sound_play("default_grass_footstep", {pos=pos})
|
minetest.sound_play("default_grass_footstep", {pos=pos})
|
||||||
end
|
|
||||||
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
|
||||||
if not disablesound then
|
|
||||||
minetest.sound_play("default_snow_footstep", {pos=pos})
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
||||||
end
|
|
||||||
minetest.add_node(pos, {name="default:snowblock"})
|
minetest.add_node(pos, {name="default:snowblock"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -117,7 +119,7 @@ function snow.place(pos, disablesound)
|
|||||||
or drawtype == "allfaces_optional" then
|
or drawtype == "allfaces_optional" then
|
||||||
pos.y = pos.y+1
|
pos.y = pos.y+1
|
||||||
local sound = data.sounds
|
local sound = data.sounds
|
||||||
if sound and not disablesound then
|
if sound then
|
||||||
sound = sound.footstep
|
sound = sound.footstep
|
||||||
if sound then
|
if sound then
|
||||||
minetest.sound_play(sound.name, {pos=pos, gain=sound.gain})
|
minetest.sound_play(sound.name, {pos=pos, gain=sound.gain})
|
||||||
@ -196,12 +198,3 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end
|
end
|
||||||
end
|
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
|
|
||||||
|
37
license.txt
Normal file → Executable file
@ -1,40 +1,3 @@
|
|||||||
License of media (snowdrift are from paramat)
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|
||||||
|
|
||||||
You are free to:
|
|
||||||
Share — copy and redistribute the material in any medium or format.
|
|
||||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
|
||||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
|
||||||
|
|
||||||
Under the following terms:
|
|
||||||
|
|
||||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
|
||||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
|
||||||
that suggests the licensor endorses you or your use.
|
|
||||||
|
|
||||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
|
||||||
your contributions under the same license as the original.
|
|
||||||
|
|
||||||
No additional restrictions — You may not apply legal terms or technological measures that
|
|
||||||
legally restrict others from doing anything the license permits.
|
|
||||||
|
|
||||||
Notices:
|
|
||||||
|
|
||||||
You do not have to comply with the license for elements of the material in the public
|
|
||||||
domain or where your use is permitted by an applicable exception or limitation.
|
|
||||||
No warranties are given. The license may not give you all of the permissions necessary
|
|
||||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
|
||||||
rights may limit how you use the material.
|
|
||||||
|
|
||||||
For more details:
|
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
||||||
|
|
||||||
|
|
||||||
License of source code and other textures.
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
0
models/sled.x
Normal file → Executable file
0
other_textures/connected_textures_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 656 B |
0
other_textures/default_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 82 B After Width: | Height: | Size: 82 B |
0
other_textures/default_ice.xcf
Normal file → Executable file
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 384 B |
0
other_textures/inkscape_default_ice.svg
Normal file → Executable file
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
0
other_textures/mocha.png
Normal file → Executable file
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
0
other_textures/mocha.xcf
Normal file → Executable file
0
other_textures/original_snow_snow_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 300 B |
0
other_textures/rect2985.png
Normal file → Executable file
Before Width: | Height: | Size: 81 B After Width: | Height: | Size: 81 B |
0
other_textures/snow_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
0
other_textures/snow_needles_decorated_animated.xcf
Normal file → Executable file
0
other_textures/snow_snow.png
Normal file → Executable file
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 164 B |
0
other_textures/snow_snow_brick.xcf
Normal file → Executable file
0
other_textures/snow_snow_cobble.xcf
Normal file → Executable file
0
other_textures/snow_snow_side.png
Normal file → Executable file
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 726 B |
0
other_textures/snow_snowball.png
Normal file → Executable file
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
0
other_textures/snow_snowfall.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
0
other_textures/snow_star_lit.xcf
Normal file → Executable file
0
other_textures/xdefault_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B |
0
other_textures/xdefault_furnace_bottom.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_furnace_fire_bg.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
0
other_textures/xdefault_furnace_fire_fg.png
Normal file → Executable file
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
0
other_textures/xdefault_furnace_front.png
Normal file → Executable file
Before Width: | Height: | Size: 553 B After Width: | Height: | Size: 553 B |
0
other_textures/xdefault_furnace_front_active.png
Normal file → Executable file
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
0
other_textures/xdefault_furnace_side.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_furnace_top.png
Normal file → Executable file
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
0
other_textures/xdefault_glass.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
0
other_textures/xdefault_ice.png
Normal file → Executable file
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
0
other_textures/xdefault_ice.xcf
Normal file → Executable file
0
other_textures/xdefault_snow.png
Normal file → Executable file
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 164 B |
0
other_textures/xdefault_stone_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 572 B After Width: | Height: | Size: 572 B |
57
readme.txt
Normal file → Executable file
@ -1,23 +1,25 @@
|
|||||||
_____ __ __ _
|
_____ __ __ _
|
||||||
/ ____| | \/ | | |
|
/ ____| | \/ | | |
|
||||||
| (___ _ __ _____ __ | \ / | ___ __| |
|
| (___ _ __ _____ __ | \ / | ___ __| |
|
||||||
\___ \| '_ \ / _ \ \ /\ / / | |\/| |/ _ \ / _` |
|
\___ \| '_ \ / _ \ \ /\ / / | |\/| |/ _ \ / _` |
|
||||||
____) | | | | (_) \ V V / | | | | (_) | (_| |
|
____) | | | | (_) \ V V / | | | | (_) | (_| |
|
||||||
|_____/|_| |_|\___/ \_/\_/ |_| |_|\___/ \__,_|
|
|_____/|_| |_|\___/ \_/\_/ |_| |_|\___/ \__,_|
|
||||||
|
|
||||||
|
Version 3.2
|
||||||
|
|
||||||
|
By Splizard and LazyJ.
|
||||||
|
|
||||||
Version 4.0
|
Minetest version: 0.4.9
|
||||||
|
|
||||||
By Splizard, HybridDog and LazyJ.
|
|
||||||
|
|
||||||
Minetest version: 0.4.16+
|
|
||||||
Depends: default
|
Depends: default
|
||||||
License: GPL v3
|
License: GPL v2
|
||||||
|
|
||||||
Complimentary Mods:
|
Complimentary Mods:
|
||||||
---------------------
|
---------------------
|
||||||
|
* "Snowdrift" by paramat
|
||||||
* "More Blocks" by Calinou (2014_05_11 or newer)
|
* "More Blocks" by Calinou (2014_05_11 or newer)
|
||||||
* "Skins" by Zeg9
|
* "Skins" by Zeg9
|
||||||
|
|
||||||
|
|
||||||
Install:
|
Install:
|
||||||
|
|
||||||
Forum post: http://minetest.net/forum/viewtopic.php?id=2290
|
Forum post: http://minetest.net/forum/viewtopic.php?id=2290
|
||||||
@ -41,8 +43,26 @@ Place this folder in your minetest mods folder.
|
|||||||
world's "world.mt" file:
|
world's "world.mt" file:
|
||||||
load_mod_snow = true
|
load_mod_snow = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NOTICE
|
||||||
|
While this mod is installed you may experience slower map loading while a snow biome is generated.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
-------
|
-------
|
||||||
|
If you walk around a bit you will find snow biomes scattered around the world.
|
||||||
|
|
||||||
|
There are nine biome types:
|
||||||
|
* Normal
|
||||||
|
* Icebergs
|
||||||
|
* Icesheet
|
||||||
|
* Broken icesheet
|
||||||
|
* Icecave
|
||||||
|
* Coast
|
||||||
|
* Alpine
|
||||||
|
* Snowy
|
||||||
|
* Plain
|
||||||
|
|
||||||
Snow can be picked up and thrown as snowballs or stacked into snow blocks.
|
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 and ice melts when near warm blocks such as torches or igniters such as lava.
|
||||||
Snow blocks freeze water source blocks around them.
|
Snow blocks freeze water source blocks around them.
|
||||||
@ -66,21 +86,18 @@ Icy Snow:
|
|||||||
Snow Ice
|
Snow Ice
|
||||||
Ice Snow
|
Ice Snow
|
||||||
|
|
||||||
|
MAPGEN_V7:
|
||||||
|
------------
|
||||||
|
If you are using minetest 0.4.8 or the latest dev version of minetest you can choose to generate a v7 map.
|
||||||
|
This option can be found when creating a new map from the menu.
|
||||||
|
Snow Biomes has support for this though you might need a couple other biomes too otherwise you will only spawn snow.
|
||||||
|
There are a couple of bugs and limitations with this such as no ice being generated at the moment.
|
||||||
|
|
||||||
Config file:
|
Config file:
|
||||||
------------
|
------------
|
||||||
You can change various settings from the advanced settings in Minetest.
|
After starting a game in minetest with snow mod, a config file will be placed in this folder that contains the various options for snow mod.
|
||||||
|
As admin you can use the /snow command in-game to make various changes.
|
||||||
|
|
||||||
* Go to the settings tab.
|
|
||||||
* Click on Advanced Settings.
|
|
||||||
* Click on Mods.
|
|
||||||
* Click on snow.
|
|
||||||
* Change stuff!
|
|
||||||
|
|
||||||
UNINSTALL:
|
UNINSTALL:
|
||||||
------------
|
------------
|
||||||
Simply delete the folder snow from the mods folder.
|
Simply delete the folder snow from the mods folder.
|
||||||
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
— test if the fixed ground_y search works correctly at chunkcorners at ground level
|
|
||||||
|
0
schematics/pine.mts
Normal file → Executable file
@ -1,39 +0,0 @@
|
|||||||
#The gravity of thrown snowballs.
|
|
||||||
snow_snowball_gravity (Snowball Gravity) float 0.91
|
|
||||||
|
|
||||||
#How fast players throw snowballs.
|
|
||||||
snow_snowball_velocity (Snowball Velocity) float 19
|
|
||||||
|
|
||||||
#Enable/Disable sleds.
|
|
||||||
snow_sleds (Enable Sleds) bool true
|
|
||||||
|
|
||||||
#Enables falling snow.
|
|
||||||
snow_enable_snowfall (Enable Snowfall) bool true
|
|
||||||
|
|
||||||
#Reduces the amount of resources and fps used by snowfall.
|
|
||||||
snow_lighter_snowfall (Use Light Snowfall) bool false
|
|
||||||
|
|
||||||
#Enables debug output. Currently it only prints mgv6 info.
|
|
||||||
snow_debug (Debug Mode) bool false
|
|
||||||
|
|
||||||
#Disable this to remove christmas saplings from being found.
|
|
||||||
snow_christmas_content (Enable Christmas Content) bool true
|
|
||||||
|
|
||||||
#Enables smooth biome transitions.
|
|
||||||
snow_smooth_biomes (Smooth Biome Transitions) bool true
|
|
||||||
|
|
||||||
#The minumum height a snow biome will generate (mgv7)
|
|
||||||
snow_min_height (Minumum Height for Snow Biomes) int 3
|
|
||||||
|
|
||||||
#Disable this to stop snow from being smoothed.
|
|
||||||
snow_smooth_snow (Multiple Snow Levels) bool true
|
|
||||||
|
|
||||||
#mapgen rarity in %. Note that this and mapgen_size do not work right because
|
|
||||||
#sinus instead of Gauss curve is used as estimation.
|
|
||||||
snow_mapgen_rarity (Snow Biome Rarity %) float 18
|
|
||||||
|
|
||||||
#size of the generated… (has an effect to the rarity, too)
|
|
||||||
snow_mapgen_size (Snow Biome Size) float 210
|
|
||||||
|
|
||||||
#Minetest finally has capable snow biomes by default, lets not mess it up with the old snowgen.
|
|
||||||
snow_disable_mapgen (Disable mod-generated biomes) bool true
|
|
59
src/abms.lua
Normal file → Executable file
@ -1,12 +1,23 @@
|
|||||||
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let
|
--Backwards Compatability.
|
||||||
-- light through (sunlight_propagates) or have a light paramtype and
|
minetest.register_abm({
|
||||||
-- liquidtype combination. ~ LazyJ, 2014_03_08
|
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({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt_with_snow"},
|
nodenames = {"default:dirt_with_snow"},
|
||||||
interval = 2,
|
interval = 2,
|
||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos)
|
action = function(pos, node)
|
||||||
local name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
|
local name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
|
||||||
local nodedef = minetest.registered_nodes[name]
|
local nodedef = minetest.registered_nodes[name]
|
||||||
if name ~= "ignore"
|
if name ~= "ignore"
|
||||||
@ -39,9 +50,9 @@ minetest.register_abm({
|
|||||||
if intensity == 1 then
|
if intensity == 1 then
|
||||||
minetest.set_node(pos, {name="default:water_source"})
|
minetest.set_node(pos, {name="default:water_source"})
|
||||||
elseif intensity == 2 then
|
elseif intensity == 2 then
|
||||||
minetest.set_node(pos, {name="default:water_flowing", param2=7})
|
minetest.set_node(pos, {name="default:water_flowing", param2=7})
|
||||||
elseif intensity == 3 then
|
elseif intensity == 3 then
|
||||||
minetest.set_node(pos, {name="default:water_flowing", param2=3})
|
minetest.set_node(pos, {name="default:water_flowing", param2=3})
|
||||||
--[[ LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06
|
--[[ LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06
|
||||||
This was causing "melts=2" nodes to just disappear so I changed it to replace the
|
This was causing "melts=2" nodes to just disappear so I changed it to replace the
|
||||||
node with a water_source for a couple seconds and then replace the water_source with
|
node with a water_source for a couple seconds and then replace the water_source with
|
||||||
@ -63,13 +74,14 @@ minetest.register_abm({
|
|||||||
-- the water to flow and spread before the
|
-- the water to flow and spread before the
|
||||||
-- water_source is changed to air. ~ LazyJ
|
-- water_source is changed to air. ~ LazyJ
|
||||||
if minetest.get_node(pos).name == "default:water_source" then
|
if minetest.get_node(pos).name == "default:water_source" then
|
||||||
minetest.add_node(pos,{name="air"})
|
minetest.add_node(pos,{name="air"})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
--]]
|
--]]
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
nodeupdate(pos)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -80,7 +92,7 @@ minetest.register_abm({
|
|||||||
--Water freezes when in contact with snow.
|
--Water freezes when in contact with snow.
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:water_source"},
|
nodenames = {"default:water_source"},
|
||||||
-- Added "group:icemaker" and snowbrick. ~ LazyJ
|
-- Added "group:icemaker" and snowbrick. ~ LazyJ
|
||||||
neighbors = {"default:snow", "default:snowblock", "snow:snow_brick", "group:icemaker"},
|
neighbors = {"default:snow", "default:snowblock", "snow:snow_brick", "group:icemaker"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 4,
|
chance = 4,
|
||||||
@ -108,10 +120,7 @@ minetest.register_abm({
|
|||||||
if math.random(2) == 2 then
|
if math.random(2) == 2 then
|
||||||
p.y = pos.y
|
p.y = pos.y
|
||||||
if minetest.get_node(p).name == "default:water_source" then
|
if minetest.get_node(p).name == "default:water_source" then
|
||||||
minetest.add_node(p, {
|
minetest.add_node(p,{name="default:ice", param2 = math.random(0,node.param2-1)})
|
||||||
name = "default:ice",
|
|
||||||
param2 = math.random(0,node.param2-1)
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -143,13 +152,13 @@ minetest.register_abm({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
--Grow Pine Saplings
|
--Grow Pine Saplings
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"snow:sapling_pine"},
|
nodenames = {"snow:sapling_pine"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 50,
|
chance = 50,
|
||||||
action = function(pos)
|
action = function(pos, node)
|
||||||
|
|
||||||
-- Check if there is enough vertical-space for the sapling to grow without
|
-- Check if there is enough vertical-space for the sapling to grow without
|
||||||
-- hitting anything else. ~ LazyJ, 2014_04_10
|
-- hitting anything else. ~ LazyJ, 2014_04_10
|
||||||
@ -162,27 +171,27 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
-- '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
|
-- This finds the sapling under the grown tree. ~ LazyJ
|
||||||
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
||||||
-- This switches the sapling to a tree trunk. ~ LazyJ
|
-- 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
|
-- This is more for testing but it may be useful info to some admins when
|
||||||
-- grepping the server logs too. ~ LazyJ
|
-- 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
|
||||||
end
|
end
|
||||||
})
|
})]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
--Grow Christmas Tree Saplings
|
--Grow Christmas Tree Saplings
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"snow:xmas_tree"},
|
nodenames = {"snow:xmas_tree"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 50,
|
chance = 50,
|
||||||
action = function(pos)
|
action = function(pos, node)
|
||||||
|
|
||||||
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
|
-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ
|
||||||
for i = 1,8 do
|
for i = 1,8 do
|
||||||
@ -192,14 +201,14 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
-- 'then' let the sapling grow into a tree. ~ LazyJ
|
-- '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
|
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,
|
--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.
|
-- then don't anything; including not allowing the sapling to grow.
|
||||||
-- ~ LazyJ, 2014_04_10
|
-- ~ LazyJ, 2014_04_10
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
})
|
})]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4
src/aliases.lua
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
-- Some aliases for compatibility switches and some to make "/give" commands
|
-- Some aliases for compatibility switches and some to make "/give" commands
|
||||||
-- a little easier
|
-- a little easier
|
||||||
|
|
||||||
|
minetest.register_alias("snow:needles", "default:pine_needles")
|
||||||
minetest.register_alias("snow:snow", "default:snow")
|
minetest.register_alias("snow:snow", "default:snow")
|
||||||
minetest.register_alias("default_snow", "default:snow")
|
minetest.register_alias("default_snow", "default:snow")
|
||||||
minetest.register_alias("snow:snowball", "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("snowcobble", "snow:snow_cobble")
|
||||||
minetest.register_alias("snowycobble", "snow:snow_cobble")
|
minetest.register_alias("snowycobble", "snow:snow_cobble")
|
||||||
minetest.register_alias("cobblesnow", "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.
|
-- To clean up my first stairsplus attempt.
|
||||||
-- Stair
|
-- Stair
|
||||||
|
302
src/basic_stairs_slabs.lua
Executable file
@ -0,0 +1,302 @@
|
|||||||
|
-- Based on
|
||||||
|
-- Minetest 0.4 mod: stairs
|
||||||
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
|
|
||||||
|
-- ADD CHECK FOR MOREBLOCKS/SKIP IF NOT FOUND CODE STUFF HERE
|
||||||
|
|
||||||
|
|
||||||
|
-- what of the recipeitem can be copied
|
||||||
|
local recipe_values = {
|
||||||
|
"description", "tiles", "groups", "sounds", "use_texture_alpha", "sunlight_propagates",
|
||||||
|
"freezemelt", "liquidtype", "sunlight_propagates",
|
||||||
|
"stair_desc", "slab_desc"
|
||||||
|
}
|
||||||
|
|
||||||
|
local stairdef = {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = true,
|
||||||
|
sounds = default.node_sound_dirt_defaults({
|
||||||
|
footstep = {name="default_snow_footstep", gain=0.25},
|
||||||
|
dig = {name="default_dig_crumbly", gain=0.4},
|
||||||
|
dug = {name="default_snow_footstep", gain=0.75},
|
||||||
|
place = {name="default_place_node", gain=1.0}
|
||||||
|
}),
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||||
|
{-0.5, 0, 0, 0.5, 0.5, 0.5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if pointed_thing.type ~= "node" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local p0 = pointed_thing.under
|
||||||
|
local p1 = pointed_thing.above
|
||||||
|
local param2 = 0
|
||||||
|
|
||||||
|
local placer_pos = placer:getpos()
|
||||||
|
if placer_pos then
|
||||||
|
local dir = {
|
||||||
|
x = p1.x - placer_pos.x,
|
||||||
|
y = p1.y - placer_pos.y,
|
||||||
|
z = p1.z - placer_pos.z
|
||||||
|
}
|
||||||
|
param2 = minetest.dir_to_facedir(dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
if p0.y-1 == p1.y then
|
||||||
|
param2 = param2 + 20
|
||||||
|
if param2 == 21 then
|
||||||
|
param2 = 23
|
||||||
|
elseif param2 == 23 then
|
||||||
|
param2 = 21
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name == "default:dirt_with_grass"
|
||||||
|
-- Thinking in terms of layers, dirt_with_snow could also double as
|
||||||
|
-- dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ, 2014_04_04
|
||||||
|
or node.name == "default:dirt" then
|
||||||
|
node.name = "default:dirt_with_snow"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Node will be called snow:stair_<subname>
|
||||||
|
local function register_stair(subname, recipeitem, newdef)
|
||||||
|
local def = table.copy(stairdef)
|
||||||
|
|
||||||
|
|
||||||
|
for n,i in pairs(newdef) do
|
||||||
|
def[n] = i
|
||||||
|
end
|
||||||
|
|
||||||
|
local name = "snow:stair_" .. subname
|
||||||
|
minetest.register_node(name, def)
|
||||||
|
--[[
|
||||||
|
-- for replace ABM
|
||||||
|
minetest.register_node("snow:stair_" .. subname.."upside_down", {
|
||||||
|
replace_name = "snow:stair_" .. subname,
|
||||||
|
groups = {slabs_replace=1},
|
||||||
|
})
|
||||||
|
--]]
|
||||||
|
minetest.register_craft({
|
||||||
|
output = name .. " 6",
|
||||||
|
recipe = {
|
||||||
|
{recipeitem, "", ""},
|
||||||
|
{recipeitem, recipeitem, ""},
|
||||||
|
{recipeitem, recipeitem, recipeitem},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Flipped recipe
|
||||||
|
minetest.register_craft({
|
||||||
|
output = name .. " 6",
|
||||||
|
recipe = {
|
||||||
|
{"", "", recipeitem},
|
||||||
|
{"", recipeitem, recipeitem},
|
||||||
|
{recipeitem, recipeitem, recipeitem},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local slabdef = table.copy(stairdef)
|
||||||
|
slabdef.node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||||
|
}
|
||||||
|
slabdef.on_place = nil
|
||||||
|
|
||||||
|
-- Node will be called snow:slab_<subname>
|
||||||
|
local function register_slab(subname, recipeitem, newdef)
|
||||||
|
local def = table.copy(slabdef)
|
||||||
|
|
||||||
|
local name = "snow:slab_" .. subname
|
||||||
|
def.on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if pointed_thing.type ~= "node" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If it's being placed on an another similar one, replace it with
|
||||||
|
-- a full block
|
||||||
|
local slabpos, slabnode
|
||||||
|
local p0 = pointed_thing.under
|
||||||
|
local p1 = pointed_thing.above
|
||||||
|
local n0 = minetest.get_node(p0)
|
||||||
|
local n1 = minetest.get_node(p1)
|
||||||
|
|
||||||
|
local n0_is_upside_down = (n0.name == name and
|
||||||
|
n0.param2 >= 20)
|
||||||
|
|
||||||
|
if n0.name == name
|
||||||
|
and not n0_is_upside_down
|
||||||
|
and p0.y+1 == p1.y then
|
||||||
|
slabpos = p0
|
||||||
|
slabnode = n0
|
||||||
|
elseif n1.name == name then
|
||||||
|
slabpos = p1
|
||||||
|
slabnode = n1
|
||||||
|
end
|
||||||
|
if slabpos then
|
||||||
|
-- Remove the slab at slabpos
|
||||||
|
minetest.remove_node(slabpos)
|
||||||
|
-- Make a fake stack of a single item and try to place it
|
||||||
|
local fakestack = ItemStack(recipeitem)
|
||||||
|
fakestack:set_count(itemstack:get_count())
|
||||||
|
|
||||||
|
pointed_thing.above = slabpos
|
||||||
|
local success
|
||||||
|
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
|
||||||
|
-- If the item was taken from the fake stack, decrement original
|
||||||
|
if success then
|
||||||
|
itemstack:set_count(fakestack:get_count())
|
||||||
|
-- Else put old node back
|
||||||
|
else
|
||||||
|
minetest.set_node(slabpos, slabnode)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local param2
|
||||||
|
-- Upside down slabs
|
||||||
|
if p0.y-1 == p1.y then
|
||||||
|
-- Turn into full block if pointing at a existing slab
|
||||||
|
if n0_is_upside_down then
|
||||||
|
-- Remove the slab at the position of the slab
|
||||||
|
minetest.remove_node(p0)
|
||||||
|
-- Make a fake stack of a single item and try to place it
|
||||||
|
local fakestack = ItemStack(recipeitem)
|
||||||
|
fakestack:set_count(itemstack:get_count())
|
||||||
|
|
||||||
|
pointed_thing.above = p0
|
||||||
|
local success
|
||||||
|
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
|
||||||
|
-- If the item was taken from the fake stack, decrement original
|
||||||
|
if success then
|
||||||
|
itemstack:set_count(fakestack:get_count())
|
||||||
|
-- Else put old node back
|
||||||
|
else
|
||||||
|
minetest.set_node(p0, n0)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Place upside down slab
|
||||||
|
param2 = 20
|
||||||
|
elseif n0_is_upside_down
|
||||||
|
and p0.y+1 ~= p1.y then
|
||||||
|
-- If pointing at the side of a upside down slab
|
||||||
|
param2 = 20
|
||||||
|
end
|
||||||
|
|
||||||
|
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||||
|
end
|
||||||
|
|
||||||
|
for n,i in pairs(newdef) do
|
||||||
|
def[n] = i
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(name, def)
|
||||||
|
--[[
|
||||||
|
-- for replace ABM
|
||||||
|
minetest.register_node("snow:slab_" .. subname.."upside_down", {
|
||||||
|
replace_name = "snow:slab_"..subname,
|
||||||
|
groups = {slabs_replace=1},
|
||||||
|
})
|
||||||
|
--]]
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = name .. " 6",
|
||||||
|
recipe = {
|
||||||
|
{recipeitem, recipeitem, recipeitem},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
-- Replace old "upside_down" nodes with new param2 versions
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:slabs_replace"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
node.name = minetest.registered_nodes[node.name].replace_name
|
||||||
|
node.param2 = node.param2 + 20
|
||||||
|
if node.param2 == 21 then
|
||||||
|
node.param2 = 23
|
||||||
|
elseif node.param2 == 23 then
|
||||||
|
node.param2 = 21
|
||||||
|
end
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Snow stairs and slabs require extra definitions because of their extra
|
||||||
|
-- features (freezing, melting, and how they change dirt and dirt_with_grass). ~ LazyJ
|
||||||
|
|
||||||
|
-- Nodes will be called snow:{stair,slab}_<subname>
|
||||||
|
local function register_stair_and_slab(subname, recipeitem, def)
|
||||||
|
local recipedef = minetest.registered_nodes[recipeitem]
|
||||||
|
for _,i in pairs(recipe_values) do
|
||||||
|
if def[i] == nil
|
||||||
|
and recipedef[i] ~= nil then
|
||||||
|
def[i] = recipedef[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local groups = table.copy(def.groups)
|
||||||
|
groups.cooks_into_ice = nil
|
||||||
|
if groups.melts then
|
||||||
|
groups.melts = math.min(groups.melts+1, 3)
|
||||||
|
end
|
||||||
|
def.groups = groups
|
||||||
|
|
||||||
|
local stair_desc = def.stair_desc
|
||||||
|
def.stair_desc = nil
|
||||||
|
local slab_desc = def.slab_desc
|
||||||
|
def.slab_desc = nil
|
||||||
|
|
||||||
|
def.description = stair_desc
|
||||||
|
register_stair(subname, recipeitem, def)
|
||||||
|
|
||||||
|
def.description = slab_desc
|
||||||
|
register_slab(subname, recipeitem, def)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
list_of_snow_stuff = {
|
||||||
|
--{"row[1] = first item in row",
|
||||||
|
-- "row[2] = second item in row",
|
||||||
|
-- "row[3] = third item in row", and so on, and so on...}, ~ LazyJ
|
||||||
|
{"ice", "default:ice", "Ice Stairs", "Ice Slabs"},
|
||||||
|
{"snowblock", "default:snowblock", "Snowblock Stairs", "Snowblock Slabs"},
|
||||||
|
{"snow_cobble", "snow:snow_cobble", "Snow Cobble Stairs", "Snow Cobble Slabs"},
|
||||||
|
{"snow_brick", "snow:snow_brick", "Snow Brick Stair", "Snow Brick Slab"},
|
||||||
|
{"ice_brick", "snow:ice_brick", "Ice Brick Stair", "Ice Brick Slab"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, row in pairs(list_of_snow_stuff) do
|
||||||
|
register_stair_and_slab(row[1], row[2], {
|
||||||
|
stair_desc = row[3],
|
||||||
|
slab_desc = row[4],
|
||||||
|
})
|
||||||
|
end
|
0
src/crafting.lua
Normal file → Executable file
444
src/falling_snow.lua
Normal file → Executable file
@ -1,6 +1,184 @@
|
|||||||
-- Parameters
|
--[[
|
||||||
|
--=================
|
||||||
|
--======================================
|
||||||
|
LazyJ's Fork of Splizard's "Snow" Mod
|
||||||
|
by LazyJ
|
||||||
|
version: Umpteen and 7/5ths something or another.
|
||||||
|
2014_04_12
|
||||||
|
--======================================
|
||||||
|
--=================
|
||||||
|
|
||||||
local function snow_fall(pos)
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
THE LIST OF CHANGES I'VE MADE
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
* Falling snow would destroy nodes it deposited snow on. I figured out that if
|
||||||
|
I switched the 'snow.place' with 'minetest.place_node' and increased the
|
||||||
|
y position by 2, then the nodes were nolonger destroyed and the snow
|
||||||
|
would start to pile up.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
~~~~~~
|
||||||
|
TODO
|
||||||
|
~~~~~~
|
||||||
|
|
||||||
|
* Add code to prevent snowfall from depositing snow on or
|
||||||
|
near torches and lava.
|
||||||
|
|
||||||
|
* Add code to prevent snowfall from depositing snow on
|
||||||
|
'walkable = false' defined nodes.
|
||||||
|
|
||||||
|
both are already fixed -- Hybrid Dog
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--=============================================================
|
||||||
|
-- CODE STUFF
|
||||||
|
--=============================================================
|
||||||
|
|
||||||
|
|
||||||
|
local weather_legacy
|
||||||
|
|
||||||
|
local worldpath = minetest.get_worldpath()
|
||||||
|
local read_weather_legacy = function ()
|
||||||
|
local file = io.open(worldpath.."/weather_v6", "r")
|
||||||
|
if not file then return end
|
||||||
|
local readweather = file:read()
|
||||||
|
file:close()
|
||||||
|
return readweather
|
||||||
|
end
|
||||||
|
|
||||||
|
--Weather for legacy versions of minetest.
|
||||||
|
local save_weather_legacy = function ()
|
||||||
|
local file = io.open(worldpath.."/weather_v6", "w+")
|
||||||
|
file:write(weather_legacy)
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
weather_legacy = read_weather_legacy() or ""
|
||||||
|
|
||||||
|
local function leg_step()
|
||||||
|
if weather_legacy == "snow" then
|
||||||
|
if math.random(1000) == 1 then
|
||||||
|
weather_legacy = "none"
|
||||||
|
save_weather_legacy()
|
||||||
|
end
|
||||||
|
elseif math.random(5000) == 2 then
|
||||||
|
weather_legacy = "snow"
|
||||||
|
save_weather_legacy()
|
||||||
|
end
|
||||||
|
minetest.after(2, leg_step)
|
||||||
|
end
|
||||||
|
minetest.after(4, leg_step)
|
||||||
|
|
||||||
|
local function infolog(msg)
|
||||||
|
minetest.log("info", "[snow] falling_snow: "..msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- copied from meru mod
|
||||||
|
local SEEDDIFF3 = 9130 -- 9130 -- Values should match minetest mapgen desert perlin.
|
||||||
|
local OCTAVES3 = 3 -- 3
|
||||||
|
local PERSISTENCE3 = 0.5 -- 0.5
|
||||||
|
local SCALE3 = 250 -- 250
|
||||||
|
|
||||||
|
-- cache perlin noise tests
|
||||||
|
local perlin_scale, rarity
|
||||||
|
local cold_perl_values = {}
|
||||||
|
setmetatable(cold_perl_values, {__mode = "kv"})
|
||||||
|
local function cold_perlin_test(x, y)
|
||||||
|
if not cold_perl_values[y] then
|
||||||
|
cold_perl_values[y] = {}
|
||||||
|
setmetatable(cold_perl_values[y], {__mode = "kv"})
|
||||||
|
end
|
||||||
|
|
||||||
|
local v = cold_perl_values[y][x]
|
||||||
|
if v ~= nil then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
if not rarity then
|
||||||
|
rarity = snow.mapgen.smooth_rarity_min
|
||||||
|
perlin_scale = snow.mapgen.perlin_scale
|
||||||
|
end
|
||||||
|
|
||||||
|
v = minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=x, y=y}) >= rarity
|
||||||
|
cold_perl_values[y][x] = v
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- disable falling snow in desert
|
||||||
|
local desert_perl_values = {}
|
||||||
|
setmetatable(desert_perl_values, {__mode = "kv"})
|
||||||
|
local function is_desert(x, y)
|
||||||
|
if not desert_perl_values[y] then
|
||||||
|
desert_perl_values[y] = {}
|
||||||
|
setmetatable(desert_perl_values[y], {__mode = "kv"})
|
||||||
|
end
|
||||||
|
|
||||||
|
local v = desert_perl_values[y][x]
|
||||||
|
if v ~= nil then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Offsets must match minetest mapgen desert perlin.
|
||||||
|
-- Smooth transition 0.35 to 0.45.
|
||||||
|
v = minetest.get_perlin(SEEDDIFF3, OCTAVES3, PERSISTENCE3, SCALE3):get2d({x=x+150,y=y+50}) <= 0.35
|
||||||
|
desert_perl_values[y][x] = v
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
--Get snow at position.
|
||||||
|
local function get_snow(pos)
|
||||||
|
return weather_legacy == "snow" --Legacy support.
|
||||||
|
and cold_perlin_test(pos.x, pos.z)
|
||||||
|
and not is_desert(pos.x, pos.z)
|
||||||
|
end
|
||||||
|
|
||||||
|
local addvectors = vector.add
|
||||||
|
|
||||||
|
--Returns a random position between minp and maxp.
|
||||||
|
-- TODO: make a fload random position
|
||||||
|
local function randpos(minp, maxp)
|
||||||
|
local x,z
|
||||||
|
if minp.x > maxp.x then
|
||||||
|
x = math.random(maxp.x,minp.x)
|
||||||
|
else
|
||||||
|
x = math.random(minp.x,maxp.x)
|
||||||
|
end
|
||||||
|
if minp.z > maxp.z then
|
||||||
|
z = math.random(maxp.z,minp.z)
|
||||||
|
else
|
||||||
|
z = math.random(minp.z,maxp.z)
|
||||||
|
end
|
||||||
|
return {x=x,y=minp.y,z=z}
|
||||||
|
end
|
||||||
|
|
||||||
|
local default_snow_particle = {
|
||||||
|
amount = 3,
|
||||||
|
time = 0.5,
|
||||||
|
exptime = 5,
|
||||||
|
size = 50,
|
||||||
|
collisiondetection = false,
|
||||||
|
vertical = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function get_snow_particledef(data)
|
||||||
|
for n,i in pairs(default_snow_particle) do
|
||||||
|
data[n] = data[n] or i
|
||||||
|
end
|
||||||
|
for _,i in pairs({"vel", "acc", "exptime", "size"}) do
|
||||||
|
data["min"..i] = data[i]
|
||||||
|
data["max"..i] = data[i]
|
||||||
|
end
|
||||||
|
data.texture = "weather_snow.png^[transform"..math.random(0,7)
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
local function snow_fall(pos, player, animate)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=pos.y+10,pos.y+20,1 do
|
for y=pos.y+10,pos.y+20,1 do
|
||||||
local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name
|
local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name
|
||||||
@ -21,191 +199,99 @@ local function snow_fall(pos)
|
|||||||
|
|
||||||
pos = {x=pos.x, y=ground_y, z=pos.z}
|
pos = {x=pos.x, y=ground_y, z=pos.z}
|
||||||
|
|
||||||
|
if not get_snow(pos) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if animate then
|
||||||
|
local spos = {x=pos.x, y=ground_y+10, z=pos.z}
|
||||||
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
|
minpos = addvectors(spos, {x=-9, y=3, z=-9}),
|
||||||
|
maxpos = addvectors(spos, {x= 9, y=5, z= 9}),
|
||||||
|
vel = {x=0, y=-1, z=-1},
|
||||||
|
acc = {x=0, y=0, z=0},
|
||||||
|
playername = player:get_player_name()
|
||||||
|
}))
|
||||||
|
end
|
||||||
snow.place(pos, true)
|
snow.place(pos, true)
|
||||||
--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"}) -- LazyJ
|
--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"}) -- LazyJ
|
||||||
end
|
end
|
||||||
|
|
||||||
local YLIMIT = 1 -- Set to world's water level
|
-- Snow
|
||||||
-- Particles are timed to disappear at this y
|
local lighter_snowfall = snow.lighter_snowfall
|
||||||
-- Particles do not spawn when player's head is below this y
|
local function calc_snowfall()
|
||||||
local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
local ppos = player:getpos()
|
||||||
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
|
||||||
local FLAKES = 32 -- Snowflakes per cycle
|
|
||||||
--~ local DROPS = 128 -- Raindrops per cycle
|
|
||||||
--~ local RAINGAIN = 0.2 -- Rain sound volume
|
|
||||||
local COLLIDE = false -- Whether particles collide with nodes
|
|
||||||
local NISVAL = 39 -- Clouds RGB value at night
|
|
||||||
local DASVAL = 175 -- Clouds RGB value in daytime
|
|
||||||
|
|
||||||
local np_prec = {
|
-- Make sure player is not in a cave/house...
|
||||||
offset = 0,
|
if get_snow(ppos)
|
||||||
scale = 1,
|
and minetest.get_node_light(ppos, 0.5) == 15 then
|
||||||
spread = {x = PRECSPR, y = PRECSPR, z = PRECSPR},
|
local animate
|
||||||
seed = 813,
|
if not lighter_snowfall then
|
||||||
octaves = 1,
|
local vel = {x=0, y=-1, z=-1}
|
||||||
persist = 0,
|
local acc = {x=0, y=0, z=0}
|
||||||
lacunarity = 2.0,
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
--flags = ""
|
amount = 5,
|
||||||
}
|
minpos = addvectors(ppos, {x=-9, y=3, z=-9}),
|
||||||
|
maxpos = addvectors(ppos, {x= 9, y=5, z= 9}),
|
||||||
|
vel = vel,
|
||||||
|
acc = acc,
|
||||||
|
size = 25,
|
||||||
|
playername = player:get_player_name()
|
||||||
|
}))
|
||||||
|
|
||||||
-- These 2 must match biome heat and humidity noise parameters for a world
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
|
amount = 4,
|
||||||
|
minpos = addvectors(ppos, {x=-5, y=3.2, z=-5}),
|
||||||
|
maxpos = addvectors(ppos, {x= 5, y=1.6, z= 5}),
|
||||||
|
vel = vel,
|
||||||
|
acc = acc,
|
||||||
|
exptime = 4,
|
||||||
|
size = 25,
|
||||||
|
playername = player:get_player_name()
|
||||||
|
}))
|
||||||
|
|
||||||
local np_temp = {
|
animate = false
|
||||||
offset = 50,
|
else
|
||||||
scale = 50,
|
animate = true
|
||||||
spread = {x = 1000, y = 1000, z = 1000},
|
end
|
||||||
seed = 5349,
|
|
||||||
octaves = 3,
|
|
||||||
persist = 0.5,
|
|
||||||
lacunarity = 2.0,
|
|
||||||
--flags = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
local np_humid = {
|
if math.random(1,5) == 4 then
|
||||||
offset = 50,
|
snow_fall(
|
||||||
scale = 50,
|
randpos(
|
||||||
spread = {x = 1000, y = 1000, z = 1000},
|
addvectors(ppos, {x=-20, y=0, z=-20}),
|
||||||
seed = 842,
|
addvectors(ppos, {x= 20, y=0, z= 20})
|
||||||
octaves = 3,
|
),
|
||||||
persist = 0.5,
|
player,
|
||||||
lacunarity = 2.0,
|
animate
|
||||||
--flags = ""
|
)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-- Stuff
|
|
||||||
|
|
||||||
local difsval = DASVAL - NISVAL
|
|
||||||
local grad = 14 / 95
|
|
||||||
local yint = 1496 / 95
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Globalstep function
|
|
||||||
local timer = 0
|
|
||||||
|
|
||||||
if snow.enable_snowfall then
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
timer = timer + dtime
|
|
||||||
if timer < GSCYCLE then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
timer = 0
|
|
||||||
|
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
local pos_player = player:get_pos()
|
|
||||||
local pposy = math.floor(pos_player.y) + 2 -- Precipitation when swimming
|
|
||||||
if pposy >= YLIMIT - 2 then
|
|
||||||
local pposx = math.floor(pos_player.x)
|
|
||||||
local pposz = math.floor(pos_player.z)
|
|
||||||
local ppos = {x = pposx, y = pposy, z = pposz}
|
|
||||||
|
|
||||||
local nobj_temp = minetest.get_perlin(np_temp)
|
|
||||||
local nobj_humid = minetest.get_perlin(np_humid)
|
|
||||||
local nobj_prec = minetest.get_perlin(np_prec)
|
|
||||||
|
|
||||||
local nval_temp = nobj_temp:get_2d({x = pposx, y = pposz})
|
|
||||||
local nval_humid = nobj_humid:get_2d({x = pposx, y = pposz})
|
|
||||||
local nval_prec = nobj_prec:get_2d({x = os.clock() / 60, y = 0})
|
|
||||||
|
|
||||||
-- Biome system: Frozen biomes below heat 35,
|
|
||||||
-- deserts below line 14 * t - 95 * h = -1496
|
|
||||||
-- h = (14 * t + 1496) / 95
|
|
||||||
-- h = 14/95 * t + 1496/95
|
|
||||||
-- where 14/95 is gradient and 1496/95 is y intersection
|
|
||||||
-- h - 14/95 t = 1496/95 y intersection
|
|
||||||
-- so area above line is
|
|
||||||
-- h - 14/95 t > 1496/95
|
|
||||||
local freeze = nval_temp < 35
|
|
||||||
local precip = nval_prec < (nval_humid - 50) / 50 + PRECOFF and
|
|
||||||
nval_humid - grad * nval_temp > yint
|
|
||||||
|
|
||||||
if snow.debug then
|
|
||||||
precip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if player is outside
|
|
||||||
local outside = minetest.get_node_light(ppos, 0.5) == 15
|
|
||||||
|
|
||||||
-- Occasionally reset player sky
|
|
||||||
if math.random() < 0.1 then
|
|
||||||
if precip then
|
|
||||||
-- Set overcast sky
|
|
||||||
local sval
|
|
||||||
local time = minetest.get_timeofday()
|
|
||||||
if time >= 0.5 then
|
|
||||||
time = 1 - time
|
|
||||||
end
|
|
||||||
-- Sky brightness transitions:
|
|
||||||
-- First transition (24000 -) 4500, (1 -) 0.1875
|
|
||||||
-- Last transition (24000 -) 5750, (1 -) 0.2396
|
|
||||||
if time <= 0.1875 then
|
|
||||||
sval = NISVAL
|
|
||||||
elseif time >= 0.2396 then
|
|
||||||
sval = DASVAL
|
|
||||||
else
|
|
||||||
sval = math.floor(NISVAL +
|
|
||||||
((time - 0.1875) / 0.0521) * difsval)
|
|
||||||
end
|
|
||||||
-- Set sky to overcast bluish-grey
|
|
||||||
player:set_sky({
|
|
||||||
base_color = {r = sval, g = sval, b = sval + 16, a = 255},
|
|
||||||
type = "plain",
|
|
||||||
})
|
|
||||||
else
|
|
||||||
-- Reset sky to normal
|
|
||||||
player:set_sky({type = "regular"})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if precip and outside then
|
|
||||||
-- Precipitation
|
|
||||||
if freeze then
|
|
||||||
-- Snowfall
|
|
||||||
local extime = math.min((pposy + 12 - YLIMIT) / 2, 9)
|
|
||||||
|
|
||||||
local x, y, z = pposx - 24 + math.random(0, 48), pposy + 12, pposz - 24 + math.random(0, 48)
|
|
||||||
|
|
||||||
if not snow.lighter_snowfall then
|
|
||||||
snow_fall({
|
|
||||||
x = x,
|
|
||||||
y = y,
|
|
||||||
z = z
|
|
||||||
}, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
for _ = 1, FLAKES do
|
|
||||||
|
|
||||||
x, y, z = pposx - 24 + math.random(0, 48), pposy + 12, pposz - 24 + math.random(0, 48)
|
|
||||||
|
|
||||||
minetest.add_particle({
|
|
||||||
pos = {
|
|
||||||
x = x,
|
|
||||||
y = y,
|
|
||||||
z = z
|
|
||||||
},
|
|
||||||
velocity = {
|
|
||||||
x = (-20 + math.random(0, 40)) / 100,
|
|
||||||
y = -2.0,
|
|
||||||
z = (-20 + math.random(0, 40)) / 100
|
|
||||||
},
|
|
||||||
acceleration = {x = 0, y = 0, z = 0},
|
|
||||||
expirationtime = extime,
|
|
||||||
size = 2.8,
|
|
||||||
collisiondetection = COLLIDE,
|
|
||||||
collision_removal = true,
|
|
||||||
vertical = false,
|
|
||||||
texture = "snowdrift_snowflake" ..
|
|
||||||
math.random(1, 12) .. ".png",
|
|
||||||
playername = player_name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local step_func
|
||||||
|
minetest.register_globalstep(function()
|
||||||
|
step_func()
|
||||||
|
end)
|
||||||
|
|
||||||
|
if snow.enable_snowfall then
|
||||||
|
step_func = calc_snowfall
|
||||||
|
infolog("step function set to calc_snowfall")
|
||||||
|
else
|
||||||
|
step_func = function() end
|
||||||
|
infolog("step function set to empty function")
|
||||||
|
end
|
||||||
|
|
||||||
|
snow.register_on_configuring(function(name, v)
|
||||||
|
if name == "enable_snowfall" then
|
||||||
|
if v then
|
||||||
|
step_func = calc_snowfall
|
||||||
|
infolog("step function set to calc_snowfall")
|
||||||
|
else
|
||||||
|
step_func = function() end
|
||||||
|
infolog("step function set to empty function")
|
||||||
|
end
|
||||||
|
elseif name == "lighter_snowfall" then
|
||||||
|
lighter_snowfall = v
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
155
src/mapgen.lua
Normal file → Executable file
@ -12,65 +12,63 @@ 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 perlin_scale, nosmooth_rarity
|
|
||||||
if not snow.disable_mapgen then
|
|
||||||
print("[snow] Mapgen enabled!")
|
|
||||||
|
|
||||||
snow.mapgen = snow.mapgen or {}
|
snow.mapgen = snow.mapgen or {}
|
||||||
local mg = snow.mapgen
|
local mg = snow.mapgen
|
||||||
|
|
||||||
-- perlin noise "hills" are not peaks but looking like sinus curve
|
-- perlin noise "hills" are not peaks but looking like sinus curve
|
||||||
local function upper_rarity(rarity)
|
local function upper_rarity(rarity)
|
||||||
return math.sign(rarity)*math.sin(math.abs(rarity)*math.pi/2)
|
return math.sign(rarity)*math.sin(math.abs(rarity)*math.pi/2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local rarity = snow.mapgen_rarity
|
||||||
|
local size = snow.mapgen_size
|
||||||
|
local smooth = snow.smooth_biomes
|
||||||
|
|
||||||
|
local nosmooth_rarity, perlin_scale
|
||||||
|
local function calc_values()
|
||||||
|
nosmooth_rarity = 1-rarity/50
|
||||||
|
perlin_scale = size*100/rarity
|
||||||
|
mg.perlin_scale = perlin_scale
|
||||||
|
local smooth_rarity_max, smooth_rarity_min, smooth_rarity_dif
|
||||||
|
if smooth then
|
||||||
|
local smooth_trans_size = 4 --snow.smooth_trans_size
|
||||||
|
mg.smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
|
||||||
|
mg.smooth_rarity_min = upper_rarity(nosmooth_rarity-smooth_trans_size/perlin_scale)
|
||||||
|
mg.smooth_rarity_dif = mg.smooth_rarity_max-mg.smooth_rarity_min
|
||||||
end
|
end
|
||||||
|
nosmooth_rarity = upper_rarity(nosmooth_rarity)
|
||||||
|
mg.nosmooth_rarity = nosmooth_rarity
|
||||||
|
end
|
||||||
|
calc_values()
|
||||||
|
|
||||||
local rarity = snow.mapgen_rarity
|
snow.register_on_configuring(function(name, v)
|
||||||
local size = snow.mapgen_size
|
if name == "mapgen_rarity" then
|
||||||
local smooth = snow.smooth_biomes
|
rarity = v
|
||||||
|
elseif name == "mapgen_size" then
|
||||||
local function calc_values()
|
size = v
|
||||||
nosmooth_rarity = 1-rarity/50
|
elseif name == "smooth_biomes" then
|
||||||
perlin_scale = size*100/rarity
|
smooth = v
|
||||||
mg.perlin_scale = perlin_scale
|
|
||||||
if smooth then
|
|
||||||
local smooth_trans_size = 4 --snow.smooth_trans_size
|
|
||||||
mg.smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
|
|
||||||
mg.smooth_rarity_min = upper_rarity(nosmooth_rarity-smooth_trans_size/perlin_scale)
|
|
||||||
mg.smooth_rarity_dif = mg.smooth_rarity_max-mg.smooth_rarity_min
|
|
||||||
end
|
|
||||||
nosmooth_rarity = upper_rarity(nosmooth_rarity)
|
|
||||||
mg.nosmooth_rarity = nosmooth_rarity
|
|
||||||
end
|
|
||||||
calc_values()
|
|
||||||
|
|
||||||
snow.register_on_configuring(function(name, v)
|
|
||||||
if name == "mapgen_rarity" then
|
|
||||||
rarity = v
|
|
||||||
elseif name == "mapgen_size" then
|
|
||||||
size = v
|
|
||||||
elseif name == "smooth_biomes" then
|
|
||||||
smooth = v
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- TODO: if e.g. size and rarity get changed at once, don't calculate the values more times
|
|
||||||
calc_values()
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
--Identify the mapgen.
|
|
||||||
local mgname = minetest.get_mapgen_setting"mg_name"
|
|
||||||
if not mgname then
|
|
||||||
minetest.log("error", "[MOD] Snow Biomes: WARNING! mapgen could not be identifyed!")
|
|
||||||
end
|
|
||||||
local path = minetest.get_modpath"snow"
|
|
||||||
if mgname == "v7" then
|
|
||||||
--Load mapgen_v7 compatibility.
|
|
||||||
dofile(path.."/src/mapgen_v7.lua")
|
|
||||||
else
|
else
|
||||||
--Load mapgen_v6 compatibility.
|
return
|
||||||
dofile(path.."/src/mapgen_v6.lua")
|
|
||||||
end
|
end
|
||||||
|
-- TODO: if e.g. size and rarity get changed at once, don't calculate the values more times
|
||||||
|
calc_values()
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
--Identify the mapgen.
|
||||||
|
local mgname = minetest.get_mapgen_setting"mg_name"
|
||||||
|
if not mgname then
|
||||||
|
minetest.log("error", "[MOD] Snow Biomes: WARNING! mapgen could not be identifyed!")
|
||||||
|
end
|
||||||
|
local path = minetest.get_modpath"snow"
|
||||||
|
if mgname == "v7" then
|
||||||
|
--Load mapgen_v7 compatibility.
|
||||||
|
dofile(path.."/src/mapgen_v7.lua")
|
||||||
|
else
|
||||||
|
--Load mapgen_v6 compatibility.
|
||||||
|
dofile(path.."/src/mapgen_v6.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- To complete the commenting-out add the *closing* comment under this line.
|
-- To complete the commenting-out add the *closing* comment under this line.
|
||||||
@ -109,11 +107,11 @@ local xmas_tree = {
|
|||||||
--Makes pine tree
|
--Makes pine tree
|
||||||
function snow.make_pine(pos,snow,xmas)
|
function snow.make_pine(pos,snow,xmas)
|
||||||
local minetest = minetest
|
local minetest = minetest
|
||||||
local function try_node(p, node)
|
local try_node = function(pos, node)
|
||||||
local n = minetest.get_node(p).name
|
local n = minetest.get_node(pos).name
|
||||||
if n == "air"
|
if n == "air"
|
||||||
or n == "ignore" then
|
or n == "ignore" then
|
||||||
minetest.add_node(p, node)
|
minetest.add_node(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if xmas then
|
if xmas then
|
||||||
@ -137,7 +135,7 @@ function snow.make_pine(pos,snow,xmas)
|
|||||||
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
|
elseif snow
|
||||||
and minetest.get_perlin(112,3, 0.5, perlin_scale):get_2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
and minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=pos.x,y=pos.z}) > nosmooth_rarity 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
|
||||||
@ -149,19 +147,20 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
local c_snow = minetest.get_content_id("default:snow")
|
local c_snow = minetest.get_content_id("default:snow")
|
||||||
local c_pine_needles = minetest.get_content_id("snow:needles")
|
local c_pine_needles = minetest.get_content_id("snow:needles")
|
||||||
local c_pinetree = minetest.get_content_id("default:pinetree")
|
local c_pinetree = minetest.get_content_id("default:pinetree")
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
local perlin1 = minetest.get_perlin(112,3, 0.5, perlin_scale)
|
local perlin1 = minetest.get_perlin(112,3, 0.5, perlin_scale)
|
||||||
for off_z = -1,1 do
|
for z = -1,1 do
|
||||||
local z = pos.z + off_z
|
local z = pos.z + z
|
||||||
for off_x = -1,1 do
|
for x = -1,1 do
|
||||||
local x = pos.x + off_x
|
local x = pos.x + x
|
||||||
|
|
||||||
--Make tree.
|
--Make tree.
|
||||||
for i = 1,2 do
|
for i = 1,2 do
|
||||||
data[a:index(x,pos.y+i,z)] = c_pine_needles
|
data[a:index(x,pos.y+i,z)] = c_pine_needles
|
||||||
if x ~= 0
|
if x ~= 0
|
||||||
and z ~= 0
|
and z ~= 0
|
||||||
and perlin1:get_2d({x=x,y=z}) > nosmooth_rarity then
|
and perlin1:get2d({x=x,y=z}) > nosmooth_rarity 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
|
||||||
@ -176,16 +175,16 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
data[a:index(x-1,y,z)] = c_pine_needles
|
data[a:index(x-1,y,z)] = c_pine_needles
|
||||||
data[a:index(x,y,z+1)] = c_pine_needles
|
data[a:index(x,y,z+1)] = c_pine_needles
|
||||||
data[a:index(x,y,z-1)] = c_pine_needles
|
data[a:index(x,y,z-1)] = c_pine_needles
|
||||||
if perlin1:get_2d({x=x+1,y=z}) > nosmooth_rarity then
|
if perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||||
data[a:index(x+1,y+1,z)] = c_snow
|
data[a:index(x+1,y+1,z)] = c_snow
|
||||||
end
|
end
|
||||||
if perlin1:get_2d({x=x+1,y=z}) > nosmooth_rarity then
|
if perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then
|
||||||
data[a:index(x-1,y+1,z)] = c_snow
|
data[a:index(x-1,y+1,z)] = c_snow
|
||||||
end
|
end
|
||||||
if perlin1:get_2d({x=x,y=z+1}) > nosmooth_rarity then
|
if perlin1:get2d({x=x,y=z+1}) > nosmooth_rarity then
|
||||||
data[a:index(x,y+1,z+1)] = c_snow
|
data[a:index(x,y+1,z+1)] = c_snow
|
||||||
end
|
end
|
||||||
if perlin1:get_2d({x=x,y=z-1}) > nosmooth_rarity then
|
if perlin1:get2d({x=x,y=z-1}) > nosmooth_rarity then
|
||||||
data[a:index(x,y+1,z-1)] = c_snow
|
data[a:index(x,y+1,z-1)] = c_snow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -194,29 +193,7 @@ function snow.voxelmanip_pine(pos,a,data)
|
|||||||
end
|
end
|
||||||
data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles
|
data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles
|
||||||
data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles
|
data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles
|
||||||
if perlin1:get_2d({x=pos.x,y=pos.z}) > nosmooth_rarity then
|
if perlin1:get2d({x=pos.x,y=pos.z}) > nosmooth_rarity 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
|
||||||
|
|
||||||
-- 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
|
|
||||||
|
195
src/mapgen_v6.lua
Normal file → Executable file
@ -14,11 +14,11 @@ local np_default = {
|
|||||||
-- 2D noise for coldness
|
-- 2D noise for coldness
|
||||||
|
|
||||||
local mg = snow.mapgen
|
local mg = snow.mapgen
|
||||||
local scale_coldness = mg.perlin_scale
|
local scale = mg.perlin_scale
|
||||||
local np_cold = {
|
local np_cold = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=scale_coldness, y=scale_coldness, z=scale_coldness},
|
spread = {x=scale, y=scale, z=scale},
|
||||||
seed = 112,
|
seed = 112,
|
||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.5
|
persist = 0.5
|
||||||
@ -172,23 +172,6 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end
|
end
|
||||||
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 = {}
|
|
||||||
local nbuf_cold = {}
|
|
||||||
local nbuf_ice = {}
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
|
|
||||||
@ -211,9 +194,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local snow_tab,num = {},1
|
local snow_tab,num = {},1
|
||||||
local pines_tab,pnum = {},1
|
local pines_tab,pnum = {},1
|
||||||
|
|
||||||
get_perlins(x1 - x0 + 1)
|
local sidelen = x1 - x0 + 1
|
||||||
local nvals_default = perlin_objs.default:get_2dMap_flat({x=x0+150, y=z0+50}, nbuf_default)
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
local nvals_cold, nvals_ice, ndia
|
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
|
-- Choose biomes
|
||||||
local pr = PseudoRandom(seed+57)
|
local pr = PseudoRandom(seed+57)
|
||||||
@ -231,7 +215,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local nodes_added
|
local nodes_added
|
||||||
|
|
||||||
-- Loop through columns in chunk
|
-- Loop through columns in chunk
|
||||||
local is_smooth = smooth and not snowy
|
local smooth = smooth and not snowy
|
||||||
local write_to_map = false
|
local write_to_map = false
|
||||||
local ni = 1
|
local ni = 1
|
||||||
for z = z0, z1 do
|
for z = z0, z1 do
|
||||||
@ -239,9 +223,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local in_biome = false
|
local in_biome = false
|
||||||
local test
|
local test
|
||||||
if nvals_default[ni] < 0.35 then
|
if nvals_default[ni] < 0.35 then
|
||||||
nvals_cold = nvals_cold or perlin_objs.cold:get_2dMap_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)
|
test = math.min(nvals_cold[ni], 1)
|
||||||
if is_smooth then
|
if smooth then
|
||||||
if test >= smooth_rarity_max
|
if test >= smooth_rarity_max
|
||||||
or (
|
or (
|
||||||
test > smooth_rarity_min
|
test > smooth_rarity_min
|
||||||
@ -257,44 +243,45 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if not in_biome then
|
if not in_biome then
|
||||||
if alpine
|
if alpine
|
||||||
and test
|
and test
|
||||||
and test > (is_smooth and smooth_rarity_min or nosmooth_rarity) then
|
and test > smooth_rarity_min then
|
||||||
-- remove trees near alpine
|
-- remove trees near alpine
|
||||||
local ground_y
|
local ground_y
|
||||||
if data[area:index(x, maxp.y, z)] == c.air then
|
if data[area:index(x, maxp.y, z)] == c.air then
|
||||||
local ytop = math.min(heightmap[ni]+20, maxp.y)
|
for y = math.min(heightmap[ni]+20, maxp.y), math.max(minp.y, heightmap[ni]-5), -1 do
|
||||||
local vi = area:index(x, ytop, z)
|
if data[area:index(x, y, z)] ~= c.air then
|
||||||
for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do
|
|
||||||
if data[vi] ~= c.air then
|
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ground_y then
|
if ground_y then
|
||||||
local vi = area:index(x, ground_y, z)
|
local vi = area:index(x, ground_y, z)
|
||||||
for _ = minp.y - 16, ground_y do
|
if data[vi] == c.leaves
|
||||||
local id = data[vi]
|
or data[vi] == c.jungleleaves then
|
||||||
if id == c.leaves
|
nodes_added = true
|
||||||
or id == c.jungleleaves
|
for y = ground_y, -16, -1 do
|
||||||
or id == c.tree
|
local vi = area:index(x, y, z)
|
||||||
or id == c.apple then
|
local id = data[vi]
|
||||||
data[vi] = c.air
|
if id ~= c.air then
|
||||||
nodes_added = true
|
if id == c.leaves
|
||||||
else
|
or id == c.jungleleaves
|
||||||
break
|
or id == c.tree
|
||||||
|
or id == c.apple then
|
||||||
|
data[vi] = c.air
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
nodes_added = true
|
||||||
|
write_to_map = true
|
||||||
if not nvals_ice then
|
if not nvals_ice then
|
||||||
nvals_ice = perlin_objs.ice:get_2dMap_flat({x=x0, y=z0}, nbuf_ice)
|
nvals_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat{x=x0, y=z0}
|
||||||
|
|
||||||
nodes_added = true
|
|
||||||
write_to_map = true
|
|
||||||
end
|
end
|
||||||
local icetype = nvals_ice[ni]
|
local icetype = nvals_ice[ni]
|
||||||
local cool = icetype > 0 -- only spawns ice on edge of water
|
local cool = icetype > 0 -- only spawns ice on edge of water
|
||||||
@ -308,14 +295,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- avoid generating underground
|
-- avoid generating underground
|
||||||
if data[area:index(x, maxp.y, z)] == c.air then
|
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)
|
-- 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)
|
for y = math.min(heightmap[ni]+20, maxp.y), math.max(minp.y, heightmap[ni]-5), -1 do
|
||||||
local vi = area:index(x, ytop, z)
|
if data[area:index(x, y, z)] ~= c.air then
|
||||||
for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do
|
|
||||||
if data[vi] ~= c.air then
|
|
||||||
ground_y = y
|
ground_y = y
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -329,13 +313,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
-- generate stone ground
|
-- generate stone ground
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = ground_y, math.max(-6, minp.y-6), -1 do
|
||||||
for _ = math.max(-6, minp.y-6), ground_y do
|
local vi = area:index(x, y, z)
|
||||||
if data[vi] == c.stone then
|
if data[vi] == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.stone
|
data[vi] = c.stone
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
elseif pines
|
elseif pines
|
||||||
and pr:next(1,36) == 1 then
|
and pr:next(1,36) == 1 then
|
||||||
@ -347,8 +330,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[area:index(x, ground_y+1, z)] = c.dry_shrub
|
data[area:index(x, ground_y+1, z)] = c.dry_shrub
|
||||||
else
|
else
|
||||||
if snowy
|
if snowy
|
||||||
or test > (is_smooth and smooth_rarity_max or
|
or test > smooth_rarity_max then
|
||||||
nosmooth_rarity) then
|
|
||||||
-- more, deeper snow
|
-- more, deeper snow
|
||||||
data[node] = c.snow_block
|
data[node] = c.snow_block
|
||||||
else
|
else
|
||||||
@ -361,21 +343,26 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if not icesheet
|
if not icesheet
|
||||||
and not icecave
|
and not icecave
|
||||||
and not icehole then
|
and not icehole then
|
||||||
local y = data[node - area.ystride]
|
local nds = {
|
||||||
local ice = y ~= c.water and y ~= c.ice
|
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
|
if not ice then
|
||||||
ndia = ndia or {
|
for _,i in ipairs(nds) do
|
||||||
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]
|
|
||||||
if i ~= c.water
|
if i ~= c.water
|
||||||
and i ~= c.ice
|
and i ~= c.ice
|
||||||
and i ~= c.air
|
and i ~= c.air
|
||||||
@ -383,24 +370,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
ice = true
|
ice = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi + ndia[n]
|
|
||||||
end
|
|
||||||
|
|
||||||
if not ice
|
|
||||||
and (cool or icebergs)
|
|
||||||
and pr:next(1,4) == 1 then
|
|
||||||
|
|
||||||
local vi_ice = node + 1
|
|
||||||
for i = 1,6 do
|
|
||||||
if data[vi_ice] == c.ice then
|
|
||||||
ice = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
vi_ice = vi_ice + ndia[i]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local y = data[area:index(x, ground_y-1, z)]
|
||||||
if ice
|
if ice
|
||||||
|
or (y ~= c.water and y ~= c.ice) -- and y ~= "air") …I don't think y can be a string here ~HybridDog
|
||||||
or (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
|
||||||
@ -411,13 +385,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[node] = c.ice
|
data[node] = c.ice
|
||||||
end
|
end
|
||||||
if icecave then
|
if icecave then
|
||||||
local vi = area:index(x, ground_y-1, z)
|
for y = ground_y-1, -33, -1 do
|
||||||
for _ = math.max(minp.y-16, -33), ground_y-1 do
|
local vi = area:index(x, y, z)
|
||||||
if data[vi] ~= c.water then
|
if data[vi] ~= c.water then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.air
|
data[vi] = c.air
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if icesheet then
|
if icesheet then
|
||||||
@ -436,23 +409,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
-- replace papyrus plants with snowblocks
|
-- replace papyrus plants with snowblocks
|
||||||
local vi = area:index(x, ground_y, z)
|
local y = ground_y
|
||||||
for _ = 1,7 do
|
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
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.snow_block
|
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
elseif alpine then
|
elseif alpine then
|
||||||
-- make stone pillars out of trees and other stuff
|
-- make stone pillars out of trees and other stuff
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = ground_y, math.max(-6, minp.y-6), -1 do
|
||||||
for _ = 0, ground_y - math.max(-6, minp.y-6) do
|
local stone = area:index(x, y, z)
|
||||||
if data[vi] == c.stone then
|
if data[stone] == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
data[vi] = c.stone
|
data[stone] = c.stone
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
-- put snow onto it
|
-- put snow onto it
|
||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
@ -463,8 +437,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
snow_tab[num] = {ground_y, z, x, test}
|
snow_tab[num] = {ground_y, z, x, test}
|
||||||
num = num+1
|
num = num+1
|
||||||
end
|
end
|
||||||
local vi = area:index(x, ground_y, z)
|
for y = 0, 12 do
|
||||||
for _ = 0, 12 do
|
y = ground_y-y
|
||||||
|
local vi = area:index(x, y, z)
|
||||||
local nd = data[vi]
|
local nd = data[vi]
|
||||||
local plantlike = is_plantlike(nd)
|
local plantlike = is_plantlike(nd)
|
||||||
if replacements[nd] then
|
if replacements[nd] then
|
||||||
@ -476,7 +451,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
data[vi] = c.dirt_with_snow
|
data[vi] = c.dirt_with_snow
|
||||||
break
|
break
|
||||||
elseif plantlike then
|
elseif plantlike then
|
||||||
local under = vi - area.ystride
|
local under = area:index(x, y-1, z)
|
||||||
if data[under] == c.dirt_with_grass then
|
if data[under] == c.dirt_with_grass then
|
||||||
-- replace other plants with shrubs
|
-- replace other plants with shrubs
|
||||||
data[vi] = c.snow_shrub
|
data[vi] = c.snow_shrub
|
||||||
@ -487,7 +462,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
elseif nd == c.stone then
|
elseif nd == c.stone then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
vi = vi - area.ystride
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -501,14 +475,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- try to fix oom memory crashes
|
||||||
|
minetest.after(0, collectgarbage)
|
||||||
|
|
||||||
if num ~= 1 then
|
if num ~= 1 then
|
||||||
for i = 1, num-1 do
|
for _,i in pairs(snow_tab) do
|
||||||
i = snow_tab[i]
|
|
||||||
-- set snow
|
-- set snow
|
||||||
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
||||||
end
|
end
|
||||||
for k = 1, num-1 do
|
for _,i in pairs(snow_tab) do
|
||||||
local i = snow_tab[k]
|
|
||||||
local y,z,x,test = unpack(i)
|
local y,z,x,test = unpack(i)
|
||||||
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
||||||
if test > 0 then
|
if test > 0 then
|
||||||
@ -518,8 +493,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if h ~= 1 then
|
if h ~= 1 then
|
||||||
-- search for nearby snow
|
-- search for nearby snow
|
||||||
y = y+1
|
y = y+1
|
||||||
for off = -1,1,2 do
|
for i = -1,1,2 do
|
||||||
for _,cord in pairs({{x+off,z}, {x,z+off}}) do
|
for _,cord in pairs({{x+i,z}, {x,z+i}}) do
|
||||||
local nd = data[area:index(cord[1], y, cord[2])]
|
local nd = data[area:index(cord[1], y, cord[2])]
|
||||||
if nd == c.air
|
if nd == c.air
|
||||||
or is_plantlike(nd) then
|
or is_plantlike(nd) then
|
||||||
@ -553,8 +528,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if pines
|
if pines
|
||||||
and pnum ~= 1 then
|
and pnum ~= 1 then
|
||||||
local spawn_pine = snow.voxelmanip_pine
|
local spawn_pine = snow.voxelmanip_pine
|
||||||
for i = 1, pnum-1 do
|
for _,pos in pairs(pines_tab) do
|
||||||
spawn_pine(pines_tab[i], area, data)
|
spawn_pine(pos, area, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -579,7 +554,7 @@ local biome_strings = {
|
|||||||
{"snowy", "plain", "alpine", "normal", "normal"},
|
{"snowy", "plain", "alpine", "normal", "normal"},
|
||||||
{"cool", "icebergs", "icesheet", "icecave", "icehole"}
|
{"cool", "icebergs", "icesheet", "icecave", "icehole"}
|
||||||
}
|
}
|
||||||
function biome_to_string(num)
|
function biome_to_string(num,num2)
|
||||||
local biome = biome_strings[1][num] or "unknown "..num
|
local biome = biome_strings[1][num] or "unknown "..num
|
||||||
return biome
|
return biome
|
||||||
end
|
end
|
||||||
|
0
src/mapgen_v7.lua
Normal file → Executable file
257
src/nodes.lua
Normal file → Executable file
@ -8,16 +8,11 @@ local nodedef = {
|
|||||||
tiles = {"snow_needles.png"},
|
tiles = {"snow_needles.png"},
|
||||||
waving = 1,
|
waving = 1,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
groups = {snappy=3},
|
groups = {snappy=3, leafdecay=5},
|
||||||
furnace_burntime = 1,
|
furnace_burntime = 1,
|
||||||
drop = {
|
drop = {
|
||||||
max_items = 1,
|
max_items = 1,
|
||||||
items = {
|
items = {
|
||||||
{
|
|
||||||
-- player will get sapling with 1/20 chance
|
|
||||||
items = {'snow:sapling_pine'},
|
|
||||||
rarity = 20,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
items = {'snow:needles'},
|
items = {'snow:needles'},
|
||||||
}
|
}
|
||||||
@ -32,23 +27,17 @@ If christmas_content is enabled, then this next part will override the pine need
|
|||||||
The Xmas tree needles are registred and defined a farther down in this nodes.lua file.
|
The Xmas tree needles are registred and defined a farther down in this nodes.lua file.
|
||||||
|
|
||||||
~ LazyJ
|
~ LazyJ
|
||||||
]]
|
|
||||||
if snow.christmas_content then
|
if snow.christmas_content then
|
||||||
table.insert(nodedef.drop.items, 1, {
|
table.insert(nodedef.drop.items, 1, {
|
||||||
-- player will get xmas tree with 1/120 chance
|
-- player will get xmas tree with 1/120 chance
|
||||||
items = {"snow:xmas_tree"},
|
items = {'snow:xmas_tree'},
|
||||||
rarity = 120,
|
rarity = 120,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
minetest.register_node("snow:needles", table.copy(nodedef))
|
minetest.register_node("snow:needles", table.copy(nodedef))
|
||||||
|
|
||||||
default.register_leafdecay{
|
|
||||||
trunks = {"default:pine_tree"},
|
|
||||||
leaves = {"snow:needles"},
|
|
||||||
radius = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
snow.register_on_configuring(function(name, v)
|
snow.register_on_configuring(function(name, v)
|
||||||
if name == "christmas_content" then
|
if name == "christmas_content" then
|
||||||
local drop = minetest.registered_nodes["snow:needles"].drop
|
local drop = minetest.registered_nodes["snow:needles"].drop
|
||||||
@ -66,10 +55,10 @@ end)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Christmas egg
|
-- Christmas egg
|
||||||
if minetest.global_exists("skins") then
|
if minetest.global_exists"skins" then
|
||||||
skins.add("character_snow_man")
|
skins.add"character_snow_man"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Decorated Pine Leaves
|
-- Decorated Pine Leaves
|
||||||
@ -82,18 +71,16 @@ if snow.disable_deco_needle_ani then
|
|||||||
else
|
else
|
||||||
-- Animated, "blinking lights" version. ~ LazyJ
|
-- Animated, "blinking lights" version. ~ LazyJ
|
||||||
nodedef.inventory_image = minetest.inventorycube("snow_needles_decorated.png")
|
nodedef.inventory_image = minetest.inventorycube("snow_needles_decorated.png")
|
||||||
nodedef.tiles = {{
|
nodedef.tiles = {
|
||||||
name="snow_needles_decorated_animated.png",
|
{name="snow_needles_decorated_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=20.0}}
|
||||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16,
|
}
|
||||||
length=20.0}
|
|
||||||
}}
|
|
||||||
end
|
end
|
||||||
nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
|
nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}}
|
||||||
|
|
||||||
minetest.register_node("snow:needles_decorated", nodedef)
|
minetest.register_node("snow:needles_decorated", nodedef)
|
||||||
|
|
||||||
|
|
||||||
-- Saplings
|
--[[ Saplings
|
||||||
|
|
||||||
nodedef = {
|
nodedef = {
|
||||||
description = "Pine Sapling",
|
description = "Pine Sapling",
|
||||||
@ -119,7 +106,7 @@ nodedef.inventory_image = "snow_xmas_tree.png"
|
|||||||
nodedef.wield_image = "snow_xmas_tree.png"
|
nodedef.wield_image = "snow_xmas_tree.png"
|
||||||
|
|
||||||
minetest.register_node("snow:xmas_tree", nodedef)
|
minetest.register_node("snow:xmas_tree", nodedef)
|
||||||
|
]]
|
||||||
|
|
||||||
nodedef = {
|
nodedef = {
|
||||||
description = "Star",
|
description = "Star",
|
||||||
@ -131,15 +118,12 @@ nodedef = {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
-- Don't want the ornament breaking too easily because you have to punch it to turn it on and off. ~ LazyJ
|
-- Don't want the ornament breaking too easily because you have to punch it to turn it on and off. ~ LazyJ
|
||||||
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1},
|
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1},
|
||||||
-- Breaking "glass" sound makes it sound like a real, broken, Xmas tree
|
-- Breaking "glass" sound makes it sound like a real, broken, Xmas tree ornament (Sorry, Mom!). ;)- ~ LazyJ
|
||||||
-- ornament (Sorry, Mom!). ;)- ~ LazyJ
|
sounds = default.node_sound_glass_defaults({dig = {name="default_glass_footstep", gain=0.2}}),
|
||||||
sounds = default.node_sound_glass_defaults(
|
on_punch = function(pos, node) -- Added a "lit" star that can be punched on or off depending on your preference. ~ LazyJ
|
||||||
{dig = {name="default_glass_footstep", gain=0.2}}),
|
|
||||||
-- Added a "lit" star that can be punched on or off depending on your
|
|
||||||
-- preference. ~ LazyJ
|
|
||||||
on_punch = function(pos, node)
|
|
||||||
node.name = "snow:star_lit"
|
node.name = "snow:star_lit"
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
|
nodeupdate(pos)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,13 +132,14 @@ minetest.register_node("snow:star", table.copy(nodedef))
|
|||||||
|
|
||||||
-- Star (Lit Version) on Xmas Trees
|
-- Star (Lit Version) on Xmas Trees
|
||||||
nodedef.description = nodedef.description.." Lighted"
|
nodedef.description = nodedef.description.." Lighted"
|
||||||
nodedef.light_source = minetest.LIGHT_MAX
|
nodedef.light_source = default.LIGHT_MAX
|
||||||
nodedef.tiles = {"snow_star_lit.png"}
|
nodedef.tiles = {"snow_star_lit.png"}
|
||||||
nodedef.drop = "snow:star"
|
nodedef.drop = "snow:star"
|
||||||
nodedef.groups.not_in_creative_inventory = 1
|
nodedef.groups.not_in_creative_inventory = 1
|
||||||
nodedef.on_punch = function(pos, node)
|
nodedef.on_punch = function(pos, node)
|
||||||
node.name = "snow:star"
|
node.name = "snow:star"
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("snow:star_lit", nodedef)
|
minetest.register_node("snow:star_lit", nodedef)
|
||||||
@ -272,15 +257,6 @@ nodedef.groups.flammable = 1
|
|||||||
minetest.register_node("snow:apple", nodedef)
|
minetest.register_node("snow:apple", nodedef)
|
||||||
snow.known_plants[minetest.get_content_id("default:apple")] = minetest.get_content_id("snow:apple")
|
snow.known_plants[minetest.get_content_id("default:apple")] = minetest.get_content_id("snow:apple")
|
||||||
|
|
||||||
if not snow.disable_mapgen then
|
|
||||||
-- decay from default/nodes.lua:2537
|
|
||||||
default.register_leafdecay{
|
|
||||||
trunks = {"default:tree"},
|
|
||||||
leaves = {"snow:apple", "snow:leaves"},
|
|
||||||
radius = minetest.get_mapgen_setting"mg_name" == "v6" and 2 or 3,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
snow.known_plants[minetest.get_content_id("default:jungleleaves")] = minetest.get_content_id("default:jungleleaves")
|
snow.known_plants[minetest.get_content_id("default:jungleleaves")] = minetest.get_content_id("default:jungleleaves")
|
||||||
|
|
||||||
@ -291,7 +267,8 @@ local function snow_onto_dirt(pos)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "default:dirt_with_grass"
|
if node.name == "default:dirt_with_grass"
|
||||||
or node.name == "default:dirt" then
|
or node.name == "default:dirt" then
|
||||||
minetest.set_node(pos, {name = "default:dirt_with_snow"})
|
node.name = "default:dirt_with_snow"
|
||||||
|
minetest.set_node(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -311,27 +288,33 @@ nodedef = {
|
|||||||
-- by player position. ~ LazyJ
|
-- by player position. ~ LazyJ
|
||||||
-- I made this a little harder to dig than snow blocks because
|
-- I made this a little harder to dig than snow blocks because
|
||||||
-- I imagine snow brick as being much more dense and solid than fluffy snow. ~ LazyJ
|
-- I imagine snow brick as being much more dense and solid than fluffy snow. ~ LazyJ
|
||||||
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1,
|
groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1, icemaker=1, cooks_into_ice=1},
|
||||||
icemaker=1, cooks_into_ice=1, cools_lava = 1, snowy = 1},
|
|
||||||
--Let's use the new snow sounds instead of the old grass sounds. ~ LazyJ
|
--Let's use the new snow sounds instead of the old grass sounds. ~ LazyJ
|
||||||
sounds = default.node_sound_snow_defaults(),
|
sounds = default.node_sound_dirt_defaults({
|
||||||
-- The "on_construct" part below, thinking in terms of layers,
|
footstep = {name="default_snow_footstep", gain=0.25},
|
||||||
-- dirt_with_snow could also double as dirt_with_frost which adds subtlety
|
dig = {name="default_dig_crumbly", gain=0.4},
|
||||||
-- to the winterscape. ~ LazyJ
|
dug = {name="default_snow_footstep", gain=0.75},
|
||||||
|
place = {name="default_place_node", gain=1.0}
|
||||||
|
}),
|
||||||
|
-- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could also
|
||||||
|
-- double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
|
||||||
on_construct = snow_onto_dirt
|
on_construct = snow_onto_dirt
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Snow Brick
|
-- Snow Brick
|
||||||
minetest.register_node("snow:snow_brick", table.copy(nodedef))
|
minetest.register_node("snow:snow_brick", table.copy(nodedef))
|
||||||
|
|
||||||
|
|
||||||
-- hard Ice Brick, original texture from LazyJ
|
-- hard Ice Brick, original texture from LazyJ
|
||||||
local ibdef = table.copy(nodedef)
|
local ibdef = table.copy(nodedef)
|
||||||
ibdef.description = "Ice Brick"
|
ibdef.description = "Ice Brick"
|
||||||
ibdef.tiles = {"snow_ice_brick.png"}
|
ibdef.tiles = {"snow_ice_brick.png"}
|
||||||
ibdef.use_texture_alpha = "blend"
|
ibdef.use_texture_alpha = true
|
||||||
ibdef.drawtype = "glasslike"
|
ibdef.drawtype = "glasslike"
|
||||||
ibdef.groups = {cracky=1, crumbly=1, choppy=1, melts=1, cools_lava = 1, slippery = 3}
|
ibdef.groups = {cracky=1, crumbly=1, choppy=1, melts=1}
|
||||||
ibdef.sounds = default.node_sound_ice_defaults()
|
ibdef.sounds = default.node_sound_glass_defaults({
|
||||||
|
dug = {name="default_hard_footstep", gain=1}
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("snow:ice_brick", ibdef)
|
minetest.register_node("snow:ice_brick", ibdef)
|
||||||
|
|
||||||
@ -343,159 +326,43 @@ nodedef.tiles = {"snow_snow_cobble.png"}
|
|||||||
|
|
||||||
minetest.register_node("snow:snow_cobble", nodedef)
|
minetest.register_node("snow:snow_cobble", nodedef)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Override Default Nodes to Add Extra Functions
|
-- Override Default Nodes to Add Extra Functions
|
||||||
|
|
||||||
local groups = minetest.registered_nodes["default:ice"].groups
|
-- This adds code to the existing default ice. ~ LazyJ
|
||||||
groups["melt"] = 1
|
|
||||||
minetest.override_item("default:ice", {
|
minetest.override_item("default:ice", {
|
||||||
|
-- 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",
|
drawtype = "glasslike",
|
||||||
use_texture_alpha = "blend",
|
inventory_image = minetest.inventorycube("default_ice.png").."^[brighten",
|
||||||
param2 = 0, --param2 is reserved for how much ice will freezeover.
|
|
||||||
sunlight_propagates = true, -- necessary for dirt_with_grass/snow/just dirt ABMs
|
|
||||||
tiles = {"snow_ice.png^[brighten"},
|
|
||||||
liquidtype = "none",
|
liquidtype = "none",
|
||||||
groups = groups,
|
-- I made this a lot harder to dig than snow blocks because ice is much more dense
|
||||||
|
-- and solid than fluffy snow. ~ LazyJ
|
||||||
|
groups = {cracky=2, crumbly=1, choppy=1, --[[oddly_breakable_by_hand=1,]] melts=1},
|
||||||
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)
|
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
|
||||||
})
|
})
|
||||||
|
|
||||||
groups = minetest.registered_nodes["default:snowblock"].groups
|
|
||||||
for g,v in pairs({melts=1, icemaker=1, cooks_into_ice=1, falling_node=1}) do
|
|
||||||
groups[g] = v
|
-- This adds code to the existing, default snowblock. ~ LazyJ
|
||||||
end
|
|
||||||
minetest.override_item("default:snowblock", {
|
minetest.override_item("default:snowblock", {
|
||||||
liquidtype = "none",
|
liquidtype = "none", -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
paramtype = "light",
|
paramtype = "light", -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true, -- LazyJ to make dirt below change to dirt_with_snow (see default, nodes.lua, dirt ABM)
|
||||||
on_construct = snow_onto_dirt,
|
-- Snow blocks should be easy to dig because they are just fluffy snow. ~ LazyJ
|
||||||
groups = groups,
|
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=1, icemaker=1, cooks_into_ice=1, falling_node=1},
|
||||||
})
|
--drop = "snow:snow_cobble",
|
||||||
|
on_construct = snow_onto_dirt
|
||||||
minetest.override_item("default:snow", {
|
-- Thinking in terms of layers, dirt_with_snow could also double as
|
||||||
drop = {
|
-- dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ, 2014_04_04
|
||||||
max_items = 2,
|
|
||||||
items = {
|
|
||||||
{items = {'snow:moss'}, rarity = 20,},
|
|
||||||
{items = {'default:snow'},}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
leveled = 7,
|
|
||||||
paramtype2 = "leveled",
|
|
||||||
node_box = {
|
|
||||||
type = "leveled",
|
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
|
||||||
},
|
|
||||||
collision_box = {
|
|
||||||
type = "leveled",
|
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
|
||||||
},
|
|
||||||
selection_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, player, pt)
|
|
||||||
local oldnode_under = minetest.get_node_or_nil(pt.under)
|
|
||||||
if not oldnode_under then
|
|
||||||
return itemstack, false
|
|
||||||
end
|
|
||||||
|
|
||||||
local olddef_under = minetest.registered_nodes[oldnode_under.name]
|
|
||||||
if not olddef_under then
|
|
||||||
return itemstack, false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If node under is buildable_to, place into it instead (eg. snow)
|
|
||||||
local pos, node
|
|
||||||
if olddef_under.buildable_to then
|
|
||||||
pos = pt.under
|
|
||||||
node = oldnode_under
|
|
||||||
else
|
|
||||||
pos = pt.above
|
|
||||||
node = minetest.get_node(pos)
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
|
||||||
if not def
|
|
||||||
or not def.buildable_to then
|
|
||||||
return itemstack, false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- nil player can place (for snowballs)
|
|
||||||
if player
|
|
||||||
and minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return itemstack, false
|
|
||||||
end
|
|
||||||
|
|
||||||
if node.name ~= "default:snow" then
|
|
||||||
if minetest.get_node{x=pos.x, y=pos.y-1, z=pos.z}.name ==
|
|
||||||
"default:snow" then
|
|
||||||
-- grow the snow below (fixes levelled problem)
|
|
||||||
pos.y = pos.y - 1
|
|
||||||
else
|
|
||||||
-- place a snow
|
|
||||||
return minetest.item_place_node(itemstack, player, pt)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- grow the snow
|
|
||||||
local level = minetest.get_node_level(pos)
|
|
||||||
level = level + 7
|
|
||||||
if level < 64 then
|
|
||||||
minetest.set_node_level(pos, level)
|
|
||||||
else
|
|
||||||
-- place a snowblock and snow onto it if possible
|
|
||||||
local p = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
||||||
local def = minetest.registered_nodes[minetest.get_node(p).name]
|
|
||||||
if not def
|
|
||||||
or not def.buildable_to then
|
|
||||||
return itemstack, false
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.set_node(pos, {name="default:snowblock"})
|
|
||||||
minetest.set_node(p, {name="default:snow"})
|
|
||||||
level = math.max(level - 64, 7)
|
|
||||||
minetest.set_node_level(p, level)
|
|
||||||
end
|
|
||||||
|
|
||||||
itemstack:take_item()
|
|
||||||
return itemstack, true
|
|
||||||
end,
|
|
||||||
on_use = snow.shoot_snowball
|
|
||||||
})
|
})
|
||||||
|
16
src/sled.lua
Normal file → Executable file
@ -53,6 +53,8 @@ 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)
|
local function table_find(t, v)
|
||||||
for i = 1,#t do
|
for i = 1,#t do
|
||||||
if t[i] == v then
|
if t[i] == v then
|
||||||
@ -81,7 +83,7 @@ local sled = {
|
|||||||
|
|
||||||
local players_sled = {}
|
local players_sled = {}
|
||||||
local function join_sled(self, player)
|
local function join_sled(self, player)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:getpos()
|
||||||
player:setpos(pos)
|
player:setpos(pos)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
players_sled[name] = true
|
players_sled[name] = true
|
||||||
@ -89,7 +91,7 @@ local function join_sled(self, player)
|
|||||||
default.player_set_animation(player, "sit" , 30)
|
default.player_set_animation(player, "sit" , 30)
|
||||||
self.driver = name
|
self.driver = name
|
||||||
self.object:set_attach(player, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
|
self.object:set_attach(player, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
|
||||||
self.object:set_yaw(player:get_look_yaw())-- - math.pi/2)
|
self.object:setyaw(player:get_look_yaw())-- - math.pi/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function leave_sled(self, player)
|
local function leave_sled(self, player)
|
||||||
@ -127,7 +129,7 @@ local function sled_rightclick(self, player)
|
|||||||
position = {x=0.5, y=0.89},
|
position = {x=0.5, y=0.89},
|
||||||
name = "sled",
|
name = "sled",
|
||||||
scale = {x=2, y=2},
|
scale = {x=2, y=2},
|
||||||
text = "You are on the sled! Hold the sneak key to get off the sled.", -- LazyJ
|
text = "You are on the sled! Press the sneak key to get off the sled.", -- LazyJ
|
||||||
direction = 0,
|
direction = 0,
|
||||||
})
|
})
|
||||||
-- End part 1
|
-- End part 1
|
||||||
@ -154,9 +156,9 @@ function sled:on_rightclick(player)
|
|||||||
on_sled_click(self, player)
|
on_sled_click(self, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sled:on_activate(staticdata)
|
function sled:on_activate(staticdata, dtime_s)
|
||||||
self.object:set_armor_groups({immortal=1})
|
self.object:set_armor_groups({immortal=1})
|
||||||
self.object:set_acceleration({x=0, y=-10, z=0})
|
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
|
||||||
@ -200,7 +202,7 @@ function sled:on_step(dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if player:get_player_control().sneak
|
if player:get_player_control().sneak
|
||||||
or not accelerating_possible(vector.round(self.object:get_pos())) then
|
or not accelerating_possible(vector.round(self.object:getpos())) then
|
||||||
leave_sled(self, player)
|
leave_sled(self, player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -220,7 +222,7 @@ minetest.register_craftitem("snow:sled", {
|
|||||||
if players_sled[placer:get_player_name()] then
|
if players_sled[placer:get_player_name()] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pos = placer:get_pos()
|
local pos = placer:getpos()
|
||||||
if accelerating_possible(vector.round(pos)) then
|
if accelerating_possible(vector.round(pos)) then
|
||||||
pos.y = pos.y+0.5
|
pos.y = pos.y+0.5
|
||||||
|
|
||||||
|
195
src/snowball.lua
Normal file → Executable file
@ -6,13 +6,13 @@
|
|||||||
-- 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 creative_mode = minetest.settings:get_bool"creative_mode"
|
local creative_mode = minetest.setting_getbool("creative_mode")
|
||||||
|
|
||||||
|
|
||||||
local snowball_velocity, entity_attack_delay
|
local snowball_velocity, entity_attack_delay
|
||||||
local function update_snowball_vel(v)
|
local function update_snowball_vel(v)
|
||||||
snowball_velocity = 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
|
entity_attack_delay = (walkspeed+1)/v
|
||||||
end
|
end
|
||||||
update_snowball_vel(snow.snowball_velocity)
|
update_snowball_vel(snow.snowball_velocity)
|
||||||
@ -27,23 +27,23 @@ snow.register_on_configuring(function(name, v)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function get_gravity()
|
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
|
return grav*snowball_gravity
|
||||||
end
|
end
|
||||||
|
|
||||||
local someone_throwing, just_acitvated
|
local someone_throwing, just_acitvated
|
||||||
|
|
||||||
--Shoot snowball
|
--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 addp = {y = 1.625} -- + (math.random()-0.5)/5}
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x)
|
||||||
addp.x = dir.z/dif -- + (math.random()-0.5)/5
|
addp.x = dir.z/dif -- + (math.random()-0.5)/5
|
||||||
addp.z = -dir.x/dif -- + (math.random()-0.5)/5
|
addp.z = -dir.x/dif -- + (math.random()-0.5)/5
|
||||||
local pos = vector.add(player:get_pos(), addp)
|
local pos = vector.add(player:getpos(), addp)
|
||||||
local obj = minetest.add_entity(pos, "snow:snowball_entity")
|
local obj = minetest.add_entity(pos, "snow:snowball_entity")
|
||||||
obj:set_velocity(vector.multiply(dir, snowball_velocity))
|
obj:setvelocity(vector.multiply(dir, snowball_velocity))
|
||||||
obj:set_acceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3})
|
obj:setacceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3})
|
||||||
obj:get_luaentity().thrower = player:get_player_name()
|
obj:get_luaentity().thrower = player:get_player_name()
|
||||||
if creative_mode then
|
if creative_mode then
|
||||||
if not someone_throwing then
|
if not someone_throwing then
|
||||||
@ -64,7 +64,7 @@ if creative_mode then
|
|||||||
local item = player:get_wielded_item()
|
local item = player:get_wielded_item()
|
||||||
local itemname = item:get_name()
|
local itemname = item:get_name()
|
||||||
if itemname == "default:snow" then
|
if itemname == "default:snow" then
|
||||||
snow.shoot_snowball(nil, player)
|
snow_shoot_snowball(nil, player)
|
||||||
active = true
|
active = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -103,25 +103,25 @@ local snow_snowball_ENTITY = {
|
|||||||
|
|
||||||
function snow_snowball_ENTITY.on_activate(self)
|
function snow_snowball_ENTITY.on_activate(self)
|
||||||
self.object:set_properties({textures = {"default_snowball.png^[transform"..math.random(0,7)}})
|
self.object:set_properties({textures = {"default_snowball.png^[transform"..math.random(0,7)}})
|
||||||
self.object:set_acceleration({x=0, y=-get_gravity(), z=0})
|
self.object:setacceleration({x=0, y=-get_gravity(), z=0})
|
||||||
self.lastpos = self.object:get_pos()
|
self.lastpos = self.object:getpos()
|
||||||
minetest.after(0.1, function(obj)
|
minetest.after(0.1, function(obj)
|
||||||
if not obj then
|
if not obj then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local vel = obj:get_velocity()
|
local vel = obj:getvelocity()
|
||||||
if vel
|
if vel
|
||||||
and vel.y ~= 0 then
|
and vel.y ~= 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.after(0, function(object)
|
minetest.after(0, function(obj)
|
||||||
if not object then
|
if not obj then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local vel_obj = object:get_velocity()
|
local vel = obj:getvelocity()
|
||||||
if not vel_obj
|
if not vel
|
||||||
or vel_obj.y == 0 then
|
or vel.y == 0 then
|
||||||
object:remove()
|
obj:remove()
|
||||||
end
|
end
|
||||||
end, obj)
|
end, obj)
|
||||||
end, self.object)
|
end, self.object)
|
||||||
@ -129,40 +129,22 @@ end
|
|||||||
|
|
||||||
--Snowball_entity.on_step()--> called when snowball is moving.
|
--Snowball_entity.on_step()--> called when snowball is moving.
|
||||||
function snow_snowball_ENTITY.on_step(self, dtime)
|
function snow_snowball_ENTITY.on_step(self, dtime)
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer+dtime
|
||||||
if self.timer > 10 then
|
if self.timer > 600 then
|
||||||
-- 10 seconds is too long for a snowball to fly somewhere
|
-- 10 minutes are too long for a snowball to fly somewhere
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.physical then
|
if self.physical then
|
||||||
local vel = self.object:get_velocity()
|
local fell = self.object:getvelocity().y == 0
|
||||||
local fell = vel.y == 0
|
|
||||||
if not fell then
|
if not fell then
|
||||||
if self.probably_stuck then
|
|
||||||
self.probably_stuck = nil
|
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self.probably_stuck
|
local pos = vector.round(self.object:getpos())
|
||||||
and vel.x == 0
|
|
||||||
and vel.z == 0 then
|
|
||||||
-- add a small velocity to move it from the corner
|
|
||||||
vel.x = math.random() - 0.5
|
|
||||||
vel.z = math.random() - 0.5
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
self.probably_stuck = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local pos = vector.round(self.object:get_pos())
|
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
if vel.x == 0
|
|
||||||
and vel.z == 0 then
|
|
||||||
self.probably_stuck = true
|
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -171,16 +153,16 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = vector.round(self.object:get_pos())
|
local pos = vector.round(self.object:getpos())
|
||||||
if vector.equals(pos, self.lastpos) then
|
if vector.equals(pos, self.lastpos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node(pos).name ~= "air" then
|
if minetest.get_node(pos).name ~= "air" then
|
||||||
self.object:set_acceleration({x=0, y=-get_gravity(), z=0})
|
self.object:setacceleration({x=0, y=-get_gravity(), z=0})
|
||||||
--self.object:set_velocity({x=0, y=0, z=0})
|
--self.object:setvelocity({x=0, y=0, z=0})
|
||||||
pos = self.lastpos
|
pos = self.lastpos
|
||||||
self.object:setpos(pos)
|
self.object:setpos(pos)
|
||||||
minetest.sound_play("default_snow_footstep", {pos=pos, gain=vector.length(self.object:get_velocity())/30})
|
minetest.sound_play("default_snow_footstep", {pos=pos, gain=vector.length(self.object:getvelocity())/30})
|
||||||
self.object:set_properties({physical = true})
|
self.object:set_properties({physical = true})
|
||||||
self.physical = true
|
self.physical = true
|
||||||
return
|
return
|
||||||
@ -191,16 +173,13 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
||||||
local entity = v:get_luaentity()
|
if v ~= self.object then
|
||||||
if v ~= self.object
|
local entity_name = v:get_entity_name()
|
||||||
and entity then
|
if entity_name ~= "snow:snowball_entity"
|
||||||
local entity_name = entity.name
|
|
||||||
if v:is_player()
|
|
||||||
or (entity_name ~= "snow:snowball_entity"
|
|
||||||
and entity_name ~= "__builtin:item"
|
and entity_name ~= "__builtin:item"
|
||||||
and entity_name ~= "gauges:hp_bar") then
|
and entity_name ~= "gauges:hp_bar" then
|
||||||
local vvel = v:get_velocity() or v:get_player_velocity()
|
local vvel = v:getvelocity() or v:get_player_velocity()
|
||||||
local veldif = self.object:get_velocity()
|
local veldif = self.object:getvelocity()
|
||||||
if vvel then
|
if vvel then
|
||||||
veldif = vector.subtract(veldif, vvel)
|
veldif = vector.subtract(veldif, vvel)
|
||||||
end
|
end
|
||||||
@ -212,15 +191,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||||||
{full_punch_interval=1, damage_groups = {fleshy=math.ceil(gain)}}
|
{full_punch_interval=1, damage_groups = {fleshy=math.ceil(gain)}}
|
||||||
)
|
)
|
||||||
minetest.sound_play("default_snow_footstep", {pos=pos, gain=gain})
|
minetest.sound_play("default_snow_footstep", {pos=pos, gain=gain})
|
||||||
|
spawn_falling_node(pos, {name = "default:snow"})
|
||||||
-- spawn_falling_node
|
|
||||||
local obj = minetest.add_entity(pos, "__builtin:falling_node")
|
|
||||||
if obj then
|
|
||||||
obj:get_luaentity():set_node{name = "default:snow"}
|
|
||||||
else
|
|
||||||
minetest.log("error", "Couldn't spawn falling node")
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -265,16 +236,11 @@ minetest.register_node(":default:snow", {
|
|||||||
dug = {name="default_snow_footstep", gain=0.75},
|
dug = {name="default_snow_footstep", gain=0.75},
|
||||||
}),
|
}),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt_with_grass" or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then
|
||||||
== "default:dirt_with_grass"
|
|
||||||
or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then
|
|
||||||
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
|
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"})
|
||||||
end
|
end
|
||||||
-- Now, let's turn the snow pile into a snowblock. ~ LazyJ
|
-- Now, let's turn the snow pile into a snowblock. ~ LazyJ
|
||||||
if minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name == "default:snow"
|
if minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name == "default:snow" and -- Minus 2 because at the end of this, the layer that triggers the change to a snowblock is the second layer more than a full block, starting into a second block (-2) ~ LazyJ, 2014_04_11
|
||||||
and -- Minus 2 because at the end of this, the layer that triggers
|
|
||||||
--the change to a snowblock is the second layer more than a full block,
|
|
||||||
--starting into a second block (-2) ~ LazyJ, 2014_04_11
|
|
||||||
minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" then
|
minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" then
|
||||||
minetest.set_node({x=pos.x, y=pos.y-2, z=pos.z}, {name="default:snowblock"})
|
minetest.set_node({x=pos.x, y=pos.y-2, z=pos.z}, {name="default:snowblock"})
|
||||||
end
|
end
|
||||||
@ -285,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.
|
A note about default torches, melting, and "buildable_to = true" in default snow.
|
||||||
|
|
||||||
|
101
src/stairs.lua
@ -1,101 +0,0 @@
|
|||||||
local snow_nodes = {
|
|
||||||
snow = { "ice_brick", "snow_brick", "snow_cobble" },
|
|
||||||
default = { "ice", "snowblock" }
|
|
||||||
}
|
|
||||||
|
|
||||||
if minetest.get_modpath("moreblocks") and
|
|
||||||
minetest.global_exists("stairsplus") then
|
|
||||||
|
|
||||||
-- For users converting from MTG stairs to stairsplus, these nodes are aliased
|
|
||||||
-- from the stairs namespace to their source mod.
|
|
||||||
local was_in_stairs = {
|
|
||||||
ice_brick = true,
|
|
||||||
snow_brick = true,
|
|
||||||
snow_cobble = true,
|
|
||||||
ice = false, -- moreblocks will take care of this one, and
|
|
||||||
snowblock = false, -- this one, because they are in the default namespace.
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Some nodes were incorrectly placed into the snow namespace. Alias these to
|
|
||||||
-- their proper namespace (default).
|
|
||||||
local was_in_snow = {
|
|
||||||
ice_brick = false,
|
|
||||||
snow_brick = false,
|
|
||||||
snow_cobble = false,
|
|
||||||
ice = true,
|
|
||||||
snowblock = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Some nodes were incorrectly placed into the moreblocks namespace. Alias
|
|
||||||
-- these to their proper namespace (either snow or default).
|
|
||||||
local was_in_moreblocks = {
|
|
||||||
ice_brick = false,
|
|
||||||
snow_brick = true,
|
|
||||||
snow_cobble = true,
|
|
||||||
ice = true,
|
|
||||||
snowblock = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
for mod, nodes in pairs(snow_nodes) do
|
|
||||||
for _, name in pairs(nodes) do
|
|
||||||
local nodename = mod .. ":" .. name
|
|
||||||
local ndef = table.copy(minetest.registered_nodes[nodename])
|
|
||||||
ndef.sunlight_propagates = true
|
|
||||||
ndef.groups.melts = 2
|
|
||||||
ndef.groups.icemaker = nil
|
|
||||||
ndef.groups.cooks_into_ice = nil
|
|
||||||
ndef.after_place_node = nil
|
|
||||||
if string.find(name, "ice") then
|
|
||||||
ndef.use_texture_alpha = "blend"
|
|
||||||
else
|
|
||||||
ndef.use_texture_alpha = "opaque"
|
|
||||||
end
|
|
||||||
stairsplus:register_all(mod, name, nodename, ndef)
|
|
||||||
|
|
||||||
if was_in_stairs[name] then
|
|
||||||
minetest.register_alias("stairs:stair_" .. name, mod .. ":stair_" .. name)
|
|
||||||
minetest.register_alias("stairs:slab_" .. name, mod .. ":slab_" .. name)
|
|
||||||
end
|
|
||||||
|
|
||||||
if was_in_snow[name] then
|
|
||||||
minetest.register_alias("snow:stair_" .. name, mod .. ":stair_" .. name)
|
|
||||||
minetest.register_alias("snow:slab_" .. name, mod .. ":slab_" .. name)
|
|
||||||
end
|
|
||||||
|
|
||||||
if was_in_moreblocks[name] then
|
|
||||||
stairsplus:register_alias_all("moreblocks", name, mod, name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif minetest.global_exists("stairs") then -- simple stairs and slabs only
|
|
||||||
for mod, nodes in pairs(snow_nodes) do
|
|
||||||
for _, name in pairs(nodes) do
|
|
||||||
local nodename = mod .. ":" .. name
|
|
||||||
local ndef = table.copy(minetest.registered_nodes[nodename])
|
|
||||||
|
|
||||||
local desc_stair = ndef.description .. " Stair"
|
|
||||||
local desc_slab = ndef.description .. " Slab"
|
|
||||||
local images = ndef.tiles
|
|
||||||
local sounds = ndef.sounds
|
|
||||||
|
|
||||||
local groups = ndef.groups
|
|
||||||
groups.melts = 2
|
|
||||||
groups.icemaker = nil
|
|
||||||
groups.cooks_into_ice = nil
|
|
||||||
|
|
||||||
stairs.register_stair_and_slab(name, nodename,
|
|
||||||
groups, images, desc_stair, desc_slab, sounds)
|
|
||||||
|
|
||||||
-- Add transparency if used (e.g. ice and ice_brick).
|
|
||||||
minetest.override_item("stairs:stair_" .. name,
|
|
||||||
{use_texture_alpha = ndef.use_texture_alpha})
|
|
||||||
minetest.override_item("stairs:slab_" .. name,
|
|
||||||
{use_texture_alpha = ndef.use_texture_alpha})
|
|
||||||
|
|
||||||
-- Alias all stairs and slabs from snow to the stairs namespace.
|
|
||||||
minetest.register_alias("snow:stair_" .. name, "stairs:stair_" .. name)
|
|
||||||
minetest.register_alias("snow:slab_" .. name, "stairs:slab_" .. name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
342
src/stairsplus.lua
Executable file
@ -0,0 +1,342 @@
|
|||||||
|
-- ===============================================================================
|
||||||
|
-- StairsPlus Bonus!
|
||||||
|
-- ===============================================================================
|
||||||
|
--[[
|
||||||
|
This section of code that makes blocks compatible with MoreBlocks' circular saw.
|
||||||
|
I've added circular saw compatible code for default snowblocks and ice. :D
|
||||||
|
A big thanks to Calinou and ShadowNinja for making this possible.
|
||||||
|
|
||||||
|
Because StairsPlus creates partial blocks, it didn't seem quite right that the
|
||||||
|
smallest microblocks would produce a full-sized water_source node when melted.
|
||||||
|
So I toned them down a bit by changing their melt to a temporary,
|
||||||
|
2-second water_source. See "melts" in abms.lua file for the various intensities.
|
||||||
|
|
||||||
|
___...::: ATTENTION MINETEST SERVER OPERATORS :::...___
|
||||||
|
You may or may not have noticed in your server logs that MoreBlocks stairs/slabs/
|
||||||
|
panels/microblocks are not recorded as to when, who, what, and where. This is
|
||||||
|
important information when trying to determine if a player who dug these blocks
|
||||||
|
is the owner (the player who placed the block) or is a griefer stealing the block.
|
||||||
|
|
||||||
|
There is an option that will log when these blocks are placed but it comes at the
|
||||||
|
cost of losing the auto-rotation of those blocks when placed. They can still be
|
||||||
|
rotated with a screwdriver but if screwdrivers are disabled on your server your
|
||||||
|
players won't be able to position MoreBlocks, saw-made blocks.
|
||||||
|
|
||||||
|
To enable logging the placement of these blocks, un-comment these lines:
|
||||||
|
|
||||||
|
--on_place = minetest.item_place
|
||||||
|
|
||||||
|
There is one in each of the "stairsplus.register_all" sections.
|
||||||
|
|
||||||
|
~ LazyJ
|
||||||
|
-- ===============================================================================
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--snow_stairsplus = {}
|
||||||
|
|
||||||
|
-- Check for infinite stacks
|
||||||
|
|
||||||
|
--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
|
||||||
|
--end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
--stairsplus.register_stair_slab_panel_micro(modname, subname, recipeitem, fields)
|
||||||
|
stairsplus:register_stair(modname, subname, recipeitem, fields)
|
||||||
|
stairsplus:register_slab(modname, subname, recipeitem, fields)
|
||||||
|
stairsplus:register_panel(modname, subname, recipeitem, fields)
|
||||||
|
stairsplus:register_micro(modname, subname, recipeitem, fields)
|
||||||
|
end
|
||||||
|
Leave commented out
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Leave commented out. Another, possible piece of the puzzle, as to why the placement of
|
||||||
|
-- stairsplus nodes aren't recorded in the logs. Shelved till I can concentrate on it again.
|
||||||
|
-- ~ LazyJ
|
||||||
|
|
||||||
|
--ItemStack({name=nodename}):get_definition()
|
||||||
|
--itemstack ={}
|
||||||
|
--[[
|
||||||
|
local def = itemstack:get_definition()
|
||||||
|
function minetest.item_place_node(itemstack, placer, pointed_thing, param2)
|
||||||
|
minetest.log("action", placer:get_player_name() .. " places node "
|
||||||
|
.. def.name .. " at " .. minetest.pos_to_string(place_to))
|
||||||
|
end
|
||||||
|
Leave commented out
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
-- Leave commented out
|
||||||
|
--[[ FIGURE OUT HOW TO GET THE SLABS TO SHOW UP IN THE LOG ON PLACEMENT
|
||||||
|
|
||||||
|
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if pointed_thing.type ~= "node" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If it's being placed on an another similar one, replace it with
|
||||||
|
-- a full block
|
||||||
|
local slabpos = nil
|
||||||
|
local slabnode = nil
|
||||||
|
local p0 = pointed_thing.under
|
||||||
|
local p1 = pointed_thing.above
|
||||||
|
local n0 = minetest.get_node(p0)
|
||||||
|
local n1 = minetest.get_node(p1)
|
||||||
|
local param2 = 0
|
||||||
|
|
||||||
|
local n0_is_upside_down = (n0.name == "snow:slab_" .. subname and
|
||||||
|
n0.param2 >= 20)
|
||||||
|
|
||||||
|
if n0.name == "snow:slab_" .. subname and not n0_is_upside_down and p0.y+1 == p1.y then
|
||||||
|
slabpos = p0
|
||||||
|
slabnode = n0
|
||||||
|
elseif n1.name == "snow:slab_" .. subname then
|
||||||
|
slabpos = p1
|
||||||
|
slabnode = n1
|
||||||
|
end
|
||||||
|
if slabpos then
|
||||||
|
-- Remove the slab at slabpos
|
||||||
|
minetest.remove_node(slabpos)
|
||||||
|
-- Make a fake stack of a single item and try to place it
|
||||||
|
local fakestack = ItemStack(recipeitem)
|
||||||
|
fakestack:set_count(itemstack:get_count())
|
||||||
|
|
||||||
|
pointed_thing.above = slabpos
|
||||||
|
local success
|
||||||
|
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
|
||||||
|
-- If the item was taken from the fake stack, decrement original
|
||||||
|
if success then
|
||||||
|
itemstack:set_count(fakestack:get_count())
|
||||||
|
-- Else put old node back
|
||||||
|
else
|
||||||
|
minetest.set_node(slabpos, slabnode)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Upside down slabs
|
||||||
|
if p0.y-1 == p1.y then
|
||||||
|
-- Turn into full block if pointing at a existing slab
|
||||||
|
if n0_is_upside_down then
|
||||||
|
-- Remove the slab at the position of the slab
|
||||||
|
minetest.remove_node(p0)
|
||||||
|
-- Make a fake stack of a single item and try to place it
|
||||||
|
local fakestack = ItemStack(recipeitem)
|
||||||
|
fakestack:set_count(itemstack:get_count())
|
||||||
|
|
||||||
|
pointed_thing.above = p0
|
||||||
|
local success
|
||||||
|
fakestack, success = minetest.item_place(fakestack, placer, pointed_thing)
|
||||||
|
-- If the item was taken from the fake stack, decrement original
|
||||||
|
if success then
|
||||||
|
itemstack:set_count(fakestack:get_count())
|
||||||
|
-- Else put old node back
|
||||||
|
else
|
||||||
|
minetest.set_node(p0, n0)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Place upside down slab
|
||||||
|
param2 = 20
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If pointing at the side of a upside down slab
|
||||||
|
if n0_is_upside_down and p0.y+1 ~= p1.y then
|
||||||
|
param2 = 20
|
||||||
|
end
|
||||||
|
|
||||||
|
return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||||
|
end
|
||||||
|
Leave commented out
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Below, in the "groups" line there is a "melts" category. Back in the ABMs lua file, melting
|
||||||
|
code, melts=1 will produce a water_source when the full-sized snow/ice block is melted making
|
||||||
|
a big, watery mess. melts=2 will produce a water_source only for a moment, then it changes back
|
||||||
|
to water_flowing and then dries-up and disappears. I gave these stairs/slabs/panels/microblocks
|
||||||
|
a melts value of 2 instead of 1 because they are not full blocks.
|
||||||
|
|
||||||
|
~ LazyJ
|
||||||
|
--]]
|
||||||
|
|
||||||
|
-- Default snowblock and ice stairs/slabs/panels/microblocks.
|
||||||
|
|
||||||
|
local ndef = minetest.registered_nodes["default:ice"]
|
||||||
|
local groups = {}
|
||||||
|
for k, v in pairs(ndef.groups) do groups[k] = v end
|
||||||
|
|
||||||
|
stairsplus:register_all("moreblocks", "ice", "default:ice", {
|
||||||
|
description = ndef.description,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
-- Added "icemaker=1" in groups. This ties into the freezing
|
||||||
|
-- function in the ABMs.lua file. ~ LazyJ
|
||||||
|
groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1, melts=2, icemaker=1},
|
||||||
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
tiles = ndef.tiles,
|
||||||
|
-- Because of the "use_texture_alpha" line, that gives ice transparency, I couldn't combine
|
||||||
|
-- default ice and default snowblocks in a list like MoreBlocks does. ~ LazyJ
|
||||||
|
use_texture_alpha = true,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
-- This "on_place" line makes placing these nodes recorded in the logs.
|
||||||
|
-- Useful for investigating griefings and determining ownership
|
||||||
|
-- BUT these nodes will nolonger auto-rotate into position. ~ LazyJ
|
||||||
|
|
||||||
|
--on_place = minetest.item_place,
|
||||||
|
|
||||||
|
-- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could
|
||||||
|
-- also double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
if minetest.get_node(pos).name == "default:dirt_with_grass"
|
||||||
|
or minetest.get_node(pos).name == "default:dirt" then
|
||||||
|
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
--end
|
||||||
|
|
||||||
|
|
||||||
|
local ndef = minetest.registered_nodes["default:snowblock"]
|
||||||
|
local groups = {}
|
||||||
|
for k, v in pairs(ndef.groups) do groups[k] = v end
|
||||||
|
|
||||||
|
stairsplus:register_all("moreblocks", "snowblock", "default:snowblock", {
|
||||||
|
description = ndef.description,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
-- Added "icemaker=1" in groups. This ties into the freezing function
|
||||||
|
-- in the ABMs.lua file. ~ LazyJ
|
||||||
|
groups = {cracky=3, crumbly=3, choppy=3, oddly_breakable_by_hand=3, melts=2, icemaker=1},
|
||||||
|
tiles = ndef.tiles,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
sounds = default.node_sound_dirt_defaults({
|
||||||
|
footstep = {name="default_snow_footstep", gain=0.25},
|
||||||
|
dig = {name="default_dig_crumbly", gain=0.4},
|
||||||
|
dug = {name="default_snow_footstep", gain=0.75},
|
||||||
|
place = {name="default_place_node", gain=1.0}
|
||||||
|
}),
|
||||||
|
-- This "on_place" line makes placing these nodes recorded in the logs.
|
||||||
|
-- Useful for investigating griefings and determining ownership
|
||||||
|
-- BUT these nodes will nolonger auto-rotate into position. ~ LazyJ
|
||||||
|
|
||||||
|
--on_place = minetest.item_place,
|
||||||
|
|
||||||
|
-- The "on_construct" part below, thinking in terms of layers,
|
||||||
|
-- dirt_with_snow could also double as dirt_with_frost
|
||||||
|
-- which adds subtlety to the winterscape. ~ LazyJ
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
if minetest.get_node(pos).name == "default:dirt_with_grass"
|
||||||
|
or minetest.get_node(pos).name == "default:dirt" then
|
||||||
|
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Snow stairs/slabs/panels/microblocks.
|
||||||
|
|
||||||
|
local snow_nodes = {
|
||||||
|
"snow_brick",
|
||||||
|
"snow_cobble",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, name in pairs(snow_nodes) do
|
||||||
|
local nodename = "snow:"..name
|
||||||
|
local ndef = minetest.registered_nodes[nodename]
|
||||||
|
local groups = {}
|
||||||
|
for k, v in pairs(ndef.groups) do groups[k] = v end
|
||||||
|
|
||||||
|
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",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
sounds = default.node_sound_dirt_defaults({
|
||||||
|
footstep = {name="default_snow_footstep", gain=0.25},
|
||||||
|
dig = {name="default_dig_crumbly", gain=0.4},
|
||||||
|
dug = {name="default_snow_footstep", gain=0.75},
|
||||||
|
place = {name="default_place_node", gain=1.0}
|
||||||
|
}),
|
||||||
|
-- This "on_place" line makes placing these nodes recorded in the logs.
|
||||||
|
-- Useful for investigating griefings and determining ownership
|
||||||
|
-- BUT these nodes will nolonger auto-rotate into position. ~ LazyJ
|
||||||
|
|
||||||
|
--on_place = minetest.item_place,
|
||||||
|
|
||||||
|
|
||||||
|
-- Some attempts to have both, the recording in the logs of the placing of
|
||||||
|
-- the stairplus stuff *and* have the auto-rotation work. No luck yet.
|
||||||
|
-- ~ LazyJ
|
||||||
|
|
||||||
|
--[[
|
||||||
|
on_place = function (i, p, t)
|
||||||
|
minetest.item_place(i, p, t, 0)
|
||||||
|
minetest.rotate_node(i, p, t)
|
||||||
|
end,
|
||||||
|
--]]
|
||||||
|
--[[
|
||||||
|
on_place = function (i, p, t)
|
||||||
|
minetest.rotate_node(i, p, t, 0)
|
||||||
|
minetest.item_place(i, p, t)
|
||||||
|
end,
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Picking up were we left off... ~ LazyJ
|
||||||
|
|
||||||
|
-- The "on_construct" part below, thinking in terms of layers, dirt_with_snow could
|
||||||
|
-- also double as dirt_with_frost which adds subtlety to the winterscape. ~ LazyJ
|
||||||
|
on_construct = function(pos)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
if minetest.get_node(pos).name == "default:dirt_with_grass"
|
||||||
|
or minetest.get_node(pos).name == "default:dirt"
|
||||||
|
then minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||||
|
end
|
||||||
|
-- Some ideas I've tried. Leaving for future reference till I can figure out a workable solution. ~ LazyJ
|
||||||
|
--minetest.log("action", sender:get_player_name().." places" ..minetest.get_node(pos).name.. "at" ..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", minetest.get_player_name().." places" ..minetest.get_node(pos).name.. "at" ..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", "BINGO places "..minetest.get_name().." at "..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", minetest.get_player_name().." places "..minetest.get_name().." at "..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", placer:get_player_name().." places moreblocks-something at "..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", " BINGO places "..minetest.get_pointed_thing().." at "..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", "BINGO places moreblocks"..ndef.." at "..minetest.pos_to_string(pos))
|
||||||
|
--minetest.log("action", "A pine sapling grows into a Christmas tree at "..minetest.pos_to_string(pos))
|
||||||
|
--return minetest.item_place(itemstack, placer, pointed_thing, param2)
|
||||||
|
--return minetest.item_place(itemstack, pointed_thing, param2)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
205
src/util.lua
Normal file → Executable file
@ -1,25 +1,38 @@
|
|||||||
--Global config and function table.
|
--Global config and function table.
|
||||||
snow = {
|
snow = {
|
||||||
snowball_gravity = tonumber(minetest.settings:get("snow_snowball_gravity")) or 0.91,
|
snowball_gravity = 100/109,
|
||||||
snowball_velocity = tonumber(minetest.settings:get("snow_snowball_velocity")) or 19,
|
snowball_velocity = 19,
|
||||||
sleds = minetest.settings:get_bool("snow_sleds", true),
|
sleds = true,
|
||||||
enable_snowfall = minetest.settings:get_bool("snow_enable_snowfall", true),
|
enable_snowfall = true,
|
||||||
lighter_snowfall = minetest.settings:get_bool("snow_lighter_snowfall", false),
|
lighter_snowfall = false,
|
||||||
debug = minetest.settings:get_bool("snow_debug", false),
|
debug = false,
|
||||||
smooth_biomes = minetest.settings:get_bool("snow_smooth_biomes", true),
|
smooth_biomes = true,
|
||||||
christmas_content = minetest.settings:get_bool("snow_christmas_content", true),
|
christmas_content = true,
|
||||||
smooth_snow = minetest.settings:get_bool("snow_smooth_snow", true),
|
smooth_snow = true,
|
||||||
min_height = tonumber(minetest.settings:get("snow_min_height")) or 3,
|
min_height = 3,
|
||||||
mapgen_rarity = tonumber(minetest.settings:get("snow_mapgen_rarity")) or 18,
|
mapgen_rarity = 18,
|
||||||
mapgen_size = tonumber(minetest.settings:get("snow_mapgen_size")) or 210,
|
mapgen_size = 210,
|
||||||
disable_mapgen = minetest.settings:get_bool("snow_disable_mapgen", true),
|
}
|
||||||
|
|
||||||
|
--Config documentation.
|
||||||
|
local doc = {
|
||||||
|
snowball_gravity = "The gravity of thrown snowballs",
|
||||||
|
snowball_velocity = "How fast players throw snowballs",
|
||||||
|
sleds = "Disable this to prevent sleds from being riden.",
|
||||||
|
enable_snowfall = "Enables falling snow.",
|
||||||
|
lighter_snowfall = "Reduces the amount of resources and fps used by snowfall.",
|
||||||
|
debug = "Enables debug output. Currently it only prints mgv6 info.",
|
||||||
|
smooth_biomes = "Enables smooth transition of biomes (mgv6)",
|
||||||
|
smooth_snow = "Disable this to stop snow from being smoothed.",
|
||||||
|
christmas_content = "Disable this to remove christmas saplings from being found.",
|
||||||
|
min_height = "The minumum height a snow biome will generate (mgv7)",
|
||||||
|
mapgen_rarity = "mapgen rarity in %",
|
||||||
|
mapgen_size = "size of the generated… (has an effect to the rarity, too)",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- functions for dynamically changing settings
|
-- functions for dynamically changing settings
|
||||||
|
|
||||||
snow.register_on_configuring = function() end
|
|
||||||
--[[
|
|
||||||
local on_configurings,n = {},1
|
local on_configurings,n = {},1
|
||||||
function snow.register_on_configuring(func)
|
function snow.register_on_configuring(func)
|
||||||
on_configurings[n] = func
|
on_configurings[n] = func
|
||||||
@ -52,4 +65,164 @@ local function value_from_string(v)
|
|||||||
end
|
end
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
--]]
|
|
||||||
|
local allowed_types = {string = true, number = true, boolean = true}
|
||||||
|
|
||||||
|
--Saves contents of config to file.
|
||||||
|
local function saveConfig(path, config, doc)
|
||||||
|
local file = io.open(path,"w")
|
||||||
|
if not file then
|
||||||
|
minetest.log("error", "[snow] could not open config file for writing at "..path)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i,v in pairs(config) do
|
||||||
|
if allowed_types[type(v)] then
|
||||||
|
if doc and doc[i] then
|
||||||
|
file:write("# "..doc[i].."\n")
|
||||||
|
end
|
||||||
|
file:write(i.." = "..tostring(v).."\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
local modpath = minetest.get_modpath("snow")
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
saveConfig(modpath.."/config.txt", snow, doc)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- load settings from config.txt
|
||||||
|
|
||||||
|
local config
|
||||||
|
do
|
||||||
|
local path = modpath.."/config.txt"
|
||||||
|
local file = io.open(path,"r")
|
||||||
|
if not file then
|
||||||
|
--Create config file.
|
||||||
|
return
|
||||||
|
end
|
||||||
|
io.close(file)
|
||||||
|
config = {}
|
||||||
|
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
|
||||||
|
config[i] = value_from_string(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if config then
|
||||||
|
for i,v in pairs(config) do
|
||||||
|
if type(snow[i]) == type(v) then
|
||||||
|
snow[i] = v
|
||||||
|
else
|
||||||
|
minetest.log("error", "[snow] wrong type of setting "..i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
saveConfig(modpath.."/config.txt", snow, doc)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- load settings from minetest.conf
|
||||||
|
|
||||||
|
for i,v in pairs(snow) do
|
||||||
|
if allowed_types[type(v)] then
|
||||||
|
local v = minetest.setting_get("snow_"..i)
|
||||||
|
if v ~= nil then
|
||||||
|
snow[i] = value_from_string(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--MENU
|
||||||
|
|
||||||
|
local function form_sort_func(a,b)
|
||||||
|
return a[1] < b[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
local function form_sort_func_bool(a,b)
|
||||||
|
if a[2] == b[2] then
|
||||||
|
return a[1] < b[1]
|
||||||
|
else
|
||||||
|
return b[2]
|
||||||
|
end
|
||||||
|
end--]]
|
||||||
|
|
||||||
|
local function get_formspec()
|
||||||
|
local ids,n1,n2 = {{},{}},1,1
|
||||||
|
for i,v in pairs(snow) do
|
||||||
|
local t = type(v)
|
||||||
|
if t == "string"
|
||||||
|
or t == "number" then
|
||||||
|
ids[2][n2] = {i,v}
|
||||||
|
n2 = n2+1
|
||||||
|
elseif t == "boolean" then
|
||||||
|
ids[1][n1] = {i,v}
|
||||||
|
n1 = n1+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(ids[2], form_sort_func)
|
||||||
|
table.sort(ids[1], form_sort_func)
|
||||||
|
|
||||||
|
local p = -0.5
|
||||||
|
local formspec = "label[0,-0.3;Settings:]"
|
||||||
|
for n = 1,n1-1 do
|
||||||
|
local i,v = unpack(ids[1][n])
|
||||||
|
p = p + 0.5
|
||||||
|
formspec = formspec.."checkbox[0,"..p..";snow:"..i..";"..i..";"..tostring(v).."]"
|
||||||
|
end
|
||||||
|
for n = 1,n2-1 do
|
||||||
|
local i,v = unpack(ids[2][n])
|
||||||
|
p = p + 1.5
|
||||||
|
formspec = formspec.."field[0.3,"..p..";2,1;snow:"..i..";"..i..";"..v.."]"
|
||||||
|
end
|
||||||
|
p = p + 1
|
||||||
|
formspec = "size[4,"..p..";]\n"..formspec
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("snow", {
|
||||||
|
description = "Show a menu for various actions",
|
||||||
|
privs = {server=true},
|
||||||
|
func = function(name)
|
||||||
|
minetest.chat_send_player(name, "Showing snow menu…")
|
||||||
|
minetest.show_formspec(name, "snow:menu", get_formspec())
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= "snow:menu" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i,v in pairs(snow) do
|
||||||
|
local t = type(v)
|
||||||
|
if allowed_types[t] then
|
||||||
|
local field = fields["snow:"..i]
|
||||||
|
if field then
|
||||||
|
if t == "number" then
|
||||||
|
field = tonumber(field)
|
||||||
|
elseif t == "boolean" then
|
||||||
|
if field == "true" then
|
||||||
|
field = true
|
||||||
|
elseif field == "false" then
|
||||||
|
field = false
|
||||||
|
else
|
||||||
|
field = nil
|
||||||
|
end
|
||||||
|
elseif t ~= "string" then
|
||||||
|
field = nil
|
||||||
|
end
|
||||||
|
if field ~= nil then
|
||||||
|
change_setting(i, field)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
0
textures/character_snow_man.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
textures/character_snow_man_preview.png
Normal file → Executable file
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
0
textures/character_snow_man_preview_back.png
Normal file → Executable file
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 211 B |
0
textures/snow_apple.png
Normal file → Executable file
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
0
textures/snow_dandelion_white.png
Normal file → Executable file
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 122 B |
0
textures/snow_dandelion_yellow.png
Normal file → Executable file
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
0
textures/snow_geranium.png
Normal file → Executable file
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 643 B |
0
textures/snow_ice_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 665 B After Width: | Height: | Size: 665 B |
Before Width: | Height: | Size: 606 B |
0
textures/snow_leaves.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 190 B |
0
textures/snow_moss.png
Normal file → Executable file
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |
0
textures/snow_needles.png
Normal file → Executable file
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 660 B |
0
textures/snow_needles_decorated.png
Normal file → Executable file
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 884 B |
0
textures/snow_needles_decorated_animated.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
textures/snow_rose.png
Normal file → Executable file
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
0
textures/snow_sapling_pine.png
Normal file → Executable file
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 272 B |
0
textures/snow_shrub.png
Normal file → Executable file
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
0
textures/snow_shrub_covering.png
Normal file → Executable file
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 297 B |
0
textures/snow_sled.png
Normal file → Executable file
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
0
textures/snow_snow_brick.png
Normal file → Executable file
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 484 B |
0
textures/snow_snow_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
0
textures/snow_star.png
Normal file → Executable file
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
0
textures/snow_star_lit.png
Normal file → Executable file
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 302 B |
0
textures/snow_tulip.png
Normal file → Executable file
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 124 B |
0
textures/snow_viola.png
Normal file → Executable file
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 117 B |
0
textures/snow_xmas_tree.png
Normal file → Executable file
Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 105 B |