Compare commits
	
		
			201 Commits
		
	
	
		
			1.0
			...
			73cf3790fa
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 73cf3790fa | |||
| 8dae0a0246 | |||
| db6bf1d1b2 | |||
|  | e8a15bf467 | ||
|  | 76981af958 | ||
| afe80c0dc3 | |||
| f51bcd00df | |||
|  | d3ba0dd21c | ||
|  | 3b44907492 | ||
|  | d215ac3fff | ||
|  | dc799f344f | ||
|  | 6529ab9304 | ||
|  | b4add0091c | ||
|  | 854e10f087 | ||
|  | 794fb251ba | ||
|  | 6120890c5d | ||
|  | d06bec7c52 | ||
|  | df38728f4b | ||
|  | 8f34ce940b | ||
|  | 221c440034 | ||
|  | 036f502968 | ||
|  | de45f53153 | ||
|  | 337e9e2c55 | ||
|  | 11364a550c | ||
|  | 5b4e705055 | ||
|  | 1b4cc3e94c | ||
|  | 0e5f469c3b | ||
|  | 6f9ba85f51 | ||
|  | 3737d6eb38 | ||
|  | 7f394447f1 | ||
|  | ee3b12c07d | ||
|  | a624a6fabe | ||
|  | 0c90b5dcf3 | ||
|  | efbfa989d2 | ||
|  | 1510ced771 | ||
|  | 663b151dec | ||
|  | 898c7e313b | ||
|  | 0dcf9b5f0e | ||
|  | 600eaa2313 | ||
|  | aec3bf2ed3 | ||
|  | fd111402d5 | ||
|  | 2dd10091df | ||
|  | 76eca09e97 | ||
|  | 2df09a7ebb | ||
|  | 13ecf6a8b2 | ||
|  | d962139358 | ||
|  | 812b0f977e | ||
|  | f7b048a851 | ||
|  | 44ae0ab35d | ||
|  | c72f56068f | ||
|  | da6a4b3361 | ||
|  | bf113a15ff | ||
|  | 9d657246c9 | ||
|  | 48db038755 | ||
|  | 7774eb3f7f | ||
|  | 9f73cc4778 | ||
|  | c9aaed23a5 | ||
|  | b1a7d12b90 | ||
|  | 6affec0a56 | ||
|  | 7080b2dbe0 | ||
|  | 30b0dd9557 | ||
|  | 020ef2fa49 | ||
|  | d61a1d54ab | ||
|  | 92f5cb0fde | ||
|  | 1c1a5c11b7 | ||
|  | 6488a3b8f5 | ||
|  | 90e08fe0bc | ||
|  | a5ae53fbeb | ||
|  | 850e5d9d33 | ||
|  | 990ace49d8 | ||
|  | b3cdf93212 | ||
|  | 049349360e | ||
|  | 9d2211b0b5 | ||
|  | 745fca1c84 | ||
|  | dee9b5ada1 | ||
|  | b994bbc5fd | ||
|  | a6af64f3f1 | ||
|  | 8d78cb6867 | ||
|  | d8d79655af | ||
|  | 0e52c53452 | ||
|  | afc578cb16 | ||
|  | 346a263761 | ||
|  | 4a30e67f46 | ||
|  | 097f5f5419 | ||
|  | 3f99399f1d | ||
|  | b647842ad4 | ||
|  | 35c21dd879 | ||
|  | a217f17566 | ||
|  | 939c63e507 | ||
|  | 7370b142ed | ||
|  | e990039ea3 | ||
|  | 521e24f69a | ||
|  | 06e74418e9 | ||
|  | 4a2c869407 | ||
|  | 51aa9a372b | ||
|  | 4286299c0e | ||
|  | 6dbbf90f34 | ||
|  | f82c525222 | ||
|  | 60f3ac4dea | ||
|  | 4a9fbc8202 | ||
|  | ccc1b5154d | ||
|  | 47a8691b82 | ||
|  | 9cd39dc111 | ||
|  | de80a0910e | ||
|  | acb5141cbe | ||
|  | ead65ab164 | ||
|  | 476dd1e029 | ||
|  | feea2d4693 | ||
|  | d5cdc50f3a | ||
|  | 3527d3158d | ||
|  | 0a3d7859cb | ||
|  | 2d91071751 | ||
|  | 0443994f06 | ||
|  | 32b08f6738 | ||
|  | 99af62a552 | ||
|  | 777d5b1407 | ||
|  | 09a422a0e7 | ||
|  | a029130d61 | ||
|  | f26ece0620 | ||
|  | 5b6592022f | ||
|  | 914758da71 | ||
|  | 921560e03f | ||
|  | bf0fa8df63 | ||
|  | f2b23a0a27 | ||
|  | 819f2d6cfb | ||
|  | d2e7ce77ba | ||
|  | 0708ea6af3 | ||
|  | 062a451bc7 | ||
|  | c0b40b5cbf | ||
|  | 6bbc4d359e | ||
|  | b1badd332b | ||
|  | aa687f5d54 | ||
|  | c05009682e | ||
|  | c8c2fbd013 | ||
|  | 46cf4e907a | ||
|  | ed97a5aaf3 | ||
|  | b9e93a8b58 | ||
|  | de76f5dc62 | ||
|  | e889cbc6a4 | ||
|  | 943efa6110 | ||
|  | a3b9c2df55 | ||
|  | 84803a5cc9 | ||
|  | 5bccad6a08 | ||
|  | f26e28c3a1 | ||
|  | abd9690433 | ||
|  | a3b9a4453a | ||
|  | d0f7233b3d | ||
|  | 96086a048f | ||
|  | 2ae53c95ec | ||
|  | 463114375a | ||
|  | 10a11591de | ||
|  | 86f0b92dcf | ||
|  | 02e64c9d1b | ||
|  | 6b3b4a8702 | ||
|  | f99ba3a1f6 | ||
|  | 37ecfd02a8 | ||
|  | 4d696c4843 | ||
|  | 8dc199dd5b | ||
|  | 5a7f6d8aa5 | ||
|  | f75eaa98a9 | ||
|  | 7780db088d | ||
|  | cdf33a3881 | ||
|  | d957adc61b | ||
|  | be26762fb7 | ||
|  | b2663d0ae3 | ||
|  | 2c83d5ed76 | ||
|  | e6f20f5825 | ||
|  | 7a2b405698 | ||
|  | 22b47f20a7 | ||
|  | 52cdffd1af | ||
|  | 79b2653d25 | ||
|  | 16d174240d | ||
|  | 3aa532202d | ||
|  | 954726e8c5 | ||
|  | 13d66be25f | ||
|  | 0c08b46264 | ||
|  | 2ea175600e | ||
|  | 31dba55c81 | ||
|  | 1710db6daa | ||
|  | f37ba7a615 | ||
|  | a4470eec2a | ||
|  | c98663085a | ||
|  | ba01e32452 | ||
|  | 1cc2c6758b | ||
|  | 848f30543d | ||
|  | 6fd073aaa7 | ||
|  | dbde0d7c93 | ||
|  | 7f9207c6ff | ||
|  | 78a0fe9f8c | ||
|  | ddfc5102a1 | ||
|  | 2a3c61b2e3 | ||
|  | b472de8132 | ||
|  | 639bda9402 | ||
|  | 69ae37cc8e | ||
|  | 191e94af02 | ||
|  | ad063c0b66 | ||
|  | bc276b44cf | ||
|  | 212e7d000e | ||
|  | 999afab1e4 | ||
|  | 7db04ee476 | ||
|  | 6a5b25bda6 | 
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,3 @@ | ||||
| config.txt | ||||
| debug.txt | ||||
| *~ | ||||
							
								
								
									
										16
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,16 @@ | ||||
| read_globals = { | ||||
| 	"dump", "vector", "minetest", | ||||
| 	"table", "math", "PseudoRandom", "VoxelArea", | ||||
| 	"stairs", "stairsplus", "skins", "treecapitator", | ||||
| 	default = { | ||||
| 		fields = { | ||||
| 			player_attached = { | ||||
| 				read_only = false, | ||||
| 				other_fields = true | ||||
| 			} | ||||
| 		}, | ||||
| 		other_fields = true | ||||
| 	} | ||||
| } | ||||
| globals = {"snow"} | ||||
| -- ignore = {"421", "423"} | ||||
							
								
								
									
										162
									
								
								LazyJ-changelog.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,162 @@ | ||||
| ~ LazyJ, 2014_06_01 | ||||
|  | ||||
| ~~~~~~~~~~~~~~~~~~~~ | ||||
| List of Changes | ||||
| ~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
|  | ||||
|  | ||||
| ##### MapGen | ||||
|  | ||||
| I did *not* fix Snow's mapgen issue with "PlantLife" (another great, Minetest | ||||
| standard) based mods. Mapgen stuff is far beyond my current skill level. | ||||
| What little changes I did make were to switch-out Snow nodes that Minetest | ||||
| now has as defaults (dirt_with_snow, snow, ice). My thoughts being that | ||||
| texture packs and other mods that may use these nodes as recipe items are more | ||||
| likely to support default nodes. I also added a line above and below in the | ||||
| "mapgen.lua" file indicating where to put the comment symbols to | ||||
| comment-out/disable Snow's mapgen. Mods based on VanessaE's excellent | ||||
| "PlantLife" mod will not produce if Snow's mapgen is active. | ||||
| *Snow's mapgen is active by default.* | ||||
| I did not disable it, merely indicated were the comment symbols are | ||||
| to be placed. To compensate for the loss of snow resources when Snow's mapgen | ||||
| is disabled, I created crafting recipes that allows players to craft more | ||||
| snow, ice, and moss. This not only encourages snow builds, but also allows | ||||
| the players to create snow biomes where they want and whatever size they are | ||||
| willing to make them. | ||||
|  | ||||
|  | ||||
| ##### Fixed | ||||
| 	* Pine saplings are now replaced with tree trunks when the tree grows. | ||||
| 	* Snowballs no longer pass through solid objects. Griefers can no | ||||
| 	longer flood the interiors of builds by throwing snowballs through the | ||||
| 	walls hoping to either leave a snowy mess inside or that a heat source | ||||
| 	would melt the snow and flood the interior. | ||||
| 	* Snowballs no longer destroy nodes when thrown at the sides. | ||||
| 	* Falling snow no longer destroys nodes (same problem snowballs had). | ||||
| 	* Snow bricks now, instead of disappearing like before, melt | ||||
| 	into water sources. | ||||
| 	* Christmas tree saplings once again will drop when pine needles | ||||
| 	are harvested. | ||||
| 	* Dirt_with_snow changes to dirt when a solid, non-light permeating | ||||
| 	(sunlight_propagates) block is set on top of it. | ||||
|  | ||||
|  | ||||
|  | ||||
| ##### Changed | ||||
| 	* All snow and ice stuff (including the stairs, slabs, panels, and | ||||
| 	microblocks) will freeze dirt and dirt_with_grass into dirt_with_snow. | ||||
| 	* All snow and most ice stuff will freeze water into ice, including | ||||
| 	the stairs, slabs, panels, and microblocks. The exception is the | ||||
| 	full-sized ice blocks will *not* freeze water into ice. | ||||
| 	* Snow brick texture reworked and based off of the default stone brick | ||||
| 	texture (and less purple in the grout). | ||||
| 	* Ice stuff is now semi-transparent. | ||||
| 	* Christmas trees now have blinking lights that give off a | ||||
| 	low level of light. | ||||
| 	* Christmas tree stars now give off a high level of light and the | ||||
| 	light can be punched on or off. | ||||
| 	* Combined default snow and snowballs. Now snow can be | ||||
| 	thrown (left-click) or placed (right-click).  | ||||
| 	* Snow stuff now has "snow" sounds instead of "grass" sounds. | ||||
| 	* Melting - Full-sized snow blocks, snow brick, snow cobble, and ice | ||||
| 	will melt into water sources. The down-side is this makes a big, | ||||
| 	permanent mess. The up-side, this is a convenient way to carry water, | ||||
| 	if buckets are disabled on your server, by keeping full-sized snow | ||||
| 	stuff and ice blocks in your inventory to, later, melt where you | ||||
| 	need water. | ||||
| 	* Melting - Partial and small-sized blocks like snow (snowballs), | ||||
| 	basic stairs and slabs for snow stuff and ice, and circular saw-made | ||||
| 	snow stuff and ice things will melt into a water source for 2 seconds, | ||||
| 	then switch from a water source to flowing water, and after a moment | ||||
| 	the flowing water dries-up (small, temporary mess). | ||||
|  | ||||
|  | ||||
|  | ||||
| ##### Added | ||||
| 	* New block-type: "Snow Cobble". Just like regular cobble from regular | ||||
| 	stone, snow cobble comes from digging snow blocks. | ||||
| 	* All snow and ice blocks can be crafted into basic slabs and stairs. | ||||
| 	The default slabs stack and change back into full-sized blocks | ||||
| 	("More Blocks" slabs won't do this). | ||||
| 	* Soft dependency on a recent release Calinou's MoreBlocks so all | ||||
| 	snow and ice blocks are compatible with the circular saw. If you don't | ||||
| 	have MoreBlocks installed, Snow will ignore the code for those fancy | ||||
| 	blocks and use basic stairs and slabs instead. | ||||
| 	* All snow and ice stuff works with the screwdriver. | ||||
| 	* Crafting, recycling, and cooking recipes for snow blocks, | ||||
| 	ice, and moss. | ||||
| 		* Snow bricks craft-recycle back into 4 snow blocks. | ||||
| 		* 2 snow blocks craft into 3 snow blocks. This is to make up | ||||
| 		for when the mapgen for snow biomes is disabled. | ||||
| 		* 2 snow cobble craft-recycle into 3 snow blocks. | ||||
| 		* 4 pine needles craft into 1 moss | ||||
| 		* Snow blocks, snow cobble, and snow bricks can be cooked in a | ||||
| 		furnace to make ice. | ||||
| 	* Snowballs can be thrown (left-click) to build up layers. After the | ||||
| 	11th layer, the bottom 9 layers change into a snow block. At a very | ||||
| 	close distance, throwing snowballs can be used as a technique to | ||||
| 	build-up gradual slopes. If you have lots and lots of snow balls, | ||||
| 	with rapid-fire throwing, you can, very briefly, "white-out" another | ||||
| 	player's view if your aim is good enough to hit them in the face. | ||||
| 	* Snowballs can be placed (right-click) but will not stack into | ||||
| 	multiple layers. Just one layer only. Placing snow is more reliable | ||||
| 	and accurate than throwing snow from a distance. By placing snow, | ||||
| 	players are able to create their own, personal, snow biomes. | ||||
| 	* Vertical clearance check for tree growth. The nine blocks above the | ||||
| 	spot where the sapling is placed must be free and clear of all | ||||
| 	obstructions or else the sapling will not be allowed to grow. | ||||
| 	Griefers could place the saplings in builds and when the tree grows | ||||
| 	it may not destroy nodes but it fills the available air space leaving | ||||
| 	a mess for the build's owner to clean-up. Now the trees will only grow | ||||
| 	inside if there is 9, free-and-clear spaces from floor to ceiling. | ||||
| 	Because pine trees (and Christmas trees) will grow on any solid surface, | ||||
| 	their saplings are handy to take with you when deep mining. Just before | ||||
| 	you run out of tool wood, dig out a space large enough for a tree to | ||||
| 	grow, plant a pine or Christmas tree sapling then place 2 torches on | ||||
| 	either side, right next to the sapling. After the tree grows harvest | ||||
| 	the trunk for tool wood, the leaves for short-run fuel in the furnace | ||||
| 	and for saplings to renew your tool wood supply again. | ||||
| 	* Aliases to help make WorldEdit and "give" commands easier: | ||||
| 			 | ||||
|  | ||||
| 	"default_snow" = "default:snow" | ||||
| 	"snowball" = "default:snow" | ||||
| 	"snowballs" = "default:snow" | ||||
| 	"snow_ball" = "default:snow" | ||||
| 	"ice" = "default:ice" | ||||
| 	"default_ice" = "default:ice" | ||||
| 	"dirtwithsnow" = "default:dirt_with_snow" | ||||
| 	"snowdirt" = "default:dirt_with_snow" | ||||
| 	"snowydirt" = "default:dirt_with_snow" | ||||
| 	"snowblocks" = "default:snowblock" | ||||
| 	"snowbrick" = "snow:snow_brick" | ||||
| 	"bricksnow" = "snow:snow_brick" | ||||
| 	"snowbricks" = "snow:snow_brick" | ||||
| 	"snowybricks" = "snow:snow_brick" | ||||
| 	"snowcobble" = "snow:snow_cobble" | ||||
| 	"snowycobble" = "snow:snow_cobble" | ||||
| 	"cobblesnow" = "snow:snow_cobble" | ||||
|  | ||||
|  | ||||
|  | ||||
| ~~~~~~ | ||||
| TODO | ||||
| ~~~~~~ | ||||
|  | ||||
| Falling Snow: | ||||
| 	* Add code to prevent snowfall from depositing snow on or near torches, | ||||
| active furnaces, and lava. | ||||
|  | ||||
| 	* Add code to prevent snowfall from depositing snow on | ||||
| 'walkable = false' defined nodes. | ||||
|  | ||||
|  | ||||
|  | ||||
| Sled: | ||||
| 	* Figure out why the player avatars remain in a seated position, | ||||
| even after getting off the sled, if they flew while on the sled. | ||||
| 'default.player_set_animation', where is a better explanation for this and what | ||||
| are it's available options? | ||||
|  | ||||
|  | ||||
							
								
								
									
										72
									
								
								changelog.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,72 @@ | ||||
| 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 | ||||
|  | ||||
| 	Update compatibility to the latest minetest. | ||||
| 	 | ||||
| Version 0.3.1 | ||||
|  | ||||
| 	Paramat's rewrite of mapgenv6.lua: bugfixes, use noisemaps for big speed increase | ||||
|  | ||||
| Version 3.0 | ||||
| 	LazyJ's big changes (see LazyJ-changelog.txt) | ||||
| 	 | ||||
| 	Ice freezes-over. | ||||
| 	 | ||||
| 	Better leveled snow. | ||||
| 	 | ||||
| 	PLUS MORE! (see commit log) | ||||
|  | ||||
| Version 2.0 | ||||
|  | ||||
|     Uses default namespace. | ||||
|      | ||||
|     Sleds. | ||||
|      | ||||
|     Bugfixes. | ||||
|      | ||||
| Version 1.8 | ||||
|  | ||||
|     Mapgen_v7 support. | ||||
|      | ||||
|     Better config system. | ||||
|      | ||||
|     Falling snow. | ||||
|  | ||||
| Version 1.4 | ||||
|  | ||||
|     New biomes, snowy and plain | ||||
|      | ||||
|     Christmas Trees | ||||
|      | ||||
|     Snowfall | ||||
|      | ||||
| Version 1.3 | ||||
|  | ||||
|     Smooth transitions | ||||
|      | ||||
|     Snow Bricks | ||||
|  | ||||
| Version 1.2 | ||||
|  | ||||
|     Pine trees | ||||
|      | ||||
|     Moss | ||||
|      | ||||
|     Alpine biomes | ||||
| 	 | ||||
|     Dry shrubs | ||||
|  | ||||
| Version 1.1 | ||||
|  | ||||
|     Better mapgen | ||||
|  | ||||
| Version 1.0 | ||||
|  | ||||
|     Initial release | ||||
							
								
								
									
										10
									
								
								config.lua
									
									
									
									
									
								
							
							
						
						| @@ -1,10 +0,0 @@ | ||||
| --This file contains configuration options for snow mod. | ||||
|  | ||||
| --Enables falling snow. | ||||
| snow.enable_snowfall = true | ||||
|  | ||||
| --Enables debuging. | ||||
| snow.debug = false | ||||
|  | ||||
| --Enables smooth transition of biomes. | ||||
| snow.smooth = true | ||||
| @@ -1 +1,7 @@ | ||||
| default | ||||
| christmas_craft? | ||||
| flowers? | ||||
| stairs? | ||||
| moreblocks? | ||||
| skins? | ||||
| treecapitator? | ||||
|   | ||||
							
								
								
									
										741
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						| @@ -1,590 +1,207 @@ | ||||
| --[[ | ||||
| --============================== | ||||
| --========================================================== | ||||
| LazyJ's Fork of Splizard's "Snow Biomes" Mod | ||||
| by LazyJ | ||||
| version: Umpteen-hundred and 7/5ths something or another. | ||||
| 2014_04_12 | ||||
|  | ||||
| ~~~ | ||||
|  | ||||
| "Snow Biomes" Mod | ||||
| By Splizard | ||||
|  | ||||
| Download: | ||||
| http//forum.minetest.net/viewtopic.php?id=2290 | ||||
| http://github.com/Splizard/minetest-mod-snow/ | ||||
|  | ||||
| --========================================================== | ||||
| --============================== | ||||
|  | ||||
|    Snow Biomes | ||||
|  | ||||
|    This program is free software; you can redistribute it and/or modify | ||||
|    it under the terms of the GNU General Public License as published by | ||||
|    the Free Software Foundation; either version 2 of the License, or | ||||
|    (at your option) any later version. | ||||
|     | ||||
|  | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|    but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|    GNU General Public License for more details. | ||||
|     | ||||
|  | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software | ||||
|    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||||
|    MA 02110-1301, USA. | ||||
| ]]-- | ||||
|  | ||||
| snow = {} | ||||
| dofile(minetest.get_modpath("snow").."/mapgen.lua") | ||||
| dofile(minetest.get_modpath("snow").."/config.lua") | ||||
|  | ||||
| --Replace leaves so snow gets removed on decay. | ||||
| local leaves = {} | ||||
| for k,v in pairs(minetest.registered_nodes["default:leaves"]) do | ||||
| 	leaves[k] = v | ||||
| end | ||||
| leaves.after_destruct = function(pos, node, digger) | ||||
| 	pos.y = pos.y + 1 | ||||
| 	local nodename = minetest.env:get_node(pos).name | ||||
| 	if nodename == "snow:snow" then | ||||
| 		minetest.env:remove_node(pos) | ||||
|  | ||||
| -- Original Lua Files | ||||
| --dofile(modpath.."/util.lua") | ||||
| --dofile(modpath.."/mapgen.lua") | ||||
| --dofile(modpath.."/sled.lua") | ||||
| -- "falling_snow.lua" disabled since weather functions minetest.get_heat(pos) and minetest.get_humidity(pos) | ||||
| -- have been removed from Minetest. | ||||
| --  Until something else can be figured out, use paramat's "Snowdrift" mod instead. | ||||
| -- dofile(modpath.."/falling_snow.lua") | ||||
|  | ||||
| local load_time_start = minetest.get_us_time() | ||||
|  | ||||
|  | ||||
| -- Original init.lua File Broken into Smaller Files | ||||
| local srcpath = minetest.get_modpath("snow").."/src/" | ||||
| dofile(srcpath.."abms.lua") | ||||
| dofile(srcpath.."aliases.lua") | ||||
| dofile(srcpath.."crafting.lua") | ||||
|  | ||||
|  | ||||
| -- The formspec menu didn't work when util.lua was the very first "dofile" so I moved | ||||
| -- it and all the other original "dofiles", in order, to the bottom of the list. ~ LazyJ | ||||
| -- Minetest would crash if the mapgen was called upon before the rest of other snow lua files so | ||||
| -- I put it lower on the list and that seems to do the trick. ~ LazyJ | ||||
| dofile(srcpath.."util.lua") | ||||
| dofile(srcpath.."snowball.lua") | ||||
| -- To get Xmas tree saplings, the "christmas_content", true or false, in "util.lua" has to be determined first. | ||||
| -- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ | ||||
| dofile(srcpath.."nodes.lua") | ||||
| dofile(srcpath.."stairs.lua") | ||||
| dofile(srcpath.."mapgen.lua") | ||||
| dofile(srcpath.."sled.lua") | ||||
| dofile(srcpath.."falling_snow.lua") | ||||
|  | ||||
|  | ||||
| local is_uneven | ||||
| --This function places snow checking at the same time for snow level and increasing as needed. | ||||
| --This also takes into account sourrounding snow and makes snow even. | ||||
| function snow.place(pos, disablesound) | ||||
| 	local node = minetest.get_node_or_nil(pos) | ||||
|  | ||||
| 	--Oops, maybe there is no node? | ||||
| 	if not node | ||||
| 	or not minetest.registered_nodes[node.name] then | ||||
| 		return | ||||
| 	end | ||||
| end | ||||
| minetest.register_node(":default:leaves", leaves) | ||||
|  | ||||
| --Pine leaves. | ||||
| minetest.register_node("snow:needles", { | ||||
| 	description = "Pine Needles", | ||||
| 	drawtype = "allfaces_optional", | ||||
| 	visual_scale = 1.3, | ||||
| 	tiles = {"snow_needles.png"}, | ||||
| 	paramtype = "light", | ||||
| 	groups = {snappy=3, leafdecay=3, flammable=2}, | ||||
| 	drop = { | ||||
| 		max_items = 1, | ||||
| 		items = { | ||||
| 			{ | ||||
| 				-- player will get xmas tree with 1/50 chance | ||||
| 				items = {'snow:xmas_tree'}, | ||||
| 				rarity = 50, | ||||
| 			}, | ||||
| 			{ | ||||
| 				-- player will get sapling with 1/20 chance | ||||
| 				items = {'snow:sapling_pine'}, | ||||
| 				rarity = 20, | ||||
| 			}, | ||||
| 			{ | ||||
| 				-- player will get leaves only if he get no saplings, | ||||
| 				-- this is because max_items is 1 | ||||
| 				items = {'snow:needles'}, | ||||
| 			} | ||||
| 		} | ||||
| 	}, | ||||
| 	--Remove snow above leaves after decay. | ||||
| 	after_destruct = function(pos, node, digger) | ||||
| 		pos.y = pos.y + 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "snow:snow" then | ||||
| 			minetest.env:remove_node(pos) | ||||
| 		end | ||||
| 	end, | ||||
| 	sounds = default.node_sound_leaves_defaults(), | ||||
| }) | ||||
|  | ||||
| --Decorated Pine leaves. | ||||
| minetest.register_node("snow:needles_decorated", { | ||||
| 	description = "Decorated Pine Needles", | ||||
| 	drawtype = "allfaces_optional", | ||||
| 	tiles = {"snow_needles_decorated.png"}, | ||||
| 	paramtype = "light", | ||||
| 	groups = {snappy=3, leafdecay=3, flammable=2}, | ||||
| 		drop = { | ||||
| 		max_items = 1, | ||||
| 		items = { | ||||
| 			{ | ||||
| 				-- player will get xmas tree with 1/20 chance | ||||
| 				items = {'snow:xmas_tree'}, | ||||
| 				rarity = 50, | ||||
| 			}, | ||||
| 			{ | ||||
| 				-- player will get sapling with 1/20 chance | ||||
| 				items = {'snow:sapling_pine'}, | ||||
| 				rarity = 20, | ||||
| 			}, | ||||
| 			{ | ||||
| 				-- player will get leaves only if he get no saplings, | ||||
| 				-- this is because max_items is 1 | ||||
| 				items = {'snow:needles_decorated'}, | ||||
| 			} | ||||
| 		} | ||||
| 	}, | ||||
| 	--Remove snow above leaves after decay. | ||||
| 	after_destruct = function(pos, node, digger) | ||||
| 		pos.y = pos.y + 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "snow:snow" then | ||||
| 			minetest.env:remove_node(pos) | ||||
| 		end | ||||
| 	end, | ||||
| 	sounds = default.node_sound_leaves_defaults(), | ||||
| }) | ||||
|  | ||||
| minetest.register_node("snow:xmas_tree", { | ||||
| 	description = "Christmas Tree", | ||||
| 	drawtype = "plantlike", | ||||
| 	visual_scale = 1.0, | ||||
| 	tiles = {"snow_xmas_tree.png"}, | ||||
| 	inventory_image = "snow_xmas_tree.png", | ||||
| 	wield_image = "snow_xmas_tree.png", | ||||
| 	paramtype = "light", | ||||
| 	walkable = false, | ||||
| 	groups = {snappy=2,dig_immediate=3,flammable=2}, | ||||
| 	sounds = default.node_sound_defaults(), | ||||
| }) | ||||
|  | ||||
| minetest.register_node("snow:sapling_pine", { | ||||
| 	description = "Pine Sapling", | ||||
| 	drawtype = "plantlike", | ||||
| 	visual_scale = 1.0, | ||||
| 	tiles = {"snow_sapling_pine.png"}, | ||||
| 	inventory_image = "snow_sapling_pine.png", | ||||
| 	wield_image = "snow_sapling_pine.png", | ||||
| 	paramtype = "light", | ||||
| 	walkable = false, | ||||
| 	groups = {snappy=2,dig_immediate=3,flammable=2}, | ||||
| 	sounds = default.node_sound_defaults(), | ||||
| }) | ||||
|  | ||||
| minetest.register_node("snow:star", { | ||||
| 	description = "Star", | ||||
| 	drawtype = "torchlike", | ||||
| 	tiles = {"snow_star.png"}, | ||||
| 	inventory_image = "snow_star.png", | ||||
| 	wield_image = "snow_star.png", | ||||
| 	paramtype = "light", | ||||
| 	walkable = false, | ||||
| 	groups = {snappy=2,dig_immediate=3}, | ||||
| 	sounds = default.node_sound_defaults(), | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "fuel", | ||||
| 	recipe = "snow:needles", | ||||
| 	burntime = 1, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "fuel", | ||||
| 	recipe = "snow:sapling_pine", | ||||
| 	burntime = 10, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "fuel", | ||||
| 	recipe = "snow:needles_decorated", | ||||
| 	burntime = 1, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "fuel", | ||||
| 	recipe = "snow:xmas_tree", | ||||
| 	burntime = 10, | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
| --Snowballs | ||||
| ------------- | ||||
| snowball_GRAVITY=9 | ||||
| snowball_VELOCITY=19 | ||||
|  | ||||
| --Shoot snowball. | ||||
| local snow_shoot_snowball=function (item, player, pointed_thing) | ||||
| 	local playerpos=player:getpos() | ||||
| 	local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "snow:snowball_entity") | ||||
| 	local dir=player:get_look_dir() | ||||
| 	obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY}) | ||||
| 	obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3}) | ||||
| 	item:take_item() | ||||
| 	return item | ||||
| end | ||||
|  | ||||
| --The snowball Entity | ||||
| snow_snowball_ENTITY={ | ||||
| 	physical = false, | ||||
| 	timer=0, | ||||
| 	textures = {"snow_snowball.png"}, | ||||
| 	lastpos={}, | ||||
| 	collisionbox = {0,0,0,0,0,0}, | ||||
| } | ||||
|  | ||||
| --Snowball_entity.on_step()--> called when snowball is moving. | ||||
| snow_snowball_ENTITY.on_step = function(self, dtime) | ||||
| 	self.timer=self.timer+dtime | ||||
| 	local pos = self.object:getpos() | ||||
| 	local node = minetest.env:get_node(pos) | ||||
|  | ||||
| 	--Become item when hitting a node. | ||||
| 	if self.lastpos.x~=nil then --If there is no lastpos for some reason. | ||||
| 		if node.name ~= "air" then | ||||
| 			minetest.env:place_node(self.lastpos,{name="snow:snow"}) | ||||
| 			self.object:remove() | ||||
| 		end | ||||
| 	end | ||||
| 	self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node | ||||
| end | ||||
|  | ||||
| minetest.register_entity("snow:snowball_entity", snow_snowball_ENTITY) | ||||
|  | ||||
| --Snowball. | ||||
| minetest.register_craftitem("snow:snowball", { | ||||
| 	description = "Snowball", | ||||
| 	inventory_image = "snow_snowball.png", | ||||
| 	on_use = snow_shoot_snowball, | ||||
| }) | ||||
|  | ||||
| --Snow. | ||||
| minetest.register_node("snow:snow", { | ||||
| 	description = "Snow", | ||||
| 	tiles = {"snow_snow.png"}, | ||||
| 	drawtype = "nodebox", | ||||
| 	sunlight_propagates = true, | ||||
| 	paramtype = "light", | ||||
| 	param2 = nil, | ||||
| 	--param2 is reserved for what vegetation is hiding inside. | ||||
| 	--mapgen defines the vegetation. | ||||
| 	--1 = Moss | ||||
| 	groups = {crumbly=3,melts=3}, | ||||
| 	buildable_to = true, | ||||
| 	drop = 'snow:snowball', | ||||
| 	node_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { | ||||
| 			{-0.5, -0.5, -0.5, 0.5, -0.35, 0.5} | ||||
| 		}, | ||||
| 	}, | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = { | ||||
| 			{-0.5, -0.5, -0.5, 0.5, -0.35, 0.5} | ||||
| 		}, | ||||
| 	}, | ||||
| 	sounds = default.node_sound_dirt_defaults({ | ||||
| 		footstep = {name="default_gravel_footstep", gain=0.45}, | ||||
| 	}), | ||||
| 	--Update dirt node underneath snow. | ||||
| 	after_destruct = function(pos, node, digger) | ||||
| 		if node.param2 == 1 then | ||||
| 			local n = minetest.env:get_node(pos).name | ||||
| 			if  n == "air" or n == "default:water_flowing" or n == "default:water_source" then | ||||
| 				minetest.env:add_node(pos,{name="snow:moss",param2=1}) | ||||
| 	if node.name == "default:snow" then | ||||
| 		local level = minetest.get_node_level(pos) | ||||
| 		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 | ||||
| 			and not is_uneven(pos) then | ||||
| 				if not disablesound then | ||||
| 				minetest.sound_play("default_snow_footstep", {pos=pos}) | ||||
| 				end | ||||
| 				minetest.add_node_level(pos, 7) | ||||
| 			end | ||||
| 		elseif level == 63 then | ||||
| 			local p = minetest.find_node_near(pos, 10, "default:dirt_with_grass") | ||||
| 			if p | ||||
| 			and minetest.get_node_light(p, 0.5) == 15 then | ||||
| 				if not disablesound then | ||||
| 				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"}) | ||||
| 			else | ||||
| 				if not disablesound then | ||||
| 				minetest.sound_play("default_snow_footstep", {pos=pos}) | ||||
| 				end | ||||
| 				minetest.add_node(pos, {name="default:snowblock"}) | ||||
| 			end | ||||
| 		end | ||||
| 		pos.y = pos.y - 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "snow:dirt_with_snow" then | ||||
| 			minetest.env:add_node(pos,{name="default:dirt_with_grass"}) | ||||
| 		end | ||||
| 	end, | ||||
| 	on_construct = function(pos, newnode) | ||||
| 		pos.y = pos.y - 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "default:dirt_with_grass" then | ||||
| 			minetest.env:remove_node(pos) | ||||
| 			minetest.env:add_node(pos,{name="snow:dirt_with_snow"}) | ||||
| 		elseif nodename == "air" then | ||||
| 			pos.y = pos.y + 1 | ||||
| 			minetest.env:remove_node(pos) | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| --Snow with dirt. | ||||
| minetest.register_node("snow:dirt_with_snow", { | ||||
| 	description = "Dirt with Snow", | ||||
| 	tiles = {"snow_snow.png", "default_dirt.png", "default_dirt.png^snow_snow_side.png"}, | ||||
| 	is_ground_content = true, | ||||
| 	groups = {crumbly=3}, | ||||
| 	drop = 'default:dirt', | ||||
| 	sounds = default.node_sound_dirt_defaults({ | ||||
| 		footstep = {name="default_grass_footstep", gain=0.4}, | ||||
| 	}), | ||||
| 	--Place snow above this node when placed. | ||||
| 	after_place_node = function(pos, newnode) | ||||
| 		pos.y = pos.y + 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "air" then | ||||
| 			minetest.env:add_node(pos,{name="snow:snow"}) | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| --Gets rid of snow when the node underneath is dug. | ||||
| local unsnowify = function(pos, node, digger) | ||||
| 	if node.name == "default:dry_shrub" then | ||||
| 		pos.y = pos.y - 1 | ||||
| 		local nodename = minetest.env:get_node(pos).name | ||||
| 		if nodename == "snow:dirt_with_snow" then | ||||
| 			minetest.env:add_node(pos,{name="default:dirt_with_grass"}) | ||||
| 		end | ||||
| 		pos.y = pos.y + 1 | ||||
| 	end | ||||
| 	pos.y = pos.y + 1 | ||||
| 	local nodename = minetest.env:get_node(pos).name | ||||
| 	if nodename == "snow:snow" then | ||||
| 		minetest.env:remove_node(pos) | ||||
| 		local obj=minetest.env:add_entity({x=pos.x,y=pos.y,z=pos.z}, "snow:snowball_entity") | ||||
| 		obj:setacceleration({x=0, y=-snowball_GRAVITY, z=0}) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| minetest.register_on_dignode(unsnowify) | ||||
|  | ||||
| --Snow block. | ||||
| minetest.register_node("snow:snow_block", { | ||||
| 	description = "Snow", | ||||
| 	tiles = {"snow_snow.png"}, | ||||
| 	--param2 is reserved for what vegetation is hiding inside. | ||||
| 	--mapgen defines the vegetation. | ||||
| 	--1 = Moss | ||||
| 	--2 = Papyrus | ||||
| 	--3 = Dry shrub | ||||
| 	is_ground_content = true, | ||||
| 	groups = {crumbly=3,melts=2,falling_node=1}, | ||||
| 	drop = 'snow:snow_block', | ||||
| 	sounds = default.node_sound_dirt_defaults({ | ||||
| 		footstep = {name="default_grass_footstep", gain=0.4}, | ||||
| 	}), | ||||
| 	--Update dirt node underneath snow. | ||||
| 	after_destruct = function(pos, node, digger) | ||||
| 		if node.param2 == 1 then | ||||
| 			local n = minetest.env:get_node(pos).name | ||||
| 			if  n == "air" or n == "default:water_flowing" or n == "default:water_source" then | ||||
| 				minetest.env:add_node(pos,{name="snow:moss",param2=1}) | ||||
| 			end | ||||
| 		elseif node.param2 == 2 then | ||||
| 			local n = minetest.env:get_node(pos).name | ||||
| 			if  n == "air" or n == "default:water_flowing" or n == "default:water_source" then | ||||
| 				minetest.env:add_node(pos,{name="default:papyrus"}) | ||||
| 				pos.y = pos.y + 1  | ||||
| 				local n =  minetest.env:get_node(pos) | ||||
| 				if n.name == "snow:snow_block" and n.param2 == 2 then | ||||
| 					minetest.env:remove_node(pos) | ||||
| 					pos.y = pos.y - 1  | ||||
| 					minetest.env:add_node(pos,{name="snow:snow_block",param2=2}) | ||||
| 	elseif node.name ~= "default:ice" | ||||
| 	and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "air" then | ||||
| 		local data = minetest.registered_nodes[node.name] | ||||
| 		local drawtype = data.drawtype | ||||
| 		if drawtype == "normal" | ||||
| 		or drawtype == "allfaces_optional" then | ||||
| 			pos.y = pos.y+1 | ||||
| 			local sound = data.sounds | ||||
| 			if sound and not disablesound then | ||||
| 				sound = sound.footstep | ||||
| 				if sound then | ||||
| 					minetest.sound_play(sound.name, {pos=pos, gain=sound.gain}) | ||||
| 				end | ||||
| 			end | ||||
| 		elseif node.param2 == 3 then | ||||
| 			local n = minetest.env:get_node(pos).name | ||||
| 			if  n == "air" or n == "default:water_flowing" or n == "default:water_source" then | ||||
| 				minetest.env:add_node(pos,{name="default:dry_shrub"}) | ||||
| 			minetest.place_node(pos, {name="default:snow"}) | ||||
| 		elseif drawtype == "plantlike" then | ||||
| 			pos.y = pos.y - 1 | ||||
| 			if minetest.get_node(pos).name == "default:dirt_with_grass" then | ||||
| 				minetest.sound_play("default_grass_footstep", {pos=pos}) | ||||
| 				minetest.add_node(pos, {name="default:dirt_with_snow"}) | ||||
| 			end | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| --Snow brick. | ||||
| minetest.register_node("snow:snow_brick", { | ||||
| 	description = "Snow Brick", | ||||
| 	tiles = {"snow_snow_brick.png"}, | ||||
| 	is_ground_content = true, | ||||
| 	groups = {crumbly=3,melts=2}, | ||||
| 	drop = 'snow:snow_brick', | ||||
| 	sounds = default.node_sound_dirt_defaults({ | ||||
| 		footstep = {name="default_grass_footstep", gain=0.4}, | ||||
| 	}), | ||||
| }) | ||||
|  | ||||
| --Ice. | ||||
| minetest.register_node("snow:ice", { | ||||
| 	description = "Ice", | ||||
| 	tiles = {"snow_ice.png"}, | ||||
| 	is_ground_content = true, | ||||
| 	groups = {snappy=2,cracky=3,melts=1}, | ||||
| 	drop = 'snow:ice', | ||||
| 	paramtype = "light", | ||||
| 	sunlight_propagates = true, | ||||
| 	sounds = default.node_sound_glass_defaults({ | ||||
| 		footstep = {name="default_stone_footstep", gain=0.4}, | ||||
| 	}), | ||||
| }) | ||||
|  | ||||
| --Moss. | ||||
| minetest.register_node("snow:moss", { | ||||
| 	description = "Moss", | ||||
| 	tiles = {"snow_moss.png"}, | ||||
| 	drawtype = "signlike", | ||||
| 	paramtype = "light", | ||||
| 	paramtype2 = "wallmounted", | ||||
| 	walkable = false, | ||||
| 	selection_box = { | ||||
| 		type = "wallmounted", | ||||
| 	}, | ||||
| 	is_ground_content = true, | ||||
| 	groups = {crumbly=3, flammable=2, attached_node=1}, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
|     output = 'snow:snow_block', | ||||
|     recipe = { | ||||
|         {'snow:snowball', 'snow:snowball'}, | ||||
|         {'snow:snowball', 'snow:snowball'}, | ||||
|     }, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
|     output = 'snow:snow_brick', | ||||
|     recipe = { | ||||
|         {'snow:snow_block', 'snow:snow_block'}, | ||||
|         {'snow:snow_block', 'snow:snow_block'}, | ||||
|     }, | ||||
| }) | ||||
|  | ||||
| --Melting | ||||
| --Any node part of the group melting will melt when near warm nodes such as lava, fire, torches, etc. | ||||
| --The amount of water that replaces the node is defined by the number on the group: | ||||
| --1: one water_source | ||||
| --2: four water_flowings | ||||
| --3: one water_flowing | ||||
| minetest.register_abm({ | ||||
|     nodenames = {"group:melts"}, | ||||
|     neighbors = {"group:igniter","default:torch","default:furnace_active","group:hot"}, | ||||
|     interval = 2, | ||||
|     chance = 2, | ||||
|     action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 		local intensity = minetest.get_item_group(node.name,"melts") | ||||
| 		if intensity == 1 then | ||||
| 			minetest.env:add_node(pos,{name="default:water_source"}) | ||||
| 		elseif intensity == 2 then | ||||
| 			local check_place = function(pos,node) | ||||
| 				if minetest.env:get_node(pos).name == "air" then | ||||
| 					minetest.env:place_node(pos,node) | ||||
| 				end | ||||
| 			end | ||||
| 			minetest.env:add_node(pos,{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x+1,y=pos.y,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x-1,y=pos.y,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x,y=pos.y+1,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x,y=pos.y-1,z=pos.z},{name="default:water_flowing"}) | ||||
| 		elseif intensity == 3 then | ||||
| 			minetest.env:add_node(pos,{name="default:water_flowing"}) | ||||
| 		end | ||||
| 		nodeupdate(pos) | ||||
|     end, | ||||
| }) | ||||
|  | ||||
| --Freezing | ||||
| --Water freezes when in contact with snow. | ||||
| minetest.register_abm({ | ||||
|     nodenames = {"default:water_source"}, | ||||
|     neighbors = {"snow:snow", "snow:snow_block"}, | ||||
|     interval = 20, | ||||
|     chance = 4, | ||||
|     action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 		minetest.env:add_node(pos,{name="snow:ice"}) | ||||
|     end, | ||||
| }) | ||||
|  | ||||
| --Spread moss to cobble. | ||||
| minetest.register_abm({ | ||||
|     nodenames = {"default:cobble"}, | ||||
|     neighbors = {"snow:moss"}, | ||||
|     interval = 20, | ||||
|     chance = 6, | ||||
|     action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 		minetest.env:add_node(pos,{name="default:mossycobble"}) | ||||
|     end, | ||||
| }) | ||||
|  | ||||
| --Grow saplings | ||||
| minetest.register_abm({ | ||||
|     nodenames = {"snow:sapling_pine"}, | ||||
|     interval = 10, | ||||
|     chance = 50, | ||||
|     action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 		snow.make_pine(pos,false) | ||||
|     end, | ||||
| }) | ||||
|  | ||||
| --Grow saplings | ||||
| minetest.register_abm({ | ||||
|     nodenames = {"snow:xmas_tree"}, | ||||
|     interval = 10, | ||||
|     chance = 50, | ||||
|     action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 		snow.make_pine(pos,false,true) | ||||
|     end, | ||||
| }) | ||||
|  | ||||
| if snow.enable_snowfall then | ||||
|  | ||||
| 	--Snowing | ||||
| 	snow_fall=function (pos) | ||||
| 		local obj=minetest.env:add_entity(pos, "snow:fall_entity") | ||||
| 		obj:setvelocity({x=0, y=-1, z=0}) | ||||
| 	end | ||||
|  | ||||
| 	-- The snowfall Entity | ||||
| 	snow_fall_ENTITY={ | ||||
| 		physical = true, | ||||
| 		timer=0, | ||||
| 		textures = {"snow_snowfall.png"}, | ||||
| 		lastpos={}, | ||||
| 		collisionbox = {0,0,0,0,0,0}, | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	-- snowfall_entity.on_step()--> called when snow is falling | ||||
| 	snow_fall_ENTITY.on_step = function(self, dtime) | ||||
| 		self.timer=self.timer+dtime | ||||
| 		local pos = self.object:getpos() | ||||
| 		local node = minetest.env:get_node(pos) | ||||
|  | ||||
| 		if self.lastpos and self.object:getvelocity().y == 0 then | ||||
| 			if minetest.env:get_node({x=self.lastpos.x,z=self.lastpos.z,y=self.lastpos.y}).name == "snow:moss" then | ||||
| 				minetest.env:add_node({x=self.lastpos.x,z=self.lastpos.z,y=self.lastpos.y},{name="snow:snow",param2=1}) | ||||
| 				self.object:remove() | ||||
| 				return | ||||
| 			end | ||||
| 			minetest.env:place_node(self.lastpos,{name="snow:snow"}) | ||||
| 			self.object:remove() | ||||
| 		end | ||||
| 		 | ||||
| 		if self.timer > 120 then | ||||
| 			self.object:remove() | ||||
| 		end | ||||
|  | ||||
| 		self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node | ||||
| 	end | ||||
|  | ||||
| 	minetest.register_entity("snow:fall_entity", snow_fall_ENTITY) | ||||
|  | ||||
| 	--Regenerate Snow | ||||
| 	minetest.register_abm({ | ||||
| 		nodenames = {"default:dirt_with_grass", "snow:moss"}, | ||||
| 		interval = 50, | ||||
| 		chance = 150, | ||||
| 		action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 			--Check we are in the right biome | ||||
| 			local env = minetest.env | ||||
| 			local perlin1 = env:get_perlin(112,3, 0.5, 150) | ||||
| 			local test = perlin1:get2d({x=pos.x, y=pos.z}) | ||||
| 			local in_biome = false | ||||
| 			local smooth = snow.smooth | ||||
| 			if smooth and (test > 0.73 or (test > 0.43 and math.random(0,29) > (0.73 - test) * 100 )) then | ||||
| 				in_biome = true | ||||
| 			elseif not smooth and test > 0.53 then | ||||
| 				in_biome = true | ||||
| 			end | ||||
| 			if in_biome then | ||||
| 				--Check if block is under cover | ||||
| 				local ground_y = nil | ||||
| 				for y=15,0,-1 do | ||||
| 					if env:get_node({x=pos.x,y=y+pos.y,z=pos.z}).name ~= "air" then | ||||
| 						ground_y = pos.y+y | ||||
| 						break | ||||
| 					end | ||||
| 				end | ||||
| 				if ground_y then | ||||
| 					local n = env:get_node({x=pos.x,y=ground_y,z=pos.z}) | ||||
| 					if (n.name ~= "snow:snow" and n.name ~= "snow:snow_block" and n.name ~= "snow:ice" and n.name ~= "default:water_source" and n.name ~= "default:papyrus") then | ||||
| 						local obj = minetest.env:get_objects_inside_radius({x=pos.x,y=ground_y+20,z=pos.z}, 15) | ||||
| 						for i,v in pairs(obj) do | ||||
| 							e = v:get_luaentity() | ||||
| 							if e ~= nil and e.name == "snow:fall_entity" then  | ||||
| 								return | ||||
| 							end | ||||
| 						end | ||||
| 						snow_fall({x=pos.x,y=ground_y+15,z=pos.z}) | ||||
| 						if snow.debug then | ||||
| 							print("snowfall at x"..pos.x.." y"..pos.z) | ||||
| 						end | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 	}) | ||||
| end | ||||
|  | ||||
| -- Checks if the snow level is even at any given pos. | ||||
| -- Smooth Snow | ||||
| local function uneven(pos) | ||||
| 	local num = minetest.get_node_level(pos) | ||||
| 	local get_node = minetest.get_node | ||||
| 	local add_node = minetest.add_node | ||||
| 	local foundx | ||||
| 	local foundz | ||||
| 	for z = -1,1 do | ||||
| 		for x = -1,1 do | ||||
| 			local p = {x=pos.x+x, y=pos.y, z=pos.z+z} | ||||
| 			local node = get_node(p) | ||||
| 			p.y = p.y-1 | ||||
| 			local bnode = get_node(p) | ||||
|  | ||||
| 			if node | ||||
| 			and minetest.registered_nodes[node.name] | ||||
| 			and minetest.registered_nodes[node.name].drawtype == "plantlike" | ||||
| 			and bnode.name == "default:dirt_with_grass" then | ||||
| 				add_node(p, {name="default:dirt_with_snow"}) | ||||
| 				return true | ||||
| 			end | ||||
|  | ||||
| 			p.y = p.y+1 | ||||
| 			if not (x == 0 and z == 0) | ||||
| 			and node.name == "default:snow" | ||||
| 			and minetest.get_node_level(p) < num then | ||||
| 				foundx = x | ||||
| 				foundz = z | ||||
| 			elseif node.name == "air" | ||||
| 			and bnode.name ~= "air" | ||||
| 			and bnode.name ~= "default:snow" then | ||||
| 				p.y = p.y-1 | ||||
| 				snow.place(p) | ||||
| 				return true | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| 	if foundx then | ||||
| 		local p = {x=pos.x+foundx, y=pos.y, z=pos.z+foundz} | ||||
| 		if not is_uneven(p) then | ||||
| 			minetest.add_node_level(p, 7) | ||||
| 		end | ||||
| 		return true | ||||
| 	end | ||||
| end | ||||
|  | ||||
| if snow.smooth_snow then | ||||
| 	is_uneven = uneven | ||||
| else | ||||
| 	is_uneven = function() end | ||||
| end | ||||
|  | ||||
| snow.register_on_configuring(function(name, v) | ||||
| 	if name == "smooth_snow" then | ||||
| 		if v then | ||||
| 			is_uneven = uneven | ||||
| 		else | ||||
| 			is_uneven = function() 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("action", msg) | ||||
| end | ||||
|   | ||||
							
								
								
									
										37
									
								
								license.txt
									
									
									
									
									
								
							
							
						
						| @@ -1,3 +1,40 @@ | ||||
| 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 | ||||
|                        Version 3, 29 June 2007 | ||||
|  | ||||
|   | ||||
							
								
								
									
										303
									
								
								mapgen.lua
									
									
									
									
									
								
							
							
						
						| @@ -1,303 +0,0 @@ | ||||
| local pine_tree = { | ||||
| 	axiom="TABff", | ||||
| 	rules_a="[&T+f+ff+ff+ff+f]GA", | ||||
| 	rules_b="[&T+f+Gf+Gf+Gf]GB", | ||||
| 	trunk="default:tree", | ||||
| 	leaves="snow:needles", | ||||
| 	angle=90, | ||||
| 	iterations=1, | ||||
| 	random_level=0, | ||||
| 	trunk_type="single", | ||||
| 	thin_branches=true, | ||||
| } | ||||
| local xmas_tree = { | ||||
| 	axiom="TABff", | ||||
| 	rules_a="[&T+f+ff+ff+ff+f]GA", | ||||
| 	rules_b="[&T+f+Gf+Gf+Gf]GB", | ||||
| 	trunk="default:tree", | ||||
| 	leaves="snow:needles_decorated", | ||||
| 	angle=90, | ||||
| 	iterations=1, | ||||
| 	random_level=0, | ||||
| 	trunk_type="single", | ||||
| 	thin_branches=true, | ||||
| } | ||||
|  | ||||
| --Makes pine tree | ||||
| function snow.make_pine(pos,snow,xmas) | ||||
| 	local env = minetest.env | ||||
| 	local perlin1 = env:get_perlin(112,3, 0.5, 150) | ||||
| 	local try_node = function(pos, node) | ||||
| 		local n = env:get_node(pos).name | ||||
| 		if n == "air" or n == "ignore" then | ||||
| 			env:add_node(pos,node) | ||||
| 		end | ||||
| 	end | ||||
| 	--Clear ground. | ||||
| 	for x=-1,1 do | ||||
| 	for z=-1,1 do | ||||
| 		if env:get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "snow:snow" then | ||||
| 			env:remove_node({x=pos.x+x,y=pos.y,z=pos.z+z}) | ||||
| 		end | ||||
| 		if env:get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "snow:snow_block" then | ||||
| 			env:remove_node({x=pos.x+x,y=pos.y,z=pos.z+z}) | ||||
| 		end | ||||
| 	end | ||||
| 	end | ||||
| 	if xmas then | ||||
| 		env:remove_node(pos) | ||||
| 		minetest.env:spawn_tree(pos, xmas_tree) | ||||
| 	else | ||||
| 		minetest.env:spawn_tree(pos, pine_tree) | ||||
| 	end | ||||
| 	if snow then | ||||
| 		local x,z = pos.x,pos.z | ||||
| 		try_node({x=x+1,y=pos.y+3,z=z+1},{name="snow:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+3,z=z-1},{name="snow:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+3,z=z+1},{name="snow:snow"}) | ||||
| 		try_node({x=x+1,y=pos.y+3,z=z-1},{name="snow:snow"}) | ||||
| 		 | ||||
| 		try_node({x=x+1,y=pos.y+5,z=z},{name="snow:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+5,z=z},{name="snow:snow"}) | ||||
| 		try_node({x=x,y=pos.y+5,z=z+1},{name="snow:snow"}) | ||||
| 		try_node({x=x,y=pos.y+5,z=z-1},{name="snow:snow"}) | ||||
| 	end | ||||
| 	if xmas then | ||||
| 		try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star"}) | ||||
| 	elseif snow and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then | ||||
| 		try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:snow"}) | ||||
| 	end | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| --Snow biomes are found at 0.53 and greater perlin noise. | ||||
| minetest.register_on_generated(function(minp, maxp, seed) | ||||
| if maxp.y >= -10 then | ||||
| 		local debug = snow.debug | ||||
|  | ||||
| 		--Should make things a bit faster. | ||||
| 		local env = minetest.env | ||||
|  | ||||
| 		--Get map specific perlin | ||||
| 		local perlin1 = env:get_perlin(112,3, 0.5, 150) | ||||
|  | ||||
| 		-- Assume X and Z lengths are equal | ||||
| 		local divlen = 16 | ||||
| 		local divs = (maxp.x-minp.x); | ||||
| 		local x0 = minp.x | ||||
| 		local z0 = minp.z | ||||
| 		local x1 = maxp.x | ||||
| 		local z1 = maxp.z | ||||
|  | ||||
| 		--Speed hack: checks the corners and middle of the chunk for "snow biome". | ||||
| 		if not ( perlin1:get2d( {x=x0, y=z0} ) > 0.53 ) 					--top left | ||||
| 		and not ( perlin1:get2d( { x = x0 + ( (x1-x0)/2), y=z0 } ) > 0.53 )--top middle | ||||
| 		and not (perlin1:get2d({x=x1, y=z1}) > 0.53) 						--bottom right | ||||
| 		and not (perlin1:get2d({x=x1, y=z0+((z1-z0)/2)}) > 0.53) 			--right middle | ||||
| 		and not (perlin1:get2d({x=x0, y=z1}) > 0.53)  						--bottom left | ||||
| 		and not (perlin1:get2d({x=x1, y=z0}) > 0.53)						--top right | ||||
| 		and not (perlin1:get2d({x=x0+((x1-x0)/2), y=z1}) > 0.53) 			--left middle | ||||
| 		and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > 0.53) 			--middle | ||||
| 		and not (perlin1:get2d({x=x0, y=z1+((z1-z0)/2)}) > 0.53) then		--bottom middle | ||||
| 			return | ||||
| 		end | ||||
|  | ||||
| 		--Choose a biome types. | ||||
| 		local pr = PseudoRandom(seed+57) | ||||
| 		local biome | ||||
|  | ||||
| 		--Land biomes | ||||
| 		biome = pr:next(1, 5) | ||||
| 		local snowy = biome == 1 --spawns alot of snow | ||||
| 		local plain = biome == 2 --spawns not much | ||||
| 		local alpine = biome == 3 --rocky terrain | ||||
| 		-- biome == 4 or biome == 5 -- normal biome | ||||
|  | ||||
| 		--Water biomes | ||||
| 		biome2 = pr:next(1, 5) | ||||
| 		local cool = biome == 1  --only spawns ice on edge of water | ||||
| 		local icebergs = biome == 2 | ||||
| 		local icesheet = biome == 3 | ||||
| 		local icecave = biome == 4 | ||||
| 		local icehole = biome == 5 --icesheet with holes | ||||
|  | ||||
| 		--Misc biome settings. | ||||
| 		local icy = pr:next(1, 2) == 2   --If enabled spawns ice in sand instead of snow blocks. | ||||
| 		local mossy = pr:next(1,2) == 1  --Spawns moss in snow. | ||||
| 		local shrubs = pr:next(1,2) == 1 --Spawns dry shrubs in snow. | ||||
| 		local pines = pr:next(1,2) == 1 --spawns pines. | ||||
|  | ||||
| 		--Debugging function | ||||
| 		local biomeToString = function(num,num2) | ||||
| 			local biome, biome2 | ||||
| 			if num == 1 then biome = "snowy" | ||||
| 			elseif num == 2 then biome = "plain" | ||||
| 			elseif num == 3 then biome = "alpine" | ||||
| 			elseif num == 4 or num == 5 then biome = "normal" | ||||
| 			else biome =  "unknown "..num end | ||||
|  | ||||
| 			if num2 == 1 then biome2 = "cool" | ||||
| 			elseif num2 == 2 then biome2 = "icebergs" | ||||
| 			elseif num2 == 3 then biome2 = "icesheet" | ||||
| 			elseif num2 == 4 then biome2 = "icecave" | ||||
| 			elseif num2 == 5 then biome2 = "icehole" | ||||
| 			else biome2 =  "unknown "..num end | ||||
|  | ||||
| 			return biome, biome2 | ||||
| 		end | ||||
|  | ||||
| 		local make_pine = snow.make_pine | ||||
| 		local smooth = snow.smooth | ||||
|  | ||||
| 		--Reseed random. | ||||
| 		pr = PseudoRandom(seed+68) | ||||
|  | ||||
| 		if alpine then | ||||
| 			local trees = env:find_nodes_in_area(minp, maxp, {"default:leaves","default:tree"}) | ||||
| 			for i,v in pairs(trees) do | ||||
| 				env:remove_node(v) | ||||
| 			end | ||||
| 		end | ||||
|  | ||||
| 		--Loop through chunk. | ||||
| 		for j=0,divs do | ||||
| 		for i=0,divs do | ||||
|  | ||||
| 			local x = x0+i | ||||
| 			local z = z0+j | ||||
|  | ||||
| 				--Check if we are in a "Snow biome" | ||||
|                 local in_biome = false | ||||
|                 local test = perlin1:get2d({x=x, y=z}) | ||||
|                 if smooth and (not snowy) and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then | ||||
|                     in_biome = true | ||||
|                 elseif (not smooth or snowy) and test > 0.53 then | ||||
| 					in_biome = true | ||||
|                 end | ||||
|  | ||||
|                 if in_biome then | ||||
|  | ||||
|                 if not plain or pr:next(1,12) == 1 then | ||||
|  | ||||
| 					 -- Find ground level (0...15) | ||||
| 					local ground_y = nil | ||||
| 					for y=maxp.y,minp.y+1,-1 do | ||||
| 						if env:get_node({x=x,y=y,z=z}).name ~= "air" then | ||||
| 							ground_y = y | ||||
| 							break | ||||
| 						end | ||||
| 					end | ||||
|  | ||||
| 					-- Snowy biome stuff | ||||
| 					local node = env:get_node({x=x,y=ground_y,z=z}) | ||||
|  | ||||
| 					if ground_y and (node.name == "default:dirt_with_grass" or node.name == "default:junglegrass") then | ||||
| 							local veg | ||||
| 							if mossy and pr:next(1,10) == 1 then veg = 1 end | ||||
| 							if alpine then | ||||
| 								--Gets rid of dirt | ||||
| 								env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow",param2=veg}) | ||||
| 								for y=ground_y,-6,-1 do | ||||
| 									if env:get_node({x=x,y=y,z=z}) and env:get_node({x=x,y=y,z=z}).name == "default:stone" then | ||||
| 										break | ||||
| 									else | ||||
| 										env:add_node({x=x,y=y,z=z},{name="default:stone"}) | ||||
| 									end | ||||
| 								end | ||||
| 							elseif (shrubs and pr:next(1,28) == 1) or node.name == "default:junglegrass" then | ||||
| 								--Spawns dry shrubs. | ||||
| 								env:add_node({x=x,y=ground_y,z=z}, {name="snow:dirt_with_snow"}) | ||||
| 								if snowy then | ||||
| 									env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow_block", param2=3}) | ||||
| 								else | ||||
| 									env:add_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"}) | ||||
| 								end | ||||
| 							elseif pines and pr:next(1,36) == 1 then | ||||
| 								--Spawns pines. | ||||
| 								env:add_node({x=x,y=ground_y,z=z}, {name="default:dirt_with_grass"}) | ||||
| 								make_pine({x=x,y=ground_y+1,z=z},true) | ||||
| 							elseif snowy then | ||||
| 								--Spawns snow blocks. | ||||
| 								env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow_block"}) | ||||
| 								env:add_node({x=x,y=ground_y+2,z=z}, {name="snow:snow",param2=veg}) | ||||
| 							else | ||||
| 								--Spawns snow. | ||||
| 								env:add_node({x=x,y=ground_y,z=z}, {name="snow:dirt_with_snow"}) | ||||
| 								env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow",param2=veg}) | ||||
| 							end | ||||
| 					elseif ground_y and node.name == "default:sand" then | ||||
| 						--Spawns ice in sand if icy, otherwise spawns snow on top. | ||||
| 						if not icy then | ||||
| 							env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"}) | ||||
| 							env:add_node({x=x,y=ground_y,z=z}, {name="snow:snow_block"}) | ||||
| 						else | ||||
| 							env:add_node({x=x,y=ground_y,z=z}, {name="snow:ice"}) | ||||
| 						end | ||||
| 					elseif ground_y and env:get_node({x=x,y=ground_y,z=z}).name == "default:leaves" then | ||||
| 						env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"}) | ||||
| 					elseif ground_y and env:get_node({x=x,y=ground_y,z=z}).name == "default:papyrus" then | ||||
| 						for i=ground_y, ground_y-4, -1 do | ||||
| 							if env:get_node({x=x,y=i,z=z}).name == "default:papyrus" then | ||||
| 								env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"}) | ||||
| 								env:add_node({x=x,y=i,z=z}, {name="snow:snow_block", param2=2}) | ||||
| 							end | ||||
| 						end | ||||
| 					elseif ground_y and node.name == "default:water_source" then | ||||
| 						if not icesheet and not icecave and not icehole then | ||||
| 							--Coastal ice. | ||||
| 							local x1 = env:get_node({x=x+1,y=ground_y,z=z}).name | ||||
| 							local z1 = env:get_node({x=x,y=ground_y,z=z+1}).name | ||||
| 							local xz1 = env:get_node({x=x+1,y=ground_y,z=z+1}).name | ||||
| 							local xz2 = env:get_node({x=x-1,y=ground_y,z=z-1}).name | ||||
| 							local x2 = env:get_node({x=x-1,y=ground_y,z=z}).name | ||||
| 							local z2 = env:get_node({x=x,y=ground_y,z=z-1}).name | ||||
| 							local y = env:get_node({x=x,y=ground_y-1,z=z}).name | ||||
| 							local rand = pr:next(1,4) == 1 | ||||
| 							if | ||||
| 							((x1  and x1 ~= "default:water_source"  and x1 ~= "snow:ice"  and x1 ~= "air" and x1 ~= "ignore") or ((cool or icebergs) and x1 == "snow:ice"  and rand)) or | ||||
| 							((z1  and z1 ~= "default:water_source"  and z1 ~= "snow:ice"  and z1 ~= "air" and z1 ~= "ignore") or ((cool or icebergs) and z1 == "snow:ice"  and rand)) or | ||||
| 							((xz1 and xz1 ~= "default:water_source" and xz1 ~= "snow:ice" and xz1 ~= "air"and xz1 ~= "ignore") or ((cool or icebergs) and xz1 == "snow:ice" and rand)) or | ||||
| 							((xz2 and xz2 ~= "default:water_source" and xz2 ~= "snow:ice" and xz2 ~= "air"and xz2 ~= "ignore") or ((cool or icebergs) and xz2 == "snow:ice" and rand)) or | ||||
| 							((x2  and x2 ~= "default:water_source"  and x2 ~= "snow:ice"  and x2 ~= "air" and x2 ~= "ignore") or ((cool or icebergs) and x2 == "snow:ice"  and rand)) or | ||||
| 							((z2  and z2 ~= "default:water_source"  and z2 ~= "snow:ice"  and z2 ~= "air" and z2 ~= "ignore") or ((cool or icebergs) and z2 == "snow:ice"  and rand)) or | ||||
| 							(y ~= "default:water_source" and y ~= "snow:ice" and y ~= "air") or (pr:next(1,6) == 1 and icebergs) then | ||||
| 									env:add_node({x=x,y=ground_y,z=z}, {name="snow:ice"}) | ||||
| 							end | ||||
| 						else | ||||
| 							--Icesheets, Broken icesheet, Icecaves | ||||
| 							if (icehole and pr:next(1,10) > 1) or icecave or icesheet then | ||||
| 								env:add_node({x=x,y=ground_y,z=z}, {name="snow:ice"}) | ||||
| 							end | ||||
| 							if icecave then | ||||
| 								--Gets rid of water underneath ice | ||||
| 								for y=ground_y-1,-60,-1 do | ||||
| 									if env:get_node({x=x,y=y,z=z}) and env:get_node({x=x,y=y,z=z}).name ~= "default:water_source" then | ||||
| 										break | ||||
| 									else | ||||
| 										env:remove_node({x=x,y=y,z=z}) | ||||
| 									end | ||||
| 								end | ||||
| 							end | ||||
| 						end | ||||
| 					--~ elseif ground_y and node.name == "snow:snow" and node.name ~= "snow:ice" then | ||||
| 						--~ --Abort genaration. | ||||
| 						--~ local name = env:get_node({x=x,y=ground_y-1,z=z}).name | ||||
| 						--~ if name ~= "default:leaves" and name ~= "snow:needles" then | ||||
| 							--~ if debug then | ||||
| 								--~ print(biomeToString(biome)..": snow found ABORTED!") | ||||
| 							--~ end | ||||
| 							--~ return | ||||
| 						--~ end | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 		end | ||||
| 		if debug then | ||||
| 			biome_string,biome2_string = biomeToString(biome,biome2) | ||||
| 			print(biome_string.." and "..biome2_string..": Snow Biome Genarated near x"..minp.x.." z"..minp.z) | ||||
| 		end | ||||
| end | ||||
| end | ||||
| ) | ||||
							
								
								
									
										
											BIN
										
									
								
								models/sled.blend
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								models/sled.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 4.1 KiB | 
							
								
								
									
										369
									
								
								models/sled.x
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,369 @@ | ||||
| xof 0303txt 0032 | ||||
|  | ||||
| Frame Root { | ||||
|   FrameTransformMatrix { | ||||
|      1.000000, 0.000000, 0.000000, 0.000000, | ||||
|      0.000000, 0.000000, 1.000000, 0.000000, | ||||
|      0.000000, 1.000000,-0.000000, 0.000000, | ||||
|      0.000000, 0.000000, 0.000000, 1.000000;; | ||||
|   } | ||||
|   Frame Cube_001 { | ||||
|     FrameTransformMatrix { | ||||
|        0.000000, 0.149813, 0.000000, 0.000000, | ||||
|       -0.149813, 0.000000, 0.000000, 0.000000, | ||||
|        0.000000, 0.000000, 0.149813, 0.000000, | ||||
|        0.025244, 3.853863,-2.133818, 1.000000;; | ||||
|     } | ||||
|     Mesh { //Cube_003 Mesh | ||||
|       88; | ||||
|       -1.000000;53.554752;-1.000000;, | ||||
|       -1.000000;-53.189678;-1.000000;, | ||||
|        1.000000;-53.189678;-1.000000;, | ||||
|        1.000000;53.554752;-1.000000;, | ||||
|        0.999999;-53.189678;14.242604;, | ||||
|       -1.000000;-53.189678;14.242604;, | ||||
|       -1.000000;-53.189678;16.253036;, | ||||
|        0.999999;-53.189678;16.253036;, | ||||
|        1.000000;-53.189678;-1.000000;, | ||||
|        0.999999;-53.189678;14.242604;, | ||||
|        1.000000;53.554752;14.242604;, | ||||
|        1.000000;53.554752;-1.000000;, | ||||
|       -1.000000;-53.189678;-1.000000;, | ||||
|       -1.000000;-53.189678;14.242604;, | ||||
|        0.999999;-53.189678;14.242604;, | ||||
|        1.000000;-53.189678;-1.000000;, | ||||
|       -1.000000;53.554752;-1.000000;, | ||||
|       -1.000000;53.554752;14.242604;, | ||||
|       -1.000000;-53.189678;14.242604;, | ||||
|       -1.000000;-53.189678;-1.000000;, | ||||
|       -1.000000;53.554752;14.242604;, | ||||
|       -1.000000;53.554752;-1.000000;, | ||||
|        1.000000;53.554752;-1.000000;, | ||||
|        1.000000;53.554752;14.242604;, | ||||
|        0.999999;-53.189678;16.253036;, | ||||
|       -1.000000;-53.189678;16.253036;, | ||||
|       -1.000000;53.554752;16.253036;, | ||||
|        1.000000;53.554752;16.253036;, | ||||
|       -50.412270;53.554752;16.253036;, | ||||
|       -50.412270;53.554752;14.242604;, | ||||
|       -1.000000;53.554752;14.242604;, | ||||
|       -1.000000;53.554752;16.253036;, | ||||
|        1.000000;53.554752;14.242604;, | ||||
|        0.999999;-53.189678;14.242604;, | ||||
|        0.999999;-53.189678;16.253036;, | ||||
|        1.000000;53.554752;16.253036;, | ||||
|        1.000000;53.554752;16.253036;, | ||||
|       -1.000000;53.554752;16.253036;, | ||||
|       -1.000000;53.554752;14.242604;, | ||||
|        1.000000;53.554752;14.242604;, | ||||
|       -52.403629;-53.189678;16.253036;, | ||||
|       -52.403629;53.554752;16.253036;, | ||||
|       -50.412270;53.554752;16.253036;, | ||||
|       -50.412270;-53.189678;16.253036;, | ||||
|       -1.000000;-53.189678;14.242604;, | ||||
|       -1.000000;53.554752;14.242604;, | ||||
|       -50.412270;53.554752;14.242604;, | ||||
|       -50.412270;-53.189678;14.242604;, | ||||
|       -50.412270;-53.189678;16.253036;, | ||||
|       -50.412270;53.554752;16.253036;, | ||||
|       -1.000000;53.554752;16.253036;, | ||||
|       -1.000000;-53.189678;16.253036;, | ||||
|       -1.000000;-53.189678;16.253036;, | ||||
|       -1.000000;-53.189678;14.242604;, | ||||
|       -50.412270;-53.189678;14.242604;, | ||||
|       -50.412270;-53.189678;16.253036;, | ||||
|       -52.403629;-53.189678;14.242604;, | ||||
|       -52.403629;53.554752;14.242604;, | ||||
|       -52.403629;53.554752;16.253036;, | ||||
|       -52.403629;-53.189678;16.253036;, | ||||
|       -50.412270;-53.189678;16.253036;, | ||||
|       -50.412270;-53.189678;14.242604;, | ||||
|       -52.403629;-53.189678;14.242604;, | ||||
|       -52.403629;-53.189678;16.253036;, | ||||
|       -52.403629;53.554752;16.253036;, | ||||
|       -52.403629;53.554752;14.242604;, | ||||
|       -50.412270;53.554752;14.242604;, | ||||
|       -50.412270;53.554752;16.253036;, | ||||
|       -50.412270;53.554752;14.242604;, | ||||
|       -52.403629;53.554752;14.242604;, | ||||
|       -52.403629;53.554752;-0.989515;, | ||||
|       -50.412270;53.554752;-0.989515;, | ||||
|       -50.412270;-53.189678;-0.989515;, | ||||
|       -50.412270;53.554752;-0.989515;, | ||||
|       -52.403629;53.554752;-0.989515;, | ||||
|       -52.403629;-53.189678;-0.989515;, | ||||
|       -52.403629;-53.189678;-0.989515;, | ||||
|       -52.403629;53.554752;-0.989515;, | ||||
|       -52.403629;53.554752;14.242604;, | ||||
|       -52.403629;-53.189678;14.242604;, | ||||
|       -52.403629;-53.189678;14.242604;, | ||||
|       -50.412270;-53.189678;14.242604;, | ||||
|       -50.412270;-53.189678;-0.989515;, | ||||
|       -52.403629;-53.189678;-0.989515;, | ||||
|       -50.412270;-53.189678;14.242604;, | ||||
|       -50.412270;53.554752;14.242604;, | ||||
|       -50.412270;53.554752;-0.989515;, | ||||
|       -50.412270;-53.189678;-0.989515;; | ||||
|       22; | ||||
|       4;0;1;2;3;, | ||||
|       4;4;5;6;7;, | ||||
|       4;8;9;10;11;, | ||||
|       4;12;13;14;15;, | ||||
|       4;16;17;18;19;, | ||||
|       4;20;21;22;23;, | ||||
|       4;24;25;26;27;, | ||||
|       4;28;29;30;31;, | ||||
|       4;32;33;34;35;, | ||||
|       4;36;37;38;39;, | ||||
|       4;40;41;42;43;, | ||||
|       4;44;45;46;47;, | ||||
|       4;48;49;50;51;, | ||||
|       4;52;53;54;55;, | ||||
|       4;56;57;58;59;, | ||||
|       4;60;61;62;63;, | ||||
|       4;64;65;66;67;, | ||||
|       4;68;69;70;71;, | ||||
|       4;72;73;74;75;, | ||||
|       4;76;77;78;79;, | ||||
|       4;80;81;82;83;, | ||||
|       4;84;85;86;87;; | ||||
|       MeshNormals { //Cube_003 Normals | ||||
|         88; | ||||
|          0.000000; 0.000000;-1.000000;, | ||||
|          0.000000; 0.000000;-1.000000;, | ||||
|          0.000000; 0.000000;-1.000000;, | ||||
|          0.000000; 0.000000;-1.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|          0.000000;-1.000000; 0.000000;, | ||||
|         -1.000000; 0.000000;-0.000000;, | ||||
|         -1.000000; 0.000000;-0.000000;, | ||||
|         -1.000000; 0.000000;-0.000000;, | ||||
|         -1.000000; 0.000000;-0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|          0.000000;-0.000000; 1.000000;, | ||||
|          0.000000;-0.000000; 1.000000;, | ||||
|          0.000000;-0.000000; 1.000000;, | ||||
|          0.000000;-0.000000; 1.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          1.000000;-0.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000; 0.000000; 1.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000;-1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|          0.000000; 1.000000; 0.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -0.000000; 0.000000;-1.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|         -1.000000; 0.000000; 0.000000;, | ||||
|          0.000000;-1.000000;-0.000000;, | ||||
|          0.000000;-1.000000;-0.000000;, | ||||
|          0.000000;-1.000000;-0.000000;, | ||||
|          0.000000;-1.000000;-0.000000;, | ||||
|          1.000000; 0.000000; 0.000000;, | ||||
|          1.000000; 0.000000; 0.000000;, | ||||
|          1.000000; 0.000000; 0.000000;, | ||||
|          1.000000; 0.000000; 0.000000;; | ||||
|         22; | ||||
|         4;0;1;2;3;, | ||||
|         4;4;5;6;7;, | ||||
|         4;8;9;10;11;, | ||||
|         4;12;13;14;15;, | ||||
|         4;16;17;18;19;, | ||||
|         4;20;21;22;23;, | ||||
|         4;24;25;26;27;, | ||||
|         4;28;29;30;31;, | ||||
|         4;32;33;34;35;, | ||||
|         4;36;37;38;39;, | ||||
|         4;40;41;42;43;, | ||||
|         4;44;45;46;47;, | ||||
|         4;48;49;50;51;, | ||||
|         4;52;53;54;55;, | ||||
|         4;56;57;58;59;, | ||||
|         4;60;61;62;63;, | ||||
|         4;64;65;66;67;, | ||||
|         4;68;69;70;71;, | ||||
|         4;72;73;74;75;, | ||||
|         4;76;77;78;79;, | ||||
|         4;80;81;82;83;, | ||||
|         4;84;85;86;87;; | ||||
|       } //End of Cube_003 Normals | ||||
|       MeshMaterialList { //Cube_003 Material List | ||||
|         1; | ||||
|         22; | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0, | ||||
|         0;; | ||||
|         Material Material { | ||||
|            0.640000; 0.640000; 0.640000; 1.000000;; | ||||
|            96.078431; | ||||
|            0.500000; 0.500000; 0.500000;; | ||||
|            0.000000; 0.000000; 0.000000;; | ||||
|         } | ||||
|       } //End of Cube_003 Material List | ||||
|       MeshTextureCoords { //Cube_003 UV Coordinates | ||||
|         88; | ||||
|          0.973358; 0.999965;, | ||||
|          0.975236; 0.387889;, | ||||
|          0.986704; 0.387924;, | ||||
|          0.984826; 1.000000;, | ||||
|          0.706578; 0.081368;, | ||||
|          0.706614; 0.092836;, | ||||
|          0.695086; 0.092871;, | ||||
|          0.695051; 0.081403;, | ||||
|          0.593305; 0.387924;, | ||||
|          0.680706; 0.387656;, | ||||
|          0.682584; 0.999732;, | ||||
|          0.595183; 1.000000;, | ||||
|          0.794015; 0.092568;, | ||||
|          0.706614; 0.092836;, | ||||
|          0.706578; 0.081368;, | ||||
|          0.793980; 0.081100;, | ||||
|          0.882261; 1.000000;, | ||||
|          0.794859; 0.999732;, | ||||
|          0.796737; 0.387656;, | ||||
|          0.884139; 0.387924;, | ||||
|          0.806422; 0.375920;, | ||||
|          0.893824; 0.376188;, | ||||
|          0.893789; 0.387656;, | ||||
|          0.806387; 0.387388;, | ||||
|          0.000000; 0.387924;, | ||||
|          0.011468; 0.387889;, | ||||
|          0.013346; 0.999965;, | ||||
|          0.001878; 1.000000;, | ||||
|          0.795764; 0.092553;, | ||||
|          0.807291; 0.092589;, | ||||
|          0.806422; 0.375920;, | ||||
|          0.794894; 0.375885;, | ||||
|          0.682584; 0.999732;, | ||||
|          0.680706; 0.387656;, | ||||
|          0.692234; 0.387621;, | ||||
|          0.694112; 0.999696;, | ||||
|          0.794859; 0.387353;, | ||||
|          0.794894; 0.375885;, | ||||
|          0.806422; 0.375920;, | ||||
|          0.806387; 0.387388;, | ||||
|          0.306218; 0.386985;, | ||||
|          0.308096; 0.999061;, | ||||
|          0.296677; 0.999096;, | ||||
|          0.294799; 0.387020;, | ||||
|          0.593305; 0.387924;, | ||||
|          0.591427; 1.000000;, | ||||
|          0.308096; 0.999131;, | ||||
|          0.309974; 0.387055;, | ||||
|          0.294799; 0.387020;, | ||||
|          0.296677; 0.999096;, | ||||
|          0.013346; 0.999965;, | ||||
|          0.011468; 0.387889;, | ||||
|          0.695086; 0.092871;, | ||||
|          0.706614; 0.092836;, | ||||
|          0.707483; 0.376167;, | ||||
|          0.695955; 0.376202;, | ||||
|          0.707518; 0.387656;, | ||||
|          0.705640; 0.999732;, | ||||
|          0.694112; 0.999697;, | ||||
|          0.695990; 0.387621;, | ||||
|          0.695955; 0.376202;, | ||||
|          0.707483; 0.376167;, | ||||
|          0.707518; 0.387586;, | ||||
|          0.695990; 0.387621;, | ||||
|          0.795799; 0.081135;, | ||||
|          0.807326; 0.081170;, | ||||
|          0.807291; 0.092589;, | ||||
|          0.795764; 0.092553;, | ||||
|          0.807291; 0.092589;, | ||||
|          0.807326; 0.081170;, | ||||
|          0.894668; 0.081438;, | ||||
|          0.894633; 0.092856;, | ||||
|          0.988581; 1.000000;, | ||||
|          0.986704; 0.387924;, | ||||
|          0.998122; 0.387889;, | ||||
|          1.000000; 0.999965;, | ||||
|          0.794859; 0.387924;, | ||||
|          0.792981; 1.000000;, | ||||
|          0.705640; 0.999732;, | ||||
|          0.707518; 0.387656;, | ||||
|          0.707518; 0.387586;, | ||||
|          0.707483; 0.376167;, | ||||
|          0.794824; 0.375899;, | ||||
|          0.794859; 0.387318;, | ||||
|          0.884138; 0.999732;, | ||||
|          0.886016; 0.387656;, | ||||
|          0.973358; 0.387924;, | ||||
|          0.971480; 1.000000;; | ||||
|       } //End of Cube_003 UV Coordinates | ||||
|     } //End of Cube_003 Mesh | ||||
|   } //End of Cube_001 | ||||
| } //End of Root Frame | ||||
							
								
								
									
										
											BIN
										
									
								
								other_textures/connected_textures_ice.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 656 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/default_ice.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 82 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/default_ice.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/fine_snow.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 164 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/fine_snow_normal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 384 B | 
							
								
								
									
										67
									
								
								other_textures/inkscape_default_ice.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,67 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||||
| <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||||
|  | ||||
| <svg | ||||
|    xmlns:dc="http://purl.org/dc/elements/1.1/" | ||||
|    xmlns:cc="http://creativecommons.org/ns#" | ||||
|    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||||
|    xmlns:svg="http://www.w3.org/2000/svg" | ||||
|    xmlns="http://www.w3.org/2000/svg" | ||||
|    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | ||||
|    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | ||||
|    width="16" | ||||
|    height="16" | ||||
|    id="svg2" | ||||
|    version="1.1" | ||||
|    inkscape:version="0.48.4 r9939" | ||||
|    sodipodi:docname="inkscape_default_ice.svg"> | ||||
|   <defs | ||||
|      id="defs4" /> | ||||
|   <sodipodi:namedview | ||||
|      id="base" | ||||
|      pagecolor="#ffffff" | ||||
|      bordercolor="#666666" | ||||
|      borderopacity="1.0" | ||||
|      inkscape:pageopacity="0.0" | ||||
|      inkscape:pageshadow="2" | ||||
|      inkscape:zoom="45.4375" | ||||
|      inkscape:cx="6.8335626" | ||||
|      inkscape:cy="8" | ||||
|      inkscape:document-units="px" | ||||
|      inkscape:current-layer="layer1" | ||||
|      showgrid="false" | ||||
|      inkscape:showpageshadow="false" | ||||
|      inkscape:window-width="1328" | ||||
|      inkscape:window-height="895" | ||||
|      inkscape:window-x="197" | ||||
|      inkscape:window-y="70" | ||||
|      inkscape:window-maximized="0" /> | ||||
|   <metadata | ||||
|      id="metadata7"> | ||||
|     <rdf:RDF> | ||||
|       <cc:Work | ||||
|          rdf:about=""> | ||||
|         <dc:format>image/svg+xml</dc:format> | ||||
|         <dc:type | ||||
|            rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | ||||
|         <dc:title></dc:title> | ||||
|       </cc:Work> | ||||
|     </rdf:RDF> | ||||
|   </metadata> | ||||
|   <g | ||||
|      inkscape:label="Layer 1" | ||||
|      inkscape:groupmode="layer" | ||||
|      id="layer1" | ||||
|      transform="translate(0,-1036.3622)"> | ||||
|     <rect | ||||
|        style="fill:#91d2ff;fill-rule:evenodd;stroke:none;fill-opacity:1;opacity:0.90000000000000002" | ||||
|        id="rect2985" | ||||
|        width="16" | ||||
|        height="16" | ||||
|        x="0" | ||||
|        y="1036.3622" | ||||
|        inkscape:export-xdpi="90" | ||||
|        inkscape:export-ydpi="90" | ||||
|        inkscape:export-filename="/home/trickpaint/Minetest/Minetest_game_stuff/049_modtest/worlds/developing_snow_overhaul/worldmods/snow_developing/snow/textures/default_ice.png" /> | ||||
|   </g> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 2.0 KiB | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/mocha.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 83 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/mocha.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/original_snow_snow_brick.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 300 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/rect2985.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 81 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_ice.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 371 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_needles_decorated_animated.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snow.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 164 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snow_brick.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snow_cobble.png_01
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 788 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snow_cobble.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snow_side.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 726 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snowball.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 127 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_snowfall.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 190 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/snow_star_lit.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_cobble.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 297 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_bottom.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 602 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_fire_bg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 204 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_fire_fg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 719 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_front.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 553 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_front_active.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 4.2 KiB | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_side.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 602 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_furnace_top.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 602 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_glass.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 204 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_ice.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 371 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_ice.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_snow.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 164 B | 
							
								
								
									
										
											BIN
										
									
								
								other_textures/xdefault_stone_brick.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 572 B | 
							
								
								
									
										109
									
								
								readme.txt
									
									
									
									
									
								
							
							
						
						| @@ -1,89 +1,86 @@ | ||||
|    _____                       __  __           _  | ||||
|    _____                       __  __           _ | ||||
|   / ____|                     |  \/  |         | | | ||||
|  | (___  _ __   _____      __ | \  / | ___   __| | | ||||
|   \___ \| '_ \ / _ \ \ /\ / / | |\/| |/ _ \ / _` | | ||||
|   ____) | | | | (_) \ V  V /  | |  | | (_) | (_| | | ||||
|  |_____/|_| |_|\___/ \_/\_/   |_|  |_|\___/ \__,_| | ||||
|    | ||||
| By Splizard, bob and cornernote. | ||||
|  | ||||
| 					Version 4.0 | ||||
|  | ||||
| By Splizard, HybridDog and LazyJ. | ||||
|  | ||||
| Minetest version:  0.4.16+ | ||||
| Depends: default | ||||
| License:  GPL v3 | ||||
|  | ||||
| Complimentary Mods: | ||||
| --------------------- | ||||
| *	"More Blocks" by Calinou (2014_05_11 or newer) | ||||
| *	"Skins" by Zeg9 | ||||
|  | ||||
| Install: | ||||
|  | ||||
| Forum post: http://minetest.net/forum/viewtopic.php?id=2290 | ||||
| Github: https://github.com/Splizard/minetest-mod-snow | ||||
| Website: http://splizard.com/minetest/mods/snow/ | ||||
|  | ||||
| INSTALL: | ||||
| ---------- | ||||
| Place this folder in your minetest mods folder. | ||||
| (http://dev.minetest.net/Installing_Mods) | ||||
|  | ||||
| NOTICE | ||||
| While this mod is installed you may experience slow map loading while a snow biome is generated. | ||||
| 	* After downloading, unzip the file. | ||||
| 	* Rename the directory "minetest-mod-snow-master" to "snow" | ||||
| 	* Copy the "snow" directory into either | ||||
| 	../minetest/worlds/yourworld'sname/worldmods/ | ||||
| 	or | ||||
| 	../minetest/mods/ | ||||
| 	* If you put "snow" in the ../minetest/mods/ directory, either | ||||
| 	enable the mod from within Minetest's "Configure" button | ||||
| 	(main menu, bottom right) or by adding this line to the | ||||
| 	world's "world.mt" file: | ||||
| 	load_mod_snow = true | ||||
|  | ||||
| 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 crafted 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 blocks freeze water source blocks around them. | ||||
| Moss can be found in the snow, when moss is placed near cobble it spreads. | ||||
| Christmas trees can be found when digging pine needles. | ||||
| Sleds allow for faster travel on snow. | ||||
|  | ||||
| CRAFTING: | ||||
| ----------- | ||||
| Snow Block: | ||||
|  | ||||
| Snowball    Snowball | ||||
| Snowball    Snowball | ||||
|  | ||||
| Snow Brick: | ||||
|  | ||||
| Snow Block    Snow Block | ||||
| Snow Block    Snow Block | ||||
|  | ||||
| Sled: | ||||
| 				Stick | ||||
| Wood	Wood	Wood | ||||
|  | ||||
| Icy Snow: | ||||
|  | ||||
| Snow	Ice | ||||
| Ice		Snow | ||||
|  | ||||
| Config file: | ||||
| ------------ | ||||
| You can change various settings from the advanced settings in Minetest. | ||||
|  | ||||
|  | ||||
| 	* Go to the settings tab. | ||||
| 	* Click on Advanced Settings. | ||||
| 	* Click on Mods. | ||||
| 	* Click on snow. | ||||
| 	* Change stuff! | ||||
|  | ||||
| UNINSTALL: | ||||
| ------------ | ||||
| Simply delete the folder snow from the mods folder. | ||||
|  | ||||
| CHANGELOG: | ||||
| ------------ | ||||
| Version 1.4 | ||||
|  | ||||
|     New biomes, snowy and plain | ||||
|      | ||||
|     Christmas Trees | ||||
|      | ||||
|     Snowfall | ||||
|      | ||||
| Version 1.3 | ||||
|  | ||||
|     Smooth transitions | ||||
|      | ||||
|     Snow Bricks | ||||
|  | ||||
| Version 1.2 | ||||
|  | ||||
|     Pine trees | ||||
|      | ||||
|     Moss | ||||
|      | ||||
|     Alpine biomes | ||||
| 	 | ||||
|     Dry shrubs | ||||
|  | ||||
| Version 1.1 | ||||
|  | ||||
|     Better mapgen | ||||
|  | ||||
| Version 1.0 | ||||
|  | ||||
|     Initial release | ||||
| TODO: | ||||
| — test if the fixed ground_y search works correctly at chunkcorners at ground level | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								schematics/snow_pine.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								schematics/snow_pine_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								schematics/snow_xmas_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								schematics/snowy_snow_pine_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								schematics/snowy_snow_xmas_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										39
									
								
								settingtypes.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,39 @@ | ||||
| #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 | ||||
							
								
								
									
										218
									
								
								src/abms.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,218 @@ | ||||
| -- Added to change dirt_with_snow to dirt if covered with blocks that don't let | ||||
| -- light through (sunlight_propagates) or have a light paramtype and | ||||
| -- liquidtype combination. ~ LazyJ, 2014_03_08 | ||||
|  | ||||
| --[[minetest.register_abm({ | ||||
| 	nodenames = {"default:dirt_with_snow"}, | ||||
| 	interval = 2, | ||||
| 	chance = 20, | ||||
| 	action = function(pos) | ||||
| 		local name = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name | ||||
| 		local nodedef = minetest.registered_nodes[name] | ||||
| 		if name ~= "ignore" | ||||
| 		and nodedef | ||||
| 		and not ( | ||||
| 			(nodedef.sunlight_propagates or nodedef.paramtype == "light") | ||||
| 			and nodedef.liquidtype == "none" | ||||
| 		) then | ||||
| 			minetest.set_node(pos, {name = "default:dirt"}) | ||||
| 		end | ||||
| 	end | ||||
| }) | ||||
| ]]-- | ||||
|  | ||||
|  | ||||
| --Melting | ||||
| --Any node part of the group melting will melt when near warm nodes such as lava, fire, torches, etc. | ||||
| --The amount of water that replaces the node is defined by the number on the group: | ||||
| --1: one water_source | ||||
| --2: four water_flowings | ||||
| --3: one water_flowing | ||||
|  | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"group:melts"}, | ||||
| 	neighbors = {"group:igniter", "default:torch", "default:torch_wall", "default:furnace_active", "group:hot"}, | ||||
| 	interval = 10, | ||||
| 	chance = 2, | ||||
| 	action = function(pos, node) | ||||
| 		local intensity = minetest.get_item_group(node.name,"melts") | ||||
| 		if intensity == 1 then | ||||
| 			minetest.set_node(pos, {name="default:water_source"}) | ||||
| 		elseif intensity == 2 then | ||||
| 			minetest.set_node(pos, {name="default:water_flowing", param2=7}) | ||||
| 		elseif intensity == 3 then | ||||
| 			minetest.set_node(pos, {name="default:water_flowing", param2=3}) | ||||
| 		--[[	LazyJ, you need to add param2, which defines the amount of the flowing water ~ HybridDog 2015_03_06 | ||||
| 			This was causing "melts=2" nodes to just disappear so I changed it to replace the | ||||
| 			node with a water_source for a couple seconds and then replace the water_source with | ||||
| 			air. This way it made a watery mess that quickly evaporated. ~ LazyJ 2014_04_24 | ||||
| 			local check_place = function(pos,node) | ||||
| 				if minetest.get_node(pos).name == "air" then | ||||
| 					minetest.place_node(pos,node) | ||||
| 				end | ||||
| 			end | ||||
| 			minetest.add_node(pos,{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x+1,y=pos.y,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x-1,y=pos.y,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x,y=pos.y+1,z=pos.z},{name="default:water_flowing"}) | ||||
| 			check_place({x=pos.x,y=pos.y-1,z=pos.z},{name="default:water_flowing"}) | ||||
| 		elseif intensity == 3 then | ||||
| 		--] | ||||
| 			minetest.add_node(pos,{name="default:water_source"}) | ||||
| 				minetest.after(2, function()  -- 2 seconds gives just enough time for | ||||
| 											-- the water to flow and spread before the | ||||
| 											-- water_source is changed to air. ~ LazyJ | ||||
| 					if minetest.get_node(pos).name == "default:water_source" then | ||||
| 						 minetest.add_node(pos,{name="air"}) | ||||
| 					 end | ||||
| 				 end) | ||||
| 		--]] | ||||
| 		 else | ||||
| 			return | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| --Freezing | ||||
| --Water freezes when in contact with snow. | ||||
| --[[ | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"default:water_source"}, | ||||
| 	-- Added "group:icemaker" and snowbrick. ~ LazyJ | ||||
| 	neighbors = {"default:snow", "default:snowblock", "snow:snow_brick", "group:icemaker"}, | ||||
| 	interval = 20, | ||||
| 	chance = 4, | ||||
| 	action = function(pos) | ||||
| 		minetest.add_node(pos,{name="default:ice"}) | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| --Freeze Ice according to it's param2 value. | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"default:ice"}, | ||||
| 	neighbors = {"default:water_source"}, | ||||
| 	interval = 20, | ||||
| 	chance = 4, | ||||
| 	action = function(pos, node) | ||||
| 		if node.param2 == 0 then | ||||
| 			return | ||||
| 		end | ||||
| 		for l = 0,1 do | ||||
| 			for i = -1,1,2 do | ||||
| 				for _,p in pairs({ | ||||
| 					{x=pos.x+i, z=pos.z-l*i}, | ||||
| 					{x=pos.x+l*i, z=pos.z+i} | ||||
| 				}) do | ||||
| 					if math.random(2) == 2 then | ||||
| 						p.y = pos.y | ||||
| 						if minetest.get_node(p).name == "default:water_source" then | ||||
| 							minetest.add_node(p, { | ||||
| 								name = "default:ice", | ||||
| 								param2 = math.random(0,node.param2-1) | ||||
| 							}) | ||||
| 						end | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 		if math.random(8) == 8 then | ||||
| 			minetest.add_node(pos, {name="default:water_source"}) | ||||
| 		else | ||||
| 			node.param2 = 0 | ||||
| 			minetest.add_node(pos, node) | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
| ]]-- | ||||
|  | ||||
|  | ||||
| --Spread moss to cobble. | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"default:cobble"}, | ||||
| 	neighbors = {"snow:moss"}, | ||||
| 	interval = 20, | ||||
| 	chance = 6, | ||||
| 	catch_up = false, | ||||
| 	action = function(pos, node) | ||||
| 		node.name = "default:mossycobble" | ||||
| 		minetest.add_node(pos, node) | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
| --[[ | ||||
| --Grow Pine Saplings | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"snow:sapling_pine"}, | ||||
| 	interval = 10, | ||||
| 	chance = 50, | ||||
| 	action = function(pos) | ||||
|  | ||||
| -- Check if there is enough vertical-space for the sapling to grow without | ||||
| -- hitting anything else.  ~ LazyJ, 2014_04_10 | ||||
|  | ||||
| 		-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ | ||||
| 		for i = 1,8 do | ||||
| 			if minetest.get_node({x=pos.x, y=pos.y+i, z=pos.z}).name ~= "air" then | ||||
| 				return | ||||
| 			end | ||||
| 		end | ||||
| 		-- 'then' let the sapling grow into a tree. ~ LazyJ | ||||
|  | ||||
| 		snow.make_pine(pos,false) | ||||
| 		-- This finds the sapling under the grown tree. ~ LazyJ | ||||
| 		if minetest.get_node(pos).name == "snow:sapling_pine" then | ||||
| 			   -- This switches the sapling to a tree trunk. ~ LazyJ | ||||
| 			minetest.set_node(pos, {name="default:pine_tree"}) | ||||
| 			   -- This is more for testing but it may be useful info to some admins when | ||||
| 			   -- grepping the server logs too. ~ LazyJ | ||||
| 			minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos)) | ||||
| 		end | ||||
| 	end | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
| --Grow Christmas Tree Saplings | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"snow:xmas_tree"}, | ||||
| 	interval = 10, | ||||
| 	chance = 50, | ||||
| 	action = function(pos) | ||||
|  | ||||
| 		-- 'If' there is air in each of the 8 nodes dirctly above the sapling,... ~LazyJ | ||||
| 		for i = 1,8 do | ||||
| 			if minetest.get_node({x=pos.x, y=pos.y+i, z=pos.z}).name ~= "air" then | ||||
| 				return | ||||
| 			end | ||||
| 		end | ||||
| 		-- 'then' let the sapling grow into a tree. ~ LazyJ | ||||
|  | ||||
| 		snow.make_pine(pos,false,true) | ||||
| 		minetest.log("action", "A pine sapling grows into a Christmas tree at "..minetest.pos_to_string(pos)) -- ~ LazyJ | ||||
| 		--else  -- 'Else', if there isn't air in each of the 8 nodes above the sapling, | ||||
| 				-- then don't anything; including not allowing the sapling to grow. | ||||
| 				-- ~ LazyJ, 2014_04_10 | ||||
| 		--end | ||||
| 	end | ||||
| }) | ||||
|  | ||||
| ]]-- | ||||
|  | ||||
|  | ||||
| --Backwards Compatability. | ||||
| --[[ | ||||
| minetest.register_abm({ | ||||
| 	nodenames = {"snow:snow1","snow:snow2","snow:snow3","gsnow4","snow:snow5","snow:snow6","snow:snow7","snow:snow8"}, | ||||
| 	interval = 1, | ||||
| 	chance = 1, | ||||
| 	action = function(pos, node) | ||||
| 		minetest.add_node(pos, {name="default:snow"}) | ||||
| 		minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1)))) | ||||
| 	end, | ||||
| }) | ||||
| ]]-- | ||||
							
								
								
									
										110
									
								
								src/aliases.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,110 @@ | ||||
| -- Some aliases for compatibility switches and some to make "/give" commands | ||||
| -- a little easier | ||||
|  | ||||
| minetest.register_alias("snow:snow", "default:snow") | ||||
| minetest.register_alias("default_snow", "default:snow") | ||||
| minetest.register_alias("snow:snowball", "default:snow") | ||||
| minetest.register_alias("snowball", "default:snow") | ||||
| minetest.register_alias("snowballs", "default:snow") | ||||
| minetest.register_alias("snow_ball", "default:snow") | ||||
| minetest.register_alias("snow:ice", "default:ice") | ||||
| minetest.register_alias("ice", "default:ice") | ||||
| minetest.register_alias("default_ice", "default:ice") | ||||
| minetest.register_alias("snow:dirt_with_snow", "default:dirt_with_snow") | ||||
| minetest.register_alias("dirtwithsnow", "default:dirt_with_snow") | ||||
| minetest.register_alias("snowdirt", "default:dirt_with_snow") | ||||
| minetest.register_alias("snowydirt", "default:dirt_with_snow") | ||||
| minetest.register_alias("snow:snow_block", "default:snowblock") | ||||
| minetest.register_alias("default:snow_block", "default:snowblock") | ||||
| minetest.register_alias("snowblocks", "default:snowblock") | ||||
| minetest.register_alias("snowbrick", "snow:snow_brick") | ||||
| minetest.register_alias("bricksnow", "snow:snow_brick") | ||||
| minetest.register_alias("snowbricks", "snow:snow_brick") | ||||
| minetest.register_alias("snowybricks", "snow:snow_brick") | ||||
| minetest.register_alias("icysnow", "snow:snow_cobble") | ||||
| minetest.register_alias("snowcobble", "snow:snow_cobble") | ||||
| minetest.register_alias("snowycobble", "snow:snow_cobble") | ||||
| minetest.register_alias("cobblesnow", "snow:snow_cobble") | ||||
|  | ||||
|  | ||||
| -- To clean up my first stairsplus attempt. | ||||
| -- Stair | ||||
| --[[ | ||||
| minetest.register_alias(":default:stair_snowblock", "moreblocks:stair_snowblock") | ||||
| minetest.register_alias(":default:stair_snowblock_half", "moreblocks:stair_snowblock_half") | ||||
| minetest.register_alias(":default:stair_snowblock_right_half", "moreblocks:stair_snowblock_right_half") | ||||
| minetest.register_alias(":default:stair_snowblock_inner", "moreblocks:stair_snowblock_inner") | ||||
| minetest.register_alias(":default:stair_snowblock_outer", "moreblocks:stair_snowblock_outer") | ||||
| minetest.register_alias(":default:stair_snowblock_alt", "moreblocks:stair_snowblock_alt") | ||||
| minetest.register_alias(":default:stair_snowblock_alt_1", "moreblocks:stair_snowblock_alt_1") | ||||
| minetest.register_alias(":default:stair_snowblock_alt_2", "moreblocks:stair_snowblock_2") | ||||
| minetest.register_alias(":default:stair_snowblock_alt_4", "moreblocks:stair_snowblock_alt_4") | ||||
|  | ||||
| minetest.register_alias(":default:stair_ice", "moreblocks:stair_ice") | ||||
| minetest.register_alias(":default:stair_ice_half", "moreblocks:stair_ice_half") | ||||
| minetest.register_alias(":default:stair_ice_right_half", "moreblocks:stair_ice_right_half") | ||||
| minetest.register_alias(":default:stair_ice_inner", "moreblocks:stair_ice_inner") | ||||
| minetest.register_alias(":default:stair_ice_outer", "moreblocks:stair_ice_outer") | ||||
| minetest.register_alias(":default:stair_ice_alt", "moreblocks:stair_ice_alt") | ||||
| minetest.register_alias(":default:stair_ice_alt_1", "moreblocks:stair_ice_alt_1") | ||||
| minetest.register_alias(":default:stair_ice_alt_2", "moreblocks:stair_ice_2") | ||||
| minetest.register_alias(":default:stair_ice_alt_4", "moreblocks:stair_ice_alt_4") | ||||
|  | ||||
|  | ||||
| -- Slab | ||||
| minetest.register_alias(":default:slab_snowblock", "moreblocks:slab_snowblock") | ||||
| minetest.register_alias(":default:slab_snowblock_quarter", "moreblocks:slab_snowblock_quarter") | ||||
| minetest.register_alias(":default:slab_snowblock_three_quarter", "moreblocks:slab_snowblock_three_quarter") | ||||
| minetest.register_alias(":default:slab_snowblock_1", "moreblocks:slab_snowblock_1") | ||||
| minetest.register_alias(":default:slab_snowblock_2", "moreblocks:slab_snowblock_2") | ||||
| minetest.register_alias(":default:slab_snowblock_14", "moreblocks:slab_snowblock_14") | ||||
| minetest.register_alias(":default:slab_snowblock_15", "moreblocks:slab_snowblock_15") | ||||
|  | ||||
| minetest.register_alias(":default:slab_ice", "moreblocks:slab_ice") | ||||
| minetest.register_alias(":default:slab_ice_quarter", "moreblocks:slab_ice_quarter") | ||||
| minetest.register_alias(":default:slab_ice_three_quarter", "moreblocks:slab_ice_three_quarter") | ||||
| minetest.register_alias(":default:slab_ice_1", "moreblocks:slab_ice_1") | ||||
| minetest.register_alias(":default:slab_ice_2", "moreblocks:slab_ice_2") | ||||
| minetest.register_alias(":default:slab_ice_14", "moreblocks:slab_ice_14") | ||||
| minetest.register_alias(":default:slab_ice_15", "moreblocks:slab_ice_15") | ||||
|  | ||||
|  | ||||
| -- Panel | ||||
| minetest.register_alias(":default:panel_snowblock", "moreblocks:panel_snowblock") | ||||
| minetest.register_alias(":default:panel_snowblock_1", "moreblocks:panel_snowblock_1") | ||||
| minetest.register_alias(":default:panel_snowblock_2", "moreblocks:panel_snowblock_2") | ||||
| minetest.register_alias(":default:panel_snowblock_4", "moreblocks:panel_snowblock_4") | ||||
| minetest.register_alias(":default:panel_snowblock_12", "moreblocks:panel_snowblock_12") | ||||
| minetest.register_alias(":default:panel_snowblock_14", "moreblocks:panel_snowblock_14") | ||||
| minetest.register_alias(":default:panel_snowblock_15", "moreblocks:panel_snowblock_15") | ||||
|  | ||||
| minetest.register_alias(":default:panel_ice", "moreblocks:panel_ice") | ||||
| minetest.register_alias(":default:panel_ice_1", "moreblocks:panel_ice_1") | ||||
| minetest.register_alias(":default:panel_ice_2", "moreblocks:panel_ice_2") | ||||
| minetest.register_alias(":default:panel_ice_4", "moreblocks:panel_ice_4") | ||||
| minetest.register_alias(":default:panel_ice_12", "moreblocks:panel_ice_12") | ||||
| minetest.register_alias(":default:panel_ice_14", "moreblocks:panel_ice_14") | ||||
| minetest.register_alias(":default:panel_ice_15", "moreblocks:panel_ice_15") | ||||
|  | ||||
|  | ||||
| -- Micro | ||||
| minetest.register_alias(":default:micro_snowblock", "moreblocks:micro_snowblock") | ||||
| minetest.register_alias(":default:micro_snowblock_1", "moreblocks:micro_snowblock_1") | ||||
| minetest.register_alias(":default:micro_snowblock_2", "moreblocks:micro_snowblock_2") | ||||
| minetest.register_alias(":default:micro_snowblock_4", "moreblocks:micro_snowblock_4") | ||||
| minetest.register_alias(":default:micro_snowblock_12", "moreblocks:micro_snowblock_12") | ||||
| minetest.register_alias(":default:micro_snowblock_14", "moreblocks:micro_snowblock_14") | ||||
| minetest.register_alias(":default:micro_snowblock_15", "moreblocks:micro_snowblock_15") | ||||
|  | ||||
| minetest.register_alias(":default:micro_ice", "moreblocks:micro_ice") | ||||
| minetest.register_alias(":default:micro_ice_1", "moreblocks:micro_ice_1") | ||||
| minetest.register_alias(":default:micro_ice_2", "moreblocks:micro_ice_2") | ||||
| minetest.register_alias(":default:micro_ice_4", "moreblocks:micro_ice_4") | ||||
| minetest.register_alias(":default:micro_ice_12", "moreblocks:micro_ice_12") | ||||
| minetest.register_alias(":default:micro_ice_14", "moreblocks:micro_ice_14") | ||||
| minetest.register_alias(":default:micro_ice_15", "moreblocks:micro_ice_15") | ||||
| ]]-- | ||||
| -- If christmas_craft then override his star with this mod one. | ||||
| if minetest.get_modpath("christmas_craft") then | ||||
| 	minetest.register_alias_force("christmas_craft:christmas_star", "snow:star") | ||||
| end | ||||
							
								
								
									
										216
									
								
								src/crafting.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,216 @@ | ||||
| --[[ | ||||
|  | ||||
| Crafting Sections (in order, top to bottom): | ||||
| 	1. Cooking | ||||
| 	2. Crafting and Recycling | ||||
|  | ||||
| The crafting recipe for the sled is in the sled.lua file. | ||||
|  | ||||
| ~ LazyJ | ||||
|  | ||||
| ]] | ||||
|  | ||||
|  | ||||
| -- 1. Cooking | ||||
|  | ||||
| --[[ | ||||
| "Cooks_into_ice" is a custom group I assigned to full-sized, snow-stuff nodes | ||||
| (snow bricks, snow cobble, snow blocks, etc.) so I wouldn't have to write an individual cooking | ||||
| recipe for each one. | ||||
|  | ||||
| ~ LazyJ | ||||
| ]] | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "cooking", | ||||
| 	cooktime = 12, | ||||
| 	output = "default:ice", | ||||
| 	recipe = "group:cooks_into_ice", | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| -- 2. Crafting and Recycling | ||||
|  | ||||
| -- Let's make moss craftable so players can more easily create mossycobble and | ||||
| -- gives another useful purpose to pine needles. ~ LazyJ | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:moss", | ||||
| 	recipe = { | ||||
| 		{"snow:needles", "snow:needles"}, | ||||
| 		{"snow:needles", "snow:needles"}, | ||||
| 	}, | ||||
| }) | ||||
|  | ||||
|  | ||||
| --[[ | ||||
| Most snow biomes are too small to provide enough snow as a building material and | ||||
| still have enough landscape snow to create the wintry surroundings of a | ||||
| snow village or castle. So I added this snowblock crafting recipe as a way for | ||||
| players to increase their snow supply in small increments. I considered making | ||||
| the output 9 but that would make it all too quick and easy (especially for griefers) to create lots | ||||
| of snowblocks (and then use them to water-grief by melting the snow blocks). | ||||
|  | ||||
| ~ LazyJ | ||||
|  | ||||
| ]]-- | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "default:snowblock 2", | ||||
| 	recipe = { | ||||
| 		"snow:snow_cobble", | ||||
| 		"snow:snow_cobble" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
| --[[minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "default:snowblock 3", | ||||
| 	recipe = { | ||||
| 		"default:snowblock", | ||||
| 		"default:snowblock" | ||||
| 	} | ||||
| })]]-- | ||||
|  | ||||
|  | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:snow_brick", | ||||
| 	recipe = { | ||||
| 		{"default:snowblock", "default:snowblock"}, | ||||
| 		{"default:snowblock", "default:snowblock"} | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| -- Why not recycle snow_bricks back into snowblocks? ~ LazyJ | ||||
| minetest.register_craft({ | ||||
| 	output = "default:snowblock 4", | ||||
| 	recipe = { | ||||
| 		{"snow:snow_brick"} | ||||
| 	} | ||||
| }) | ||||
|  | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:ice_brick", | ||||
| 	recipe = { | ||||
| 		{"default:ice", "default:ice"}, | ||||
| 		{"default:ice", "default:ice"} | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:snow_cobble 6", | ||||
| 	recipe = { | ||||
| 		{"snow:ice_brick"} | ||||
| 	} | ||||
| }) | ||||
|  | ||||
|  | ||||
| --Craft icy snow. | ||||
| minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "snow:snow_cobble 6", | ||||
| 	recipe = { | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:ice", | ||||
| 		"default:ice", | ||||
| 		"default:ice" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "snow:snow_cobble 4", | ||||
| 	recipe = { | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:ice", | ||||
| 		"default:ice" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "snow:snow_cobble 2", | ||||
| 	recipe = { | ||||
| 		"default:snow", | ||||
| 		"default:snow", | ||||
| 		"default:ice" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	type = "shapeless", | ||||
| 	output = "snow:snow_cobble", | ||||
| 	recipe = { | ||||
| 		"default:snow", | ||||
| 		"default:ice" | ||||
| 	} | ||||
| }) | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Recycle basic, half-block, slabs back into full blocks | ||||
|  | ||||
| -- A little "list" magic here. Instead of writing four crafts I only have to write two. ~ LazyJ | ||||
| local recycle_default_slabs = { | ||||
| 	"ice", | ||||
| 	"snowblock", | ||||
| } | ||||
|  | ||||
| for _, name in pairs(recycle_default_slabs) do | ||||
| 	local subname_default = name | ||||
|  | ||||
| 	-- This craft is for default snowblocks and default ice. | ||||
| 	-- 1 crafting recipe handles 2, default blocks. ~ LazyJ | ||||
| 	minetest.register_craft({ | ||||
| 		type = "shapeless", | ||||
| 		output = "default:"..subname_default, | ||||
| 		recipe = { | ||||
| 			"snow:slab_"..subname_default, | ||||
| 			"snow:slab_"..subname_default, | ||||
| 		} | ||||
| 	}) | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Similar list magic here too. I couldn't successfully combine these in the first list | ||||
| -- because we are dealing with slabs/blocks from two different mods, the "Snow" mod and | ||||
| -- minetest_game's "Default" mod. ~ LazyJ | ||||
|  | ||||
| local recycle_snowmod_slabs = { | ||||
| 	"snow_brick", | ||||
| 	"snow_cobble", | ||||
| } | ||||
|  | ||||
| for _, name in pairs(recycle_snowmod_slabs) do | ||||
| 	local subname_snowmod = name | ||||
|  | ||||
| 	-- This craft is for the Snow mod's full-sized blocks. | ||||
| 	-- 1 crafting recipe handles 2, or more, Snow mod blocks. ~ LazyJ | ||||
| 	minetest.register_craft({ | ||||
| 		type = "shapeless", | ||||
| 		output = "snow:"..subname_snowmod, | ||||
| 		recipe = { | ||||
| 			"snow:slab_"..subname_snowmod, | ||||
| 			"snow:slab_"..subname_snowmod, | ||||
| 		} | ||||
| 	}) | ||||
| end | ||||
							
								
								
									
										211
									
								
								src/falling_snow.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,211 @@ | ||||
| -- Parameters | ||||
|  | ||||
| local function snow_fall(pos) | ||||
| 	local ground_y = nil | ||||
| 	for y=pos.y+10,pos.y+20,1 do | ||||
| 		local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name | ||||
| 		if n ~= "air" and n ~= "ignore" then | ||||
| 			return | ||||
| 		end | ||||
| 	end | ||||
| 	for y=pos.y+9,pos.y-15,-1 do | ||||
| 		local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name | ||||
| 		if n ~= "air" and n ~= "ignore" then | ||||
| 			ground_y = y | ||||
| 			break | ||||
| 		end | ||||
| 	end | ||||
| 	if not ground_y then | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	pos = {x=pos.x, y=ground_y, z=pos.z} | ||||
|  | ||||
| 	snow.place(pos, true) | ||||
| 	--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"}) -- LazyJ | ||||
| end | ||||
|  | ||||
| local YLIMIT = 1 -- Set to world's water level | ||||
| 				-- Particles are timed to disappear at this y | ||||
| 				-- Particles do not spawn when player's head is below this y | ||||
| local PRECSPR = 6 -- Time scale for precipitation variation in minutes | ||||
| local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often | ||||
| local GSCYCLE = 0.5 -- Globalstep cycle (seconds) | ||||
| local FLAKES = 32 -- Snowflakes per cycle | ||||
| --~ local DROPS = 128 -- Raindrops per cycle | ||||
| --~ local RAINGAIN = 0.2 -- Rain sound volume | ||||
| local 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 = { | ||||
| 	offset = 0, | ||||
| 	scale = 1, | ||||
| 	spread = {x = PRECSPR, y = PRECSPR, z = PRECSPR}, | ||||
| 	seed = 813, | ||||
| 	octaves = 1, | ||||
| 	persist = 0, | ||||
| 	lacunarity = 2.0, | ||||
| 	--flags = "" | ||||
| } | ||||
|  | ||||
| -- These 2 must match biome heat and humidity noise parameters for a world | ||||
|  | ||||
| local np_temp = { | ||||
| 	offset = 50, | ||||
| 	scale = 50, | ||||
| 	spread = {x = 1000, y = 1000, z = 1000}, | ||||
| 	seed = 5349, | ||||
| 	octaves = 3, | ||||
| 	persist = 0.5, | ||||
| 	lacunarity = 2.0, | ||||
| 	--flags = "" | ||||
| } | ||||
|  | ||||
| local np_humid = { | ||||
| 	offset = 50, | ||||
| 	scale = 50, | ||||
| 	spread = {x = 1000, y = 1000, z = 1000}, | ||||
| 	seed = 842, | ||||
| 	octaves = 3, | ||||
| 	persist = 0.5, | ||||
| 	lacunarity = 2.0, | ||||
| 	--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 | ||||
							
								
								
									
										222
									
								
								src/mapgen.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,222 @@ | ||||
| --[[ | ||||
| If you want to run PlantLife and mods that depend on it, i.e. MoreTrees, Disable the mapgen by | ||||
| commenting-out the lines starting with "local mgname = " through "end" (I left a note were to start | ||||
| and stop) Disabling "Snow's" mapgen allows MoreTrees and PlantLife to do their thing until the | ||||
| issue is figured out. However, the pine and xmas tree code is still needed for when those | ||||
| saplings grow into trees. --]] | ||||
| --The *starting* comment looks like this:  --[[ | ||||
| --The *closing* comment looks like this:  --]] | ||||
|  | ||||
| -- ~ LazyJ, 2014_05_13 | ||||
|  | ||||
|  | ||||
| -- 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 {} | ||||
| 	local mg = snow.mapgen | ||||
|  | ||||
| 	-- perlin noise "hills" are not peaks but looking like sinus curve | ||||
| 	local function upper_rarity(rarity) | ||||
| 		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 function calc_values() | ||||
| 		nosmooth_rarity = 1-rarity/50 | ||||
| 		perlin_scale = size*100/rarity | ||||
| 		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 == "v6" then | ||||
| 		--Load mapgen_v6 compatibility. | ||||
| 		dofile(path.."/src/mapgen_v6.lua") | ||||
| 	else]]-- | ||||
| 		--Load mapgen_v7 compatibility. | ||||
| dofile(minetest.get_modpath("snow").."/src/mapgen_v7.lua") | ||||
| --[[	end | ||||
| end | ||||
|  | ||||
| -- To complete the commenting-out add the *closing* comment under this line. | ||||
|  | ||||
|  | ||||
| local pine_tree = { | ||||
| 	axiom="TABff", | ||||
| 	rules_a="[&T+f+ff+ff+ff+f]GA", | ||||
| 	rules_b="[&T+f+Gf+Gf+Gf]GB", | ||||
| 	trunk="default:pine_tree", | ||||
| 	leaves="snow:needles", | ||||
| 	angle=90, | ||||
| 	iterations=1, | ||||
| 	random_level=0, | ||||
| 	trunk_type="single", | ||||
| 	thin_branches=true, | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| local xmas_tree = { | ||||
| 	axiom="TABff", | ||||
| 	rules_a="[&T+f+ff+ff+ff+f]GA", | ||||
| 	rules_b="[&T+f+Gf+Gf+Gf]GB", | ||||
| 	trunk="default:pine_tree", | ||||
| 	leaves="snow:needles_decorated", | ||||
| 	angle=90, | ||||
| 	iterations=1, | ||||
| 	random_level=0, | ||||
| 	trunk_type="single", | ||||
| 	thin_branches=true, | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| --Makes pine tree | ||||
| function snow.make_pine(pos,snow,xmas) | ||||
| 	local minetest = minetest | ||||
| 	local function try_node(p, node) | ||||
| 		local n = minetest.get_node(p).name | ||||
| 		if n == "air" | ||||
| 		or n == "ignore" then | ||||
| 			minetest.add_node(p, node) | ||||
| 		end | ||||
| 	end | ||||
| 	if xmas then | ||||
| 		minetest.remove_node(pos) | ||||
| 		minetest.spawn_tree(pos, xmas_tree) | ||||
| 	else | ||||
| 		minetest.spawn_tree(pos, pine_tree) | ||||
| 	end | ||||
| 	if snow then | ||||
| 		local x,z = pos.x,pos.z | ||||
| 		try_node({x=x+1,y=pos.y+3,z=z+1},{name="default:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+3,z=z-1},{name="default:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+3,z=z+1},{name="default:snow"}) | ||||
| 		try_node({x=x+1,y=pos.y+3,z=z-1},{name="default:snow"}) | ||||
|  | ||||
| 		try_node({x=x+1,y=pos.y+5,z=z},{name="default:snow"}) | ||||
| 		try_node({x=x-1,y=pos.y+5,z=z},{name="default:snow"}) | ||||
| 		try_node({x=x,y=pos.y+5,z=z+1},{name="default:snow"}) | ||||
| 		try_node({x=x,y=pos.y+5,z=z-1},{name="default:snow"}) | ||||
| 	end | ||||
| 	if xmas then | ||||
| 		try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star_lit"}) -- Added lit star. ~ LazyJ | ||||
| 	elseif snow | ||||
| 	and minetest.get_perlin(112,3, 0.5, perlin_scale):get2d({x=pos.x,y=pos.z}) > nosmooth_rarity then | ||||
| 		try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="default:snow"}) | ||||
| 	end | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| --Makes pine tree | ||||
| function snow.voxelmanip_pine(pos,a,data) | ||||
| 	local c_snow = minetest.get_content_id("default:snow") | ||||
| 	local c_pine_needles = minetest.get_content_id("snow:needles") | ||||
| 	local c_pinetree = minetest.get_content_id("default:pinetree") | ||||
|  | ||||
| 	local perlin1 = minetest.get_perlin(112,3, 0.5, perlin_scale) | ||||
| 	for off_z = -1,1 do | ||||
| 		local z = pos.z + off_z | ||||
| 		for off_x = -1,1 do | ||||
| 			local x = pos.x + off_x | ||||
|  | ||||
| 			--Make tree. | ||||
| 			for i = 1,2 do | ||||
| 				data[a:index(x,pos.y+i,z)] = c_pine_needles | ||||
| 				if x ~= 0 | ||||
| 				and z ~= 0 | ||||
| 				and perlin1:get2d({x=x,y=z}) > nosmooth_rarity then | ||||
| 					local abovenode = a:index(x,pos.y+i+1,z) | ||||
| 					data[abovenode] = c_snow | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| 	for i=3, 4 do | ||||
| 		local x = pos.x | ||||
| 		local y = pos.y+i | ||||
| 		local z = pos.z | ||||
| 		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 | ||||
| 		if perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then | ||||
| 			data[a:index(x+1,y+1,z)] = c_snow | ||||
| 		end | ||||
| 		if perlin1:get2d({x=x+1,y=z}) > nosmooth_rarity then | ||||
| 			data[a:index(x-1,y+1,z)] = c_snow | ||||
| 		end | ||||
| 		if perlin1:get2d({x=x,y=z+1}) > nosmooth_rarity then | ||||
| 			data[a:index(x,y+1,z+1)] = c_snow | ||||
| 		end | ||||
| 		if perlin1:get2d({x=x,y=z-1}) > nosmooth_rarity then | ||||
| 			data[a:index(x,y+1,z-1)] = c_snow | ||||
| 		end | ||||
| 	end | ||||
| 	for i=0, 4 do | ||||
| 		data[a:index(pos.x,pos.y+i,pos.z)] = c_pinetree | ||||
| 	end | ||||
| 	data[a:index(pos.x,pos.y+5,pos.z)] = c_pine_needles | ||||
| 	data[a:index(pos.x,pos.y+6,pos.z)] = c_pine_needles | ||||
| 	if perlin1:get2d({x=pos.x,y=pos.z}) > nosmooth_rarity then | ||||
| 		data[a:index(pos.x,pos.y+7,pos.z)] = c_snow | ||||
| 	end | ||||
| end | ||||
| ]]-- | ||||
| -- treecapitator support | ||||
| if minetest.global_exists("treecapitator") then | ||||
| 	treecapitator.register_tree{ | ||||
| 		trees = {"default:pine_tree"}, | ||||
| 		leaves = {"snow:needles"}, | ||||
| 		range = 1, | ||||
| 		range_up = 2, | ||||
| 		range_down = 3, | ||||
| 		stem_height_min = 1, | ||||
| 	} | ||||
|  | ||||
| 	treecapitator.register_tree{ | ||||
| 		trees = {"default:pine_tree"}, | ||||
| 		leaves = {"snow:needles_decorated"}, | ||||
| 		fruits = {"snow:star_lit", "snow:star"}, | ||||
| 		range = 1, | ||||
| 		range_up = 3, | ||||
| 		range_down = 3, | ||||
| 		stem_height_min = 1, | ||||
| 	} | ||||
| end | ||||
							
								
								
									
										585
									
								
								src/mapgen_v6.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,585 @@ | ||||
| -- https://github.com/paramat/meru/blob/master/init.lua#L52 | ||||
| -- Parameters must match mgv6 biome noise | ||||
|  | ||||
| local np_default = { | ||||
| 	offset = 0, | ||||
| 	scale = 1, | ||||
| 	spread = {x=250, y=250, z=250}, | ||||
| 	seed = 9130, | ||||
| 	octaves = 3, | ||||
| 	persist = 0.5 | ||||
| } | ||||
|  | ||||
|  | ||||
| -- 2D noise for coldness | ||||
|  | ||||
| local mg = snow.mapgen | ||||
| local scale_coldness = mg.perlin_scale | ||||
| local np_cold = { | ||||
| 	offset = 0, | ||||
| 	scale = 1, | ||||
| 	spread = {x=scale_coldness, y=scale_coldness, z=scale_coldness}, | ||||
| 	seed = 112, | ||||
| 	octaves = 3, | ||||
| 	persist = 0.5 | ||||
| } | ||||
|  | ||||
|  | ||||
| -- 2D noise for icetype | ||||
|  | ||||
| local np_ice = { | ||||
| 	offset = 0, | ||||
| 	scale = 1, | ||||
| 	spread = {x=80, y=80, z=80}, | ||||
| 	seed = 322345, | ||||
| 	octaves = 3, | ||||
| 	persist = 0.5 | ||||
| } | ||||
|  | ||||
|  | ||||
| local function do_ws_func(a, x) | ||||
| 	local n = math.pi * x / 16000 | ||||
| 	local y = 0 | ||||
| 	for k = 1,1000 do | ||||
| 		y = y + math.sin(k^a * n)/(k^a) | ||||
| 	end | ||||
| 	return 1000*y/math.pi | ||||
| end | ||||
|  | ||||
|  | ||||
| -- caching functions | ||||
|  | ||||
| local ws_values = {} | ||||
| local function get_ws_value(a, x) | ||||
| 	local v = ws_values[a] | ||||
| 	if v then | ||||
| 		v = v[x] | ||||
| 		if v then | ||||
| 			return v | ||||
| 		end | ||||
| 	else | ||||
| 		ws_values[a] = {} | ||||
| 		-- weak table, see https://www.lua.org/pil/17.1.html | ||||
| 		setmetatable(ws_values[a], {__mode = "kv"}) | ||||
| 	end | ||||
| 	v = do_ws_func(a, x) | ||||
| 	ws_values[a][x] = v | ||||
| 	return v | ||||
| end | ||||
|  | ||||
| local plantlike_ids = {} | ||||
| setmetatable(plantlike_ids, {__mode = "kv"}) | ||||
| local function is_plantlike(id) | ||||
| 	if plantlike_ids[id] ~= nil then | ||||
| 		return plantlike_ids[id] | ||||
| 	end | ||||
| 	local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)] | ||||
| 	if not node then | ||||
| 		plantlike_ids[id] = false | ||||
| 		return false | ||||
| 	end | ||||
| 	local drawtype = node.drawtype | ||||
| 	if not drawtype | ||||
| 	or drawtype ~= "plantlike" then | ||||
| 		plantlike_ids[id] = false | ||||
| 		return false | ||||
| 	end | ||||
| 	plantlike_ids[id] = true | ||||
| 	return true | ||||
| end | ||||
|  | ||||
| local snowable_ids = {} | ||||
| setmetatable(snowable_ids, {__mode = "kv"}) | ||||
| local function is_snowable(id) | ||||
| 	if snowable_ids[id] ~= nil then | ||||
| 		return snowable_ids[id] | ||||
| 	end | ||||
| 	local node = minetest.registered_nodes[minetest.get_name_from_content_id(id)] | ||||
| 	if not node then | ||||
| 		snowable_ids[id] = false | ||||
| 		return false | ||||
| 	end | ||||
| 	local drawtype = node.drawtype | ||||
| 	if drawtype | ||||
| 	and drawtype ~= "normal" | ||||
| 	and drawtype ~= "allfaces_optional" | ||||
| 	and drawtype ~= "glasslike" then | ||||
| 		snowable_ids[id] = false | ||||
| 		return false | ||||
| 	end | ||||
| 	snowable_ids[id] = true | ||||
| 	return true | ||||
| end | ||||
|  | ||||
|  | ||||
| local c, replacements, mg_debug, biome_to_string | ||||
| local function define_contents() | ||||
| 	c = { | ||||
| 		dirt_with_grass = minetest.get_content_id("default:dirt_with_grass"), | ||||
| 		dirt = minetest.get_content_id("default:dirt"), | ||||
| 		tree = minetest.get_content_id("default:tree"), | ||||
| 		apple = minetest.get_content_id("default:apple"), | ||||
| 		snow = minetest.get_content_id("default:snow"), | ||||
| 		snow_block = minetest.get_content_id("default:snowblock"), | ||||
| 		dirt_with_snow = minetest.get_content_id("default:dirt_with_snow"), | ||||
| 		air = minetest.get_content_id("air"), | ||||
| 		ignore = minetest.get_content_id("ignore"), | ||||
| 		stone = minetest.get_content_id("default:stone"), | ||||
| 		dry_shrub = minetest.get_content_id("default:dry_shrub"), | ||||
| 		snow_shrub = minetest.get_content_id("snow:shrub_covered"), | ||||
| 		leaves = minetest.get_content_id("default:leaves"), | ||||
| 		jungleleaves = minetest.get_content_id("default:jungleleaves"), | ||||
| 		junglegrass = minetest.get_content_id("default:junglegrass"), | ||||
| 		ice = minetest.get_content_id("default:ice"), | ||||
| 		water = minetest.get_content_id("default:water_source"), | ||||
| 		papyrus = minetest.get_content_id("default:papyrus"), | ||||
| 		sand = minetest.get_content_id("default:sand"), | ||||
| 		desert_sand = minetest.get_content_id("default:desert_sand"), | ||||
| 	} | ||||
| 	replacements = snow.known_plants or {} | ||||
|  | ||||
| 	mg_debug = snow.debug | ||||
| end | ||||
|  | ||||
| local smooth = snow.smooth_biomes | ||||
| local smooth_rarity_max = mg.smooth_rarity_max or 0 | ||||
| local smooth_rarity_min = mg.smooth_rarity_min or 0 | ||||
| local smooth_rarity_dif = mg.smooth_rarity_dif or 0 | ||||
| local nosmooth_rarity = mg.nosmooth_rarity or 0 | ||||
|  | ||||
| snow.register_on_configuring(function(name, v) | ||||
| 	if name == "debug" then | ||||
| 		mg_debug = v | ||||
| 	elseif name == "mapgen_rarity" | ||||
| 	or name == "mapgen_size" | ||||
| 	or name == "smooth_biomes" then | ||||
| 		minetest.after(0, function() | ||||
| 			smooth = snow.smooth_biomes | ||||
| 			smooth_rarity_max = mg.smooth_rarity_max | ||||
| 			smooth_rarity_min = mg.smooth_rarity_min | ||||
| 			smooth_rarity_dif = mg.smooth_rarity_dif | ||||
| 			nosmooth_rarity = mg.nosmooth_rarity | ||||
| 			local scale = mg.perlin_scale | ||||
| 			np_cold = { | ||||
| 				offset = 0, | ||||
| 				scale = 1, | ||||
| 				spread = {x=scale, y=scale, z=scale}, | ||||
| 				seed = 112, | ||||
| 				octaves = 3, | ||||
| 				persist = 0.5 | ||||
| 			} | ||||
| 		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) | ||||
| 	local t1 = os.clock() | ||||
|  | ||||
| 	local x0 = minp.x | ||||
| 	local z0 = minp.z | ||||
| 	local x1 = maxp.x | ||||
| 	local z1 = maxp.z | ||||
|  | ||||
| 	if not c then | ||||
| 		define_contents() | ||||
| 	end | ||||
|  | ||||
| 	local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") | ||||
| 	local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} | ||||
| 	local data = vm:get_data() | ||||
| 	local param2s = vm:get_param2_data() | ||||
|  | ||||
| 	local heightmap = minetest.get_mapgen_object("heightmap") | ||||
|  | ||||
| 	local snow_tab,num = {},1 | ||||
| 	local pines_tab,pnum = {},1 | ||||
|  | ||||
| 	get_perlins(x1 - x0 + 1) | ||||
| 	local nvals_default = perlin_objs.default:get2dMap_flat({x=x0+150, y=z0+50}, nbuf_default) | ||||
| 	local nvals_cold, nvals_ice, ndia | ||||
|  | ||||
| 	-- Choose biomes | ||||
| 	local pr = PseudoRandom(seed+57) | ||||
| 	-- Land biomes | ||||
| 	local biome = pr:next(1, 5) | ||||
| 	local snowy = biome == 1 -- spawns snow | ||||
| 	local alpine = biome == 3 -- rocky terrain | ||||
| 	-- Misc biome settings | ||||
| 	local icy = pr:next(1, 2) == 2   -- if enabled spawns ice in sand instead of snow blocks | ||||
| 	local shrubs = pr:next(1,2) == 1 -- spawns dry shrubs in snow | ||||
| 	local pines = pr:next(1,2) == 1 -- spawns pines | ||||
| 	-- Reseed random | ||||
| 	pr = PseudoRandom(seed+68) | ||||
|  | ||||
| 	local nodes_added | ||||
|  | ||||
| 	-- Loop through columns in chunk | ||||
| 	local is_smooth = smooth and not snowy | ||||
| 	local write_to_map = false | ||||
| 	local ni = 1 | ||||
| 	for z = z0, z1 do | ||||
| 	for x = x0, x1 do | ||||
| 		local in_biome = false | ||||
| 		local test | ||||
| 		if nvals_default[ni] < 0.35 then | ||||
| 			nvals_cold = nvals_cold or perlin_objs.cold:get2dMap_flat({x=x0, y=z0}, nbuf_cold) | ||||
| 			test = math.min(nvals_cold[ni], 1) | ||||
| 			if is_smooth then | ||||
| 				if test >= smooth_rarity_max | ||||
| 				or ( | ||||
| 					test > smooth_rarity_min | ||||
| 					and pr:next(1, 1000) <= ((test-smooth_rarity_min)/smooth_rarity_dif)*1000 | ||||
| 				) then | ||||
| 					in_biome = true | ||||
| 				end | ||||
| 			elseif test > nosmooth_rarity then | ||||
| 				in_biome = true | ||||
| 			end | ||||
| 		end | ||||
|  | ||||
| 		if not in_biome then | ||||
| 			if alpine | ||||
| 			and test | ||||
| 			and test > (is_smooth and smooth_rarity_min or nosmooth_rarity) then | ||||
| 				-- remove trees near alpine | ||||
| 				local ground_y | ||||
| 				if data[area:index(x, maxp.y, z)] == c.air then | ||||
| 					local ytop = math.min(heightmap[ni]+20, maxp.y) | ||||
| 					local vi = area:index(x, ytop, z) | ||||
| 					for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do | ||||
| 						if data[vi] ~= c.air then | ||||
| 							ground_y = y | ||||
| 							break | ||||
| 						end | ||||
| 						vi = vi - area.ystride | ||||
| 					end | ||||
| 				end | ||||
|  | ||||
| 				if ground_y then | ||||
| 					local vi = area:index(x, ground_y, z) | ||||
| 					for _ = minp.y - 16, ground_y do | ||||
| 						local id = data[vi] | ||||
| 						if id == c.leaves | ||||
| 						or id == c.jungleleaves | ||||
| 						or id == c.tree | ||||
| 						or id == c.apple then | ||||
| 							data[vi] = c.air | ||||
| 							nodes_added = true | ||||
| 						else | ||||
| 							break | ||||
| 						end | ||||
| 						vi = vi - area.ystride | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		else | ||||
| 			if not nvals_ice then | ||||
| 				nvals_ice = perlin_objs.ice:get2dMap_flat({x=x0, y=z0}, nbuf_ice) | ||||
|  | ||||
| 				nodes_added = true | ||||
| 				write_to_map = true | ||||
| 			end | ||||
| 			local icetype = nvals_ice[ni] | ||||
| 			local cool = icetype > 0 -- only spawns ice on edge of water | ||||
| 			local icebergs = icetype > -0.2 and icetype <= 0 | ||||
| 			local icehole = icetype > -0.4 and icetype <= -0.2 -- icesheet with holes | ||||
| 			local icesheet = icetype > -0.6 and icetype <= -0.4 | ||||
| 			local icecave = icetype <= -0.6 | ||||
|  | ||||
|  | ||||
| 			local ground_y | ||||
| 			-- avoid generating underground | ||||
| 			if data[area:index(x, maxp.y, z)] == c.air then | ||||
| 				-- search for non air node from 20 m above ground down to 5 m below ground (confined by minp and maxp) | ||||
| 				local ytop = math.min(heightmap[ni]+20, maxp.y) | ||||
| 				local vi = area:index(x, ytop, z) | ||||
| 				for y = ytop, math.max(minp.y, heightmap[ni]-5), -1 do | ||||
| 					if data[vi] ~= c.air then | ||||
| 						ground_y = y | ||||
| 						break | ||||
| 					end | ||||
| 					vi = vi - area.ystride | ||||
| 				end | ||||
| 			end | ||||
|  | ||||
| 			if ground_y then | ||||
| 				local node = area:index(x, ground_y, z) | ||||
| 				local c_ground = data[node] | ||||
|  | ||||
| 				if c_ground == c.dirt_with_grass then | ||||
| 					if alpine | ||||
| 					and test > nosmooth_rarity then | ||||
| 						snow_tab[num] = {ground_y, z, x, test} | ||||
| 						num = num+1 | ||||
| 						-- generate stone ground | ||||
| 						local vi = area:index(x, ground_y, z) | ||||
| 						for _ = math.max(-6, minp.y-6), ground_y do | ||||
| 							if data[vi] == c.stone then | ||||
| 								break | ||||
| 							end | ||||
| 							data[vi] = c.stone | ||||
| 							vi = vi - area.ystride | ||||
| 						end | ||||
| 					elseif pines | ||||
| 					and pr:next(1,36) == 1 then | ||||
| 						pines_tab[pnum] = {x=x, y=ground_y+1, z=z} | ||||
| 						pnum = pnum+1 | ||||
| 					elseif shrubs | ||||
| 					and pr:next(1,928) == 1 then | ||||
| 						data[node] = c.dirt_with_snow | ||||
| 						data[area:index(x, ground_y+1, z)] = c.dry_shrub | ||||
| 					else | ||||
| 						if snowy | ||||
| 						or test > (is_smooth and smooth_rarity_max or | ||||
| 								nosmooth_rarity) then | ||||
| 							-- more, deeper snow | ||||
| 							data[node] = c.snow_block | ||||
| 						else | ||||
| 							data[node] = c.dirt_with_snow | ||||
| 						end | ||||
| 						snow_tab[num] = {ground_y, z, x, test} | ||||
| 						num = num+1 | ||||
| 					end | ||||
| 				elseif c_ground == c.water then | ||||
| 					if not icesheet | ||||
| 					and not icecave | ||||
| 					and not icehole then | ||||
| 						local y = data[node - area.ystride] | ||||
| 						local ice = y ~= c.water and y ~= c.ice | ||||
|  | ||||
| 						if not ice then | ||||
| 							ndia = ndia or { | ||||
| 								area.zstride - 1, | ||||
| 								1, | ||||
| 								-2*area.zstride - 2, | ||||
| 								area.zstride, | ||||
| 								1 - area.zstride, | ||||
| 								0 | ||||
| 							} | ||||
| 							local vi = node + 1 | ||||
| 							for n = 1,6 do | ||||
| 								local i = data[vi] | ||||
| 								if i ~= c.water | ||||
| 								and i ~= c.ice | ||||
| 								and i ~= c.air | ||||
| 								and i ~= c.ignore then | ||||
| 									ice = true | ||||
| 									break | ||||
| 								end | ||||
| 								vi = vi + ndia[n] | ||||
| 							end | ||||
|  | ||||
| 							if not ice | ||||
| 							and (cool or icebergs) | ||||
| 							and pr:next(1,4) == 1 then | ||||
|  | ||||
| 								local vi_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 | ||||
| 						if ice | ||||
| 						or (icebergs and pr:next(1,6) == 1) then | ||||
| 							data[node] = c.ice | ||||
| 						end | ||||
| 					else | ||||
| 						if icesheet | ||||
| 						or icecave | ||||
| 						or (icehole and pr:next(1,10) > 1) then | ||||
| 							data[node] = c.ice | ||||
| 						end | ||||
| 						if icecave then | ||||
| 							local vi = area:index(x, ground_y-1, z) | ||||
| 							for _ = math.max(minp.y-16, -33), ground_y-1 do | ||||
| 								if data[vi] ~= c.water then | ||||
| 									break | ||||
| 								end | ||||
| 								data[vi] = c.air | ||||
| 								vi = vi - area.ystride | ||||
| 							end | ||||
| 						end | ||||
| 						if icesheet then | ||||
| 							-- put snow onto icesheets | ||||
| 							snow_tab[num] = {ground_y, z, x, test} | ||||
| 							num = num+1 | ||||
| 						end | ||||
| 					end | ||||
| 				elseif c_ground == c.sand then | ||||
| 					if icy then | ||||
| 						data[node] = c.ice | ||||
| 					end | ||||
| 					snow_tab[num] = {ground_y, z, x, test} | ||||
| 					num = num+1 | ||||
| 				elseif c_ground == c.papyrus then | ||||
| 					snow_tab[num] = {ground_y, z, x, test} | ||||
| 					num = num+1 | ||||
| 					-- replace papyrus plants with snowblocks | ||||
| 					local vi = area:index(x, ground_y, z) | ||||
| 					for _ = 1,7 do | ||||
| 						if data[vi] ~= c.papyrus then | ||||
| 							break | ||||
| 						end | ||||
| 						data[vi] = c.snow_block | ||||
| 						vi = vi - area.ystride | ||||
| 					end | ||||
| 				elseif alpine then | ||||
| 					-- make stone pillars out of trees and other stuff | ||||
| 					local vi = area:index(x, ground_y, z) | ||||
| 					for _ = 0, ground_y - math.max(-6, minp.y-6) do | ||||
| 						if data[vi] == c.stone then | ||||
| 							break | ||||
| 						end | ||||
| 						data[vi] = c.stone | ||||
| 						vi = vi - area.ystride | ||||
| 					end | ||||
| 					-- put snow onto it | ||||
| 					snow_tab[num] = {ground_y, z, x, test} | ||||
| 					num = num+1 | ||||
| 				elseif c_ground ~= c.desert_sand then | ||||
| 					if is_snowable(c_ground) then | ||||
| 						-- put snow onto it | ||||
| 						snow_tab[num] = {ground_y, z, x, test} | ||||
| 						num = num+1 | ||||
| 					end | ||||
| 					local vi = area:index(x, ground_y, z) | ||||
| 					for _ = 0, 12 do | ||||
| 						local nd = data[vi] | ||||
| 						local plantlike = is_plantlike(nd) | ||||
| 						if replacements[nd] then | ||||
| 							data[vi] = replacements[nd] | ||||
| 							if plantlike then | ||||
| 								param2s[vi] = pr:next(0,179) | ||||
| 							end | ||||
| 						elseif nd == c.dirt_with_grass then | ||||
| 							data[vi] = c.dirt_with_snow | ||||
| 							break | ||||
| 						elseif plantlike then | ||||
| 							local under = vi - area.ystride | ||||
| 							if data[under] == c.dirt_with_grass then | ||||
| 								-- replace other plants with shrubs | ||||
| 								data[vi] = c.snow_shrub | ||||
| 								param2s[vi] = pr:next(0,179) | ||||
| 								data[under] = c.dirt_with_snow | ||||
| 								break | ||||
| 							end | ||||
| 						elseif nd == c.stone then | ||||
| 							break | ||||
| 						end | ||||
| 						vi = vi - area.ystride | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 		ni = ni + 1 | ||||
| 	end | ||||
| 	end | ||||
|  | ||||
| 	-- abort if mapgen doesn't change sth | ||||
| 	if not nodes_added then | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	if num ~= 1 then | ||||
| 		for i = 1, num-1 do | ||||
| 			i = snow_tab[i] | ||||
| 			-- set snow | ||||
| 			data[area:index(i[3], i[1]+1, i[2])] = c.snow | ||||
| 		end | ||||
| 		for k = 1, num-1 do | ||||
| 			local i = snow_tab[k] | ||||
| 			local y,z,x,test = unpack(i) | ||||
| 			test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53) | ||||
| 			if test > 0 then | ||||
| 				local maxh = math.floor(test*10)%10+1 | ||||
| 				if maxh ~= 1 then | ||||
| 					local h = math.floor(get_ws_value(2, x) + get_ws_value(5, z)*5)%10+1 | ||||
| 					if h ~= 1 then | ||||
| 						-- search for nearby snow | ||||
| 						y = y+1 | ||||
| 						for off = -1,1,2 do | ||||
| 							for _,cord in pairs({{x+off,z}, {x,z+off}}) do | ||||
| 								local nd = data[area:index(cord[1], y, cord[2])] | ||||
| 								if nd == c.air | ||||
| 								or is_plantlike(nd) then | ||||
| 									h = h/2 | ||||
| 								end | ||||
| 							end | ||||
| 						end | ||||
| 						h = math.floor(h+0.5) | ||||
| 						if h > 1 then | ||||
| 							-- make snowdrifts walkable | ||||
| 							if h == 10 then | ||||
| 								h = 5 | ||||
| 							end | ||||
| 							h = math.min(maxh, h) | ||||
| 							local vi = area:index(x, y, z) | ||||
| 							if h == 9 then | ||||
| 								-- replace the snow with a snowblock because its a full node | ||||
| 								data[vi] = c.snow_block | ||||
| 							else | ||||
| 								-- set a specific snow height | ||||
| 								param2s[vi] = h*7 | ||||
| 							end | ||||
| 						end | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	-- spawn pines | ||||
| 	if pines | ||||
| 	and pnum ~= 1 then | ||||
| 		local spawn_pine = snow.voxelmanip_pine | ||||
| 		for i = 1, pnum-1 do | ||||
| 			spawn_pine(pines_tab[i], area, data) | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	vm:set_data(data) | ||||
| 	vm:set_param2_data(param2s) | ||||
| 	vm:set_lighting({day=0, night=0}) | ||||
| 	vm:calc_lighting() | ||||
| 	vm:write_to_map() | ||||
|  | ||||
| 	if write_to_map | ||||
| 	and mg_debug then -- print if any column of mapchunk was snow biome | ||||
| 		local biome_string = biome_to_string(biome) | ||||
| 		local chugent = math.ceil((os.clock() - t1) * 1000) | ||||
| 		print("[snow] "..biome_string.." x "..minp.x.." z "..minp.z.." time "..chugent.." ms") | ||||
| 	end | ||||
| end) | ||||
|  | ||||
|  | ||||
| -- Debugging function | ||||
|  | ||||
| local biome_strings = { | ||||
| 	{"snowy", "plain", "alpine", "normal", "normal"}, | ||||
| 	{"cool", "icebergs", "icesheet", "icecave", "icehole"} | ||||
| } | ||||
| function biome_to_string(num) | ||||
| 	local biome = biome_strings[1][num] or "unknown "..num | ||||
| 	return biome | ||||
| end | ||||
							
								
								
									
										237
									
								
								src/mapgen_v7.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,237 @@ | ||||
| --[[minetest.register_biome({ | ||||
| 	name           = "snow_biome_default", | ||||
| 	node_dust = "default:snow", | ||||
| 	node_top       = "default:dirt_with_snow", | ||||
| 	depth_top      = 1, | ||||
| 	node_filler    = "default:dirt", | ||||
| 	depth_filler   = 1, | ||||
| 	node_riverbed = "default:sand", | ||||
| 	depth_riverbed = 2, | ||||
| 	y_min     = 5, | ||||
| 	y_max     = 31000, | ||||
| 	heat_point     = 10.0, | ||||
| 	humidity_point = 40.0, | ||||
| }) | ||||
| ]]-- | ||||
| minetest.register_biome({ | ||||
| 	name           = "snow_biome_forest", | ||||
| 	node_dust = "default:snow", | ||||
| 	node_top       = "default:dirt_with_snow", | ||||
| 	depth_top      = 1, | ||||
| 	node_filler    = "default:dirt", | ||||
| 	depth_filler   = 2, | ||||
| 	node_riverbed = "default:sand", | ||||
| 	depth_riverbed = 2, | ||||
| 	y_min     = 2, | ||||
| 	y_max     = 31000, | ||||
| 	heat_point     = 20.0, | ||||
| 	humidity_point = 70.0, | ||||
| }) | ||||
|  | ||||
| minetest.register_biome({ | ||||
| 	name = "pine_forest", | ||||
| 	node_top = "default:dirt_with_grass", | ||||
| 	depth_top = 1, | ||||
| 	node_filler = "default:dirt", | ||||
| 	depth_filler = 3, | ||||
| 	node_riverbed = "default:sand", | ||||
| 	depth_riverbed = 2, | ||||
| 	y_min = 60, | ||||
| 	y_max = 31000, | ||||
| 	heat_point = 40, | ||||
| 	humidity_point = 68, | ||||
| }) | ||||
|  | ||||
| minetest.register_biome({ | ||||
| 	name           = "snow_biome_lush", | ||||
| 	node_dust = "default:snow", | ||||
| 	node_top       = "default:dirt_with_snow", | ||||
| 	depth_top      = 1, | ||||
| 	node_filler    = "default:dirt", | ||||
| 	depth_filler   = 2, | ||||
| 	node_riverbed = "default:sand", | ||||
| 	depth_riverbed = 2, | ||||
| 	y_min     = 2, | ||||
| 	y_max     = 31000, | ||||
| 	heat_point     = 10.0, | ||||
| 	humidity_point = 70.0, | ||||
| }) | ||||
|  | ||||
| minetest.register_biome({ | ||||
| 	name           = "snow_biome_alpine", | ||||
| 	node_dust = "default:snow", | ||||
| 	node_top       = "default:dirt_with_snow", | ||||
| 	depth_top      = 1, | ||||
| 	node_filler    = "default:stone", | ||||
| 	node_riverbed = "default:gravel", | ||||
| 	depth_riverbed = 2, | ||||
| 	y_min     = 60, | ||||
| 	y_max     = 31000, | ||||
| 	heat_point     = 10.0, | ||||
| 	humidity_point = 40.0, | ||||
| }) | ||||
|  | ||||
| --[[minetest.register_biome({ | ||||
| 	name           = "snow_biome_sand", | ||||
|  | ||||
| 	node_top       = "default:sand", | ||||
| 	depth_top      = 3, | ||||
| 	node_filler    = "default:stone", | ||||
| 	depth_filler   = 0, | ||||
|  | ||||
| 	y_min     = -2, | ||||
| 	y_max     = 31000, | ||||
| 	heat_point     = 10.0, | ||||
| 	humidity_point = 40.0, | ||||
| }) | ||||
| ]]-- | ||||
|  | ||||
| --Pine tree. | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "schematic", | ||||
| 	place_on = {"default:dirt_with_snow", "default:dirt_with_grass", "default:dirt_with_coniferous_litter"}, | ||||
| 	sidelen = 16, | ||||
| 	noise_params = { | ||||
| 		offset = -0.004, | ||||
| 		scale = 0.01, | ||||
| 		spread = {x = 100, y = 100, z = 100}, | ||||
| 		seed = 4087, | ||||
| 		octaves = 3, | ||||
| 		persist = 0.7, | ||||
| 	}, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 4, | ||||
| 	biomes = {"snowy_grassland", "coniferous_forest", "taiga", "snow_biome_alpine"}, | ||||
| 	schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", | ||||
| 	flags = "place_center_x, place_center_z", | ||||
| }) | ||||
|  | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "schematic", | ||||
| 	place_on = {"default:dirt_with_snow", "default:dirt_with_grass"}, | ||||
| 	sidelen = 16, | ||||
| 	noise_params = { | ||||
| 		--offset = 0.036, | ||||
| 		offset = 0.020, | ||||
| 		scale = 0.002, | ||||
| 		spread = {x = 250, y = 250, z = 250}, | ||||
| 		seed = 2861, | ||||
| 		octaves = 3, | ||||
| 		persist = 0.66 | ||||
| 	}, | ||||
| --	fill_ratio = 0.0005, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 4, | ||||
| 	biomes = {"snow_biome_forest", "pine_forest"}, | ||||
| 	schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", | ||||
| 	flags = "place_center_x, place_center_z", | ||||
| }) | ||||
|  | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "schematic", | ||||
| 	place_on = "default:dirt_with_snow", | ||||
| 	sidelen = 16, | ||||
| 	fill_ratio = 0.05, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 4, | ||||
| 	biomes = {"snow_biome_lush"}, | ||||
| 	schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", | ||||
| 	flags = "place_center_x, place_center_z", | ||||
| }) | ||||
|  | ||||
| --Dry shrubs. | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "simple", | ||||
| 	place_on = "default:dirt_with_snow", | ||||
| 	sidelen = 16, | ||||
| 	fill_ratio = 0.001, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 1, | ||||
| 	biomes = {"snowy_grassland"}, | ||||
| 	decoration = "default:dry_shrub", | ||||
| }) | ||||
|  | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "simple", | ||||
| 	place_on = "default:dirt_with_snow", | ||||
| 	sidelen = 16, | ||||
| 	fill_ratio = 0.01, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 1, | ||||
| 	biomes = {"snow_biome_forest", "snow_biome_lush"}, | ||||
| 	decoration = "default:dry_shrub", | ||||
| }) | ||||
|  | ||||
| --Snow shrubs. | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "simple", | ||||
| 	place_on = "default:dirt_with_snow", | ||||
| 	sidelen = 16, | ||||
| 	fill_ratio = 0.005, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 1, | ||||
| 	biomes = {"snowy_grassland"}, | ||||
| 	decoration = "snow:shrub_covered", | ||||
| }) | ||||
|  | ||||
| minetest.register_decoration({ | ||||
| 	deco_type = "simple", | ||||
| 	place_on = "default:dirt_with_snow", | ||||
| 	sidelen = 16, | ||||
| 	fill_ratio = 0.05, | ||||
| 	y_max = 31000, | ||||
| 	y_min = 1, | ||||
| 	biomes = {"snow_biome_forest", "snow_biome_lush"}, | ||||
| 	decoration = "snow:shrub_covered", | ||||
| }) | ||||
|  | ||||
| -- Snow Flowers | ||||
| local function register_flower(seed, name) | ||||
| 	minetest.register_decoration({ | ||||
| 		deco_type = "simple", | ||||
| 		place_on = {"default:dirt_with_snow"}, | ||||
| 		sidelen = 16, | ||||
| 		noise_params = { | ||||
| 			offset = -0.015, | ||||
| 			scale = 0.025, | ||||
| 			spread = {x = 200, y = 200, z = 200}, | ||||
| 			seed = seed, | ||||
| 			octaves = 3, | ||||
| 			persist = 0.6 | ||||
| 		}, | ||||
| 		biomes = {"snow_biome_lush", "snow_biome_forest", "taiga", "snowy_grassland", "tundra"}, | ||||
| 		y_min = 1, | ||||
| 		y_max = 31000, | ||||
| 		decoration = "snow:flower_"..name, | ||||
| 	}) | ||||
| end | ||||
|  | ||||
| register_flower(436,     "rose") | ||||
| register_flower(19822,   "tulip") | ||||
| register_flower(1220999, "dandelion_yellow") | ||||
| register_flower(36662,   "geranium") | ||||
| register_flower(1133,    "viola") | ||||
| register_flower(73133,   "dandelion_white") | ||||
|  | ||||
| --Snow. | ||||
| --minetest.register_decoration({ | ||||
| --	deco_type = "simple", | ||||
| --	place_on = "default:dirt_with_snow", | ||||
| --	sidelen = 16, | ||||
| --	fill_ratio = 10, | ||||
| --	y_max = 31000, | ||||
| --	y_min = 1, | ||||
| --	biomes = {"snow_biome_forest", "snow_biome_lush"}, | ||||
| --	decoration = "default:snow", | ||||
| --}) | ||||
|  | ||||
| --minetest.register_decoration({ | ||||
| --	deco_type = "simple", | ||||
| --	place_on = "default:stone", | ||||
| --	sidelen = 16, | ||||
| --	fill_ratio = 10, | ||||
| --	y_max = 31000, | ||||
| --	y_min = 1, | ||||
| --	biomes = {"snow_biome_alpine"}, | ||||
| --	decoration = "default:snow", | ||||
| --}) | ||||
							
								
								
									
										566
									
								
								src/nodes.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,566 @@ | ||||
| -- NODES | ||||
|  | ||||
| -- Grow sapling | ||||
|  | ||||
| local function grow_pine_tree(pos) | ||||
| 	local path = minetest.get_modpath("snow").."/schematics/snow_pine_from_sapling.mts" | ||||
| 	minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "0", nil, false) | ||||
| end | ||||
|  | ||||
| local function grow_snowy_pine_tree(pos) | ||||
| 	local path = minetest.get_modpath("snow").."/schematics/snowy_snow_pine_from_sapling.mts" | ||||
| 	minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) | ||||
| end | ||||
|  | ||||
| local function grow_xmas_tree(pos) | ||||
| 	local path = minetest.get_modpath("snow").."/schematics/snow_xmas_from_sapling.mts" | ||||
| 	minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "0", nil, false) | ||||
| end | ||||
|  | ||||
| local function grow_snowy_xmas_tree(pos) | ||||
| 	local path = minetest.get_modpath("snow").."/schematics/snowy_snow_xmas_from_sapling.mts" | ||||
| 	minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) | ||||
| end | ||||
|  | ||||
| local function is_snow_nearby(pos) | ||||
| 	return minetest.find_node_near(pos, 1, {"group:snowy"}) | ||||
| end | ||||
|  | ||||
| local function grow_sapling(pos) | ||||
| 	if not default.can_grow(pos) then | ||||
| 		-- try again 5 min later | ||||
| 		minetest.get_node_timer(pos):start(300) | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	local node = minetest.get_node(pos) | ||||
| 	if node.name == "snow:sapling_pine" then | ||||
| 		minetest.log("action", "A Snow Pine sapling grows into a tree at "..minetest.pos_to_string(pos)) | ||||
| 		if is_snow_nearby(pos) then | ||||
| 			grow_snowy_pine_tree(pos) | ||||
| 		else | ||||
| 			grow_pine_tree(pos) | ||||
| 		end | ||||
| 	elseif node.name == "snow:xmas_tree" then | ||||
| 		minetest.log("action", "A Christmas sapling grows into a tree at "..minetest.pos_to_string(pos)) | ||||
| 		if is_snow_nearby(pos) then | ||||
| 			grow_snowy_xmas_tree(pos) | ||||
| 		else | ||||
| 			grow_xmas_tree(pos) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
| minetest.register_lbm({ | ||||
| 	name = "snow:convert_saplings_to_node_timer", | ||||
| 	nodenames = {"snow:sapling_pine", "snow:xmas_tree"}, | ||||
| 	action = function(pos) | ||||
| 		minetest.get_node_timer(pos):start(math.random(300, 1500)) | ||||
| 	end | ||||
| }) | ||||
|  | ||||
| -- Pine Needles | ||||
| local nodedef = table.copy(minetest.registered_nodes["default:pine_needles"]) | ||||
| nodedef.description = "Snow Pine Needles" | ||||
| nodedef.drop = { | ||||
| 	max_items = 1, | ||||
| 	items = { | ||||
| 		{ | ||||
| 			-- player will get sapling with 1/20 chance | ||||
| 			items = {'snow:sapling_pine'}, | ||||
| 			rarity = 20, | ||||
| 		}, | ||||
| 		{ | ||||
| 			items = {'snow:needles'}, | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| --[[ | ||||
| If christmas_content is enabled, then this next part will override the pine needles' drop code | ||||
| (in the code section above) and adds Xmas tree saplings to the items that are dropped. | ||||
| The Xmas tree needles are registred and defined a farther down in this nodes.lua file. | ||||
|  | ||||
| ~ LazyJ | ||||
| ]]-- | ||||
| if snow.christmas_content then | ||||
| 	table.insert(nodedef.drop.items, 1, { | ||||
| 		-- player will get xmas tree with 1/120 chance | ||||
| 		items = {"snow:xmas_tree"}, | ||||
| 		rarity = 120, | ||||
| 	}) | ||||
| end | ||||
|  | ||||
| minetest.register_node("snow:needles", table.copy(nodedef)) | ||||
|  | ||||
| snow.register_on_configuring(function(name, v) | ||||
| 	if name == "christmas_content" then | ||||
| 		local drop = minetest.registered_nodes["snow:needles"].drop | ||||
| 		if v then | ||||
| 			table.insert(drop.items, 1, { | ||||
| 				items = {"snow:xmas_tree"}, | ||||
| 				rarity = 120, | ||||
| 			}) | ||||
| 		else | ||||
| 			table.remove(drop.items, 1) | ||||
| 		end | ||||
| 		minetest.override_item("snow:needles", {drop = drop}) | ||||
| 	end | ||||
| end) | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Christmas egg | ||||
| if minetest.global_exists("skins") then | ||||
| 	skins.add("character_snow_man") | ||||
| end | ||||
|  | ||||
|  | ||||
| -- Decorated Pine Leaves | ||||
|  | ||||
| nodedef.description ="Decorated "..nodedef.description | ||||
| nodedef.light_source = 5 | ||||
| nodedef.waving = nil | ||||
| if snow.disable_deco_needle_ani then | ||||
| 	nodedef.tiles = {"snow_needles_decorated.png"} | ||||
| else | ||||
| 	-- Animated, "blinking lights" version. ~ LazyJ | ||||
| 	nodedef.inventory_image = minetest.inventorycube("snow_needles_decorated.png") | ||||
| 	nodedef.tiles = {{ | ||||
| 		name="snow_needles_decorated_animated.png", | ||||
| 		animation={type="vertical_frames", aspect_w=16, aspect_h=16, | ||||
| 			length=20.0} | ||||
| 	}} | ||||
| end | ||||
| nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}} | ||||
|  | ||||
| minetest.register_node("snow:needles_decorated", table.copy(nodedef)) | ||||
|  | ||||
| -- Leaf decay | ||||
|  | ||||
| default.register_leafdecay{ | ||||
| 	trunks = {"default:pine_tree"}, | ||||
| 	leaves = {"snow:needles", "default:pine_needles", "snow:needles_decorated"}, | ||||
| 	radius = 2, | ||||
| } | ||||
|  | ||||
| -- Saplings | ||||
|  | ||||
| nodedef = table.copy(minetest.registered_nodes["default:pine_sapling"]) | ||||
| nodedef.description = "Snow Pine Sapling" | ||||
| nodedef.tiles = {"snow_sapling_pine.png"} | ||||
| nodedef.inventory_image = "snow_sapling_pine.png" | ||||
| nodedef.wield_image = "snow_sapling_pine.png" | ||||
| nodedef.on_timer = grow_sapling | ||||
| nodedef.on_place = function(itemstack, placer, pointed_thing) | ||||
| 	itemstack = default.sapling_on_place( | ||||
| 		itemstack, | ||||
| 		placer, | ||||
| 		pointed_thing, | ||||
| 		"snow:sapling_pine", | ||||
| 		{x = -2, y = 1, z = -2}, | ||||
| 		{x = 2, y = 13, z = 2}, | ||||
| 		4) | ||||
| 	return itemstack | ||||
| end | ||||
|  | ||||
| -- Pine Sapling | ||||
| minetest.register_node("snow:sapling_pine", table.copy(nodedef)) | ||||
|  | ||||
| -- Xmas Tree Sapling | ||||
| nodedef.description = "Christmas Tree" | ||||
| nodedef.tiles = {"snow_xmas_tree.png"} | ||||
| nodedef.inventory_image = "snow_xmas_tree.png" | ||||
| nodedef.wield_image = "snow_xmas_tree.png" | ||||
| nodedef.on_place = function(itemstack, placer, pointed_thing) | ||||
| 	itemstack = default.sapling_on_place( | ||||
| 		itemstack, | ||||
| 		placer, | ||||
| 		pointed_thing, | ||||
| 		"snow:xmas_tree", | ||||
| 		{x= -2, y = 1, z = -2}, | ||||
| 		{x = 2, y = 14, z = 2}, | ||||
| 		4) | ||||
| 	return itemstack | ||||
| end | ||||
|  | ||||
| minetest.register_node("snow:xmas_tree", nodedef) | ||||
|  | ||||
| -- Star | ||||
| nodedef = { | ||||
| 	description = "Star", | ||||
| 	drawtype = "plantlike", | ||||
| 	tiles = {"snow_star.png"}, | ||||
| 	inventory_image = "snow_star.png", | ||||
| 	wield_image = "snow_star.png", | ||||
| 	paramtype = "light", | ||||
| 	walkable = false, | ||||
| 	-- Don't want the ornament breaking too easily because you have to punch it to turn it on and off. ~ LazyJ | ||||
| 	groups = {cracky=1, crumbly=1, choppy=1, oddly_breakable_by_hand=1}, | ||||
| 	-- Breaking "glass" sound makes it sound like a real, broken, Xmas tree | ||||
| 	-- ornament (Sorry, Mom!).  ;)-  ~ LazyJ | ||||
| 	sounds = default.node_sound_glass_defaults( | ||||
| 		{dig = {name="default_glass_footstep", gain=0.2}}), | ||||
| 	-- Added a "lit" star that can be punched on or off depending on your | ||||
| 	-- preference. ~ LazyJ | ||||
| 	on_punch = function(pos, node) | ||||
| 		node.name = "snow:star_lit" | ||||
| 		minetest.set_node(pos, node) | ||||
| 	end, | ||||
| } | ||||
|  | ||||
| -- Star on Xmas Trees | ||||
| minetest.register_node("snow:star", table.copy(nodedef)) | ||||
|  | ||||
| -- Star (Lit Version) on Xmas Trees | ||||
| nodedef.description = nodedef.description.." Lighted" | ||||
| nodedef.light_source = minetest.LIGHT_MAX | ||||
| nodedef.tiles = {"snow_star_lit.png"} | ||||
| nodedef.drop = "snow:star" | ||||
| nodedef.groups.not_in_creative_inventory = 1 | ||||
| nodedef.on_punch = function(pos, node) | ||||
| 	node.name = "snow:star" | ||||
| 	minetest.set_node(pos, node) | ||||
| end | ||||
|  | ||||
| minetest.register_node("snow:star_lit", nodedef) | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Plants | ||||
|  | ||||
| -- Moss | ||||
| minetest.register_node("snow:moss", { | ||||
| 	description = "Moss", | ||||
| 	inventory_image = "snow_moss.png", | ||||
| 	tiles = {"snow_moss.png"}, | ||||
| 	drawtype = "signlike", | ||||
| 	paramtype = "light", | ||||
| 	paramtype2 = "wallmounted", | ||||
| 	walkable = false, | ||||
| 	selection_box = { | ||||
| 		type = "wallmounted", | ||||
| 	}, | ||||
| 	is_ground_content = true, | ||||
| 	groups = {crumbly=3, attached_node=1}, | ||||
| 	furnace_burntime = 3, | ||||
| }) | ||||
|  | ||||
| -- Shrub(s) | ||||
| nodedef = { | ||||
| 	description = "Snow Shrub", | ||||
| 	tiles = {"snow_shrub.png"}, | ||||
| 	inventory_image = "snow_shrub.png", | ||||
| 	wield_image = "snow_shrub.png", | ||||
| 	drawtype = "plantlike", | ||||
| 	paramtype = "light", | ||||
| 	waving = 1, | ||||
| 	sunlight_propagates = true, | ||||
| 	walkable = false, | ||||
| 	is_ground_content = true, | ||||
| 	buildable_to = true, | ||||
| 	groups = {snappy=3,flammable=3,attached_node=1}, | ||||
| 	sounds = default.node_sound_leaves_defaults(), | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
| 		fixed = {-0.3, -0.5, -0.3, 0.3, -5/16, 0.3}, | ||||
| 	}, | ||||
| 	furnace_burntime = 5, | ||||
| } | ||||
| minetest.register_node("snow:shrub", table.copy(nodedef)) | ||||
|  | ||||
| nodedef.tiles = {"snow_shrub.png^snow_shrub_covering.png"} | ||||
| nodedef.inventory_image = "snow_shrub.png^snow_shrub_covering.png" | ||||
| nodedef.wield_image = "snow_shrub.png^snow_shrub_covering.png" | ||||
| nodedef.paramtype2 = "degrotate" | ||||
| nodedef.drop = "snow:shrub" | ||||
| nodedef.furnace_burntime = 3 | ||||
| minetest.register_node("snow:shrub_covered", nodedef) | ||||
|  | ||||
| -- Flowers | ||||
| if rawget(_G, "flowers") then | ||||
| 	-- broken flowers | ||||
| 	snow.known_plants = {} | ||||
| 	for _,name in pairs({"dandelion_yellow", "geranium", "rose", "tulip", "dandelion_white", "viola"}) do | ||||
| 		local flowername = "flowers:"..name | ||||
| 		local newname = "snow:flower_"..name | ||||
| 		local flower = minetest.registered_nodes[flowername] | ||||
| 		minetest.register_node(newname, { | ||||
| 			drawtype = "plantlike", | ||||
| 			tiles = { "snow_" .. name .. ".png" }, | ||||
| 			sunlight_propagates = true, | ||||
| 			paramtype = "light", | ||||
| 			paramtype2 = "degrotate", | ||||
| 			walkable = false, | ||||
| 			drop = "", | ||||
| 			groups = {snappy=3, attached_node = 1}, | ||||
| 			sounds = default.node_sound_leaves_defaults(), | ||||
| 			selection_box = flower.selection_box | ||||
| 		}) | ||||
| 		snow.known_plants[minetest.get_content_id(flowername)] = minetest.get_content_id(newname) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| -- Leaves | ||||
| --[[local leaves = minetest.registered_nodes["default:leaves"] | ||||
| nodedef = { | ||||
| 	description = "Snow Leaves", | ||||
| 	tiles = {"snow_leaves.png"}, | ||||
| 	waving = 1, | ||||
| 	visual_scale = leaves.visual_scale, | ||||
| 	drawtype = leaves.drawtype, | ||||
| 	paramtype = leaves.paramtype, | ||||
| 	groups = leaves.groups, | ||||
| 	drop = leaves.drop, | ||||
| 	sounds = leaves.sounds, | ||||
| } | ||||
| nodedef.groups.flammable = 1 | ||||
|  | ||||
| minetest.register_node("snow:leaves", nodedef) | ||||
| snow.known_plants[minetest.get_content_id("default:leaves")] = minetest.get_content_id("snow:leaves") | ||||
|  | ||||
| local apple = minetest.registered_nodes["default:apple"] | ||||
| nodedef = { | ||||
| 	description = "Snow Apple", | ||||
| 	drawtype = "plantlike", | ||||
| 	tiles = {"snow_apple.png"}, | ||||
| 	paramtype = "light", | ||||
| 	paramtype2 = "degrotate", | ||||
| 	walkable = false, | ||||
| 	sunlight_propagates = apple.sunlight_propagates, | ||||
| 	selection_box = apple.selection_box, | ||||
| 	groups = apple.groups, | ||||
| 	sounds = apple.sounds, | ||||
| 	drop = apple.drop, | ||||
| } | ||||
| nodedef.groups.flammable = 1 | ||||
|  | ||||
| minetest.register_node("snow:apple", nodedef) | ||||
| snow.known_plants[minetest.get_content_id("default:apple")] = minetest.get_content_id("snow:apple") | ||||
|  | ||||
| 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 | ||||
| snow.known_plants[minetest.get_content_id("default:jungleleaves")] = minetest.get_content_id("default:jungleleaves") | ||||
|  | ||||
|  | ||||
|  | ||||
| local function snow_onto_dirt(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 | ||||
| 		minetest.set_node(pos, {name = "default:dirt_with_snow"}) | ||||
| 	end | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Bricks | ||||
|  | ||||
| nodedef = { | ||||
| 	description = "Snow Brick", | ||||
| 	tiles = {"snow_snow_brick.png"}, | ||||
| 	is_ground_content = true, | ||||
| 	--freezemelt = "default:water_source", -- deprecated | ||||
| 	liquidtype = "none", | ||||
| 	paramtype = "light", | ||||
| 	sunlight_propagates = true, | ||||
| 	paramtype2 = "facedir", -- Allow blocks to be rotated with the screwdriver or | ||||
| 	-- by player position. ~ LazyJ | ||||
| 	 -- I made this a little harder to dig than snow blocks because | ||||
| 	 -- I imagine snow brick as being much more dense and solid than fluffy snow. ~ LazyJ | ||||
| 	groups = {cracky=2, crumbly=2, choppy=2, oddly_breakable_by_hand=2, melts=1, icemaker=1, cooks_into_ice=1, cools_lava = 1, snowy = 1}, | ||||
| 	 --Let's use the new snow sounds instead of the old grass sounds. ~ LazyJ | ||||
| 	sounds = default.node_sound_snow_defaults(), | ||||
| 	-- The "on_construct" part below, thinking in terms of layers, | ||||
| 	-- dirt_with_snow could also double as dirt_with_frost which adds subtlety | ||||
| 	-- to the winterscape. ~ LazyJ | ||||
| 	on_construct = snow_onto_dirt | ||||
| } | ||||
|  | ||||
| -- Snow Brick | ||||
| minetest.register_node("snow:snow_brick", table.copy(nodedef)) | ||||
|  | ||||
| -- hard Ice Brick, original texture from LazyJ | ||||
| local ibdef = table.copy(nodedef) | ||||
| ibdef.description = "Ice Brick" | ||||
| ibdef.tiles = {"snow_ice_brick.png"} | ||||
| ibdef.use_texture_alpha = "blend" | ||||
| ibdef.drawtype = "glasslike" | ||||
| ibdef.groups = {cracky=1, crumbly=1, choppy=1, melts=1, cools_lava = 1, slippery = 3} | ||||
| ibdef.sounds = default.node_sound_ice_defaults() | ||||
|  | ||||
| minetest.register_node("snow:ice_brick", ibdef) | ||||
|  | ||||
|  | ||||
| -- Snow Cobble  ~ LazyJ | ||||
| -- Described as Icy Snow | ||||
| nodedef.description = "Icy Snow" | ||||
| nodedef.tiles = {"snow_snow_cobble.png"} | ||||
|  | ||||
| minetest.register_node("snow:snow_cobble", nodedef) | ||||
|  | ||||
| -- Override Default Nodes to Add Extra Functions | ||||
|  | ||||
| local groups = minetest.registered_nodes["default:ice"].groups | ||||
| groups["melt"] = 1 | ||||
| minetest.override_item("default:ice", { | ||||
| 	drawtype = "glasslike", | ||||
| 	use_texture_alpha = "blend", | ||||
| 	param2 = 0,  --param2 is reserved for how much ice will freezeover. | ||||
| 	sunlight_propagates = true,  -- necessary for dirt_with_grass/snow/just dirt ABMs | ||||
| 	tiles = {"snow_ice.png^[brighten"}, | ||||
| 	liquidtype = "none", | ||||
| 	groups = groups, | ||||
| 	on_construct = snow_onto_dirt, | ||||
| 	liquids_pointable = true, | ||||
| 	--Make ice freeze over when placed by a maximum of 10 blocks. | ||||
| 	after_place_node = function(pos) | ||||
| 		minetest.set_node(pos, {name="default:ice", param2=math.random(0,10)}) | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| groups = minetest.registered_nodes["default:snowblock"].groups | ||||
| for g,v in pairs({melts=1, icemaker=1, cooks_into_ice=1, falling_node=1}) do | ||||
| 	groups[g] = v | ||||
| end | ||||
| minetest.override_item("default:snowblock", { | ||||
| 	liquidtype = "none", | ||||
| 	paramtype = "light", | ||||
| 	sunlight_propagates = true, | ||||
| 	on_construct = snow_onto_dirt, | ||||
| 	groups = groups, | ||||
| }) | ||||
|  | ||||
| minetest.override_item("default:snow", { | ||||
| 	drop = { | ||||
| 		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 | ||||
| }) | ||||
							
								
								
									
										249
									
								
								src/sled.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,249 @@ | ||||
| --[[ | ||||
| --================= | ||||
| --====================================== | ||||
| LazyJ's Fork of Splizard's "Snow" Mod | ||||
| by LazyJ | ||||
| version: Umpteen and 7/5ths something or another. | ||||
| 2014_04_12 | ||||
| --====================================== | ||||
| --================= | ||||
|  | ||||
|  | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
| THE LIST OF CHANGES I'VE MADE | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
|  | ||||
|  | ||||
| * The HUD message that displayed when a player sat on the sled would not go away after the player | ||||
| got off the sled. I spent hours on trial-and-error while reading the lua_api.txt and scrounging | ||||
| the Internet for a needle-in-the-haystack solution as to why the hud_remove wasn't working. | ||||
| Turns out Splizard's code was mostly correct, just not assembled in the right order. | ||||
|  | ||||
| The key to the solution was found in the code of leetelate's scuba mod: | ||||
| http://forum.minetest.net/viewtopic.php?id=7175 | ||||
|  | ||||
| * Changed the wording of the HUD message for clarity. | ||||
|  | ||||
|  | ||||
| ~~~~~~ | ||||
| TODO | ||||
| ~~~~~~ | ||||
|  | ||||
| * Figure out why the player avatars remain in a seated position, even after getting off the sled, | ||||
| if they flew while on the sled. 'default.player_set_animation', where is a better explanation | ||||
| for this and what are it's available options? | ||||
|  | ||||
| * Go through, clean-up my notes and get them better sorted. Some are in the code, some are | ||||
| scattered in my note-taking program. This "Oh, I'll just make a little tweak here and a | ||||
| little tweak there" project has evolved into something much bigger and more complex | ||||
| than I originally planned. :p  ~ LazyJ | ||||
|  | ||||
| * find out why the sled disappears after rightclicking it ~ HybridDog | ||||
|  | ||||
| --]] | ||||
|  | ||||
|  | ||||
|  | ||||
| --============================================================= | ||||
| -- CODE STUFF | ||||
| --============================================================= | ||||
|  | ||||
| -- | ||||
| -- Helper functions | ||||
| -- | ||||
|  | ||||
| local function table_find(t, v) | ||||
| 	for i = 1,#t do | ||||
| 		if t[i] == v then | ||||
| 			return true | ||||
| 		end | ||||
| 	end | ||||
| 	return false | ||||
| end | ||||
|  | ||||
| local function is_water(pos) | ||||
| 	return minetest.get_item_group(minetest.get_node(pos).name, "water") ~= 0 | ||||
| end | ||||
|  | ||||
|  | ||||
| -- | ||||
| -- Sled entity | ||||
| -- | ||||
|  | ||||
| local sled = { | ||||
| 	physical = true, | ||||
| 	collisionbox = {-0.6,-0.25,-0.6, 0.6,0.3,0.6}, | ||||
| 	visual = "mesh", | ||||
| 	mesh = "sled.x", | ||||
| 	textures = {"sled.png"}, | ||||
| } | ||||
|  | ||||
| local players_sled = {} | ||||
| local function join_sled(self, player) | ||||
| 	local pos = self.object:getpos() | ||||
| 	player:setpos(pos) | ||||
| 	local name = player:get_player_name() | ||||
| 	players_sled[name] = true | ||||
| 	default.player_attached[name] = true | ||||
| 	default.player_set_animation(player, "sit" , 30) | ||||
| 	self.driver = name | ||||
| 	self.object:set_attach(player, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0}) | ||||
| 	self.object:setyaw(player:get_look_yaw())-- - math.pi/2) | ||||
| end | ||||
|  | ||||
| local function leave_sled(self, player) | ||||
| 	local name = player:get_player_name() | ||||
| 	players_sled[name] = false | ||||
| 	self.driver = nil | ||||
| 	self.object:set_detach() | ||||
| 	default.player_attached[name] = false | ||||
| 	default.player_set_animation(player, "stand" , 30) | ||||
|  | ||||
| 	player:set_physics_override({ | ||||
| 		speed = 1, | ||||
| 		jump = 1, | ||||
| 	}) | ||||
| 	player:hud_remove(self.HUD) -- And here is part 2. ~ LazyJ | ||||
| 	self.object:remove() | ||||
|  | ||||
| 	--Give the sled back again | ||||
| 	player:get_inventory():add_item("main", "snow:sled") | ||||
| end | ||||
|  | ||||
| local function sled_rightclick(self, player) | ||||
| 	if self.driver then | ||||
| 		return | ||||
| 	end | ||||
| 	join_sled(self, player) | ||||
| 	player:set_physics_override({ | ||||
| 		speed = 2, -- multiplier to default value | ||||
| 		jump = 0, -- multiplier to default value | ||||
| 	}) | ||||
|  | ||||
| -- Here is part 1 of the fix. ~ LazyJ | ||||
| 	self.HUD = player:hud_add({ | ||||
| 		hud_elem_type = "text", | ||||
| 		position = {x=0.5, y=0.89}, | ||||
| 		name = "sled", | ||||
| 		scale = {x=2, y=2}, | ||||
| 		text = "You are on the sled! Hold the sneak key to get off the sled.", -- LazyJ | ||||
| 		direction = 0, | ||||
| 	}) | ||||
| -- End part 1 | ||||
| end | ||||
|  | ||||
| local on_sled_click | ||||
| if snow.sleds then | ||||
| 	on_sled_click = sled_rightclick | ||||
| else | ||||
| 	on_sled_click = function() end | ||||
| end | ||||
|  | ||||
| snow.register_on_configuring(function(name, v) | ||||
| 	if name == "sleds" then | ||||
| 		if v then | ||||
| 			on_sled_click = sled_rightclick | ||||
| 		else | ||||
| 			on_sled_click = function() end | ||||
| 		end | ||||
| 	end | ||||
| end) | ||||
|  | ||||
| function sled:on_rightclick(player) | ||||
| 	on_sled_click(self, player) | ||||
| end | ||||
|  | ||||
| function sled:on_activate(staticdata) | ||||
| 	self.object:set_armor_groups({immortal=1}) | ||||
| 	self.object:setacceleration({x=0, y=-10, z=0}) | ||||
| 	if staticdata then | ||||
| 		self.v = tonumber(staticdata) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| function sled:get_staticdata() | ||||
| 	return tostring(self.v) | ||||
| end | ||||
|  | ||||
| function sled:on_punch(puncher) | ||||
| 	self.object:remove() | ||||
| 	if puncher | ||||
| 	and puncher:is_player() then | ||||
| 		puncher:get_inventory():add_item("main", "snow:sled") | ||||
| 	end | ||||
| end | ||||
|  | ||||
| local driveable_nodes = {"default:snow","default:snowblock","default:ice","default:dirt_with_snow", "group:icemaker"} | ||||
| local function accelerating_possible(pos) | ||||
| 	if is_water(pos) then | ||||
| 		return false | ||||
| 	end | ||||
| 	if table_find(driveable_nodes, minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name) then | ||||
| 		return true | ||||
| 	end | ||||
| 	return false | ||||
| end | ||||
|  | ||||
| local timer = 0 | ||||
| function sled:on_step(dtime) | ||||
| 	if not self.driver then | ||||
| 		return | ||||
| 	end | ||||
| 	timer = timer+dtime | ||||
| 	if timer < 1 then | ||||
| 		return | ||||
| 	end | ||||
| 	timer = 0 | ||||
| 	local player = minetest.get_player_by_name(self.driver) | ||||
| 	if not player then | ||||
| 		return | ||||
| 	end | ||||
| 	if player:get_player_control().sneak | ||||
| 	or not accelerating_possible(vector.round(self.object:getpos())) then | ||||
| 		leave_sled(self, player) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| minetest.register_entity("snow:sled", sled) | ||||
|  | ||||
|  | ||||
| minetest.register_craftitem("snow:sled", { | ||||
| 	description = "Sled", | ||||
| 	inventory_image = "snow_sled.png", | ||||
| 	wield_image = "snow_sled.png", | ||||
| 	wield_scale = {x=2, y=2, z=1}, | ||||
| 	liquids_pointable = true, | ||||
| 	stack_max = 1, | ||||
|  | ||||
| 	on_use = function(itemstack, placer) | ||||
| 		if players_sled[placer:get_player_name()] then | ||||
| 			return | ||||
| 		end | ||||
| 		local pos = placer:getpos() | ||||
| 		if accelerating_possible(vector.round(pos)) then | ||||
| 			pos.y = pos.y+0.5 | ||||
|  | ||||
| 			--Get on the sled and remove it from inventory. | ||||
| 			minetest.add_entity(pos, "snow:sled"):right_click(placer) | ||||
| 			itemstack:take_item(); return itemstack | ||||
| 		end | ||||
| 	end, | ||||
| }) | ||||
|  | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:sled", | ||||
| 	recipe = { | ||||
| 		{"", "", ""}, | ||||
| 		{"group:stick", "", ""}, | ||||
| 		{"group:wood", "group:wood", "group:wood"}, | ||||
| 	}, | ||||
| }) | ||||
| minetest.register_craft({ | ||||
| 	output = "snow:sled", | ||||
| 	recipe = { | ||||
| 		{"", "", ""}, | ||||
| 		{"", "", "group:stick"}, | ||||
| 		{"group:wood", "group:wood", "group:wood"}, | ||||
| 	}, | ||||
| }) | ||||
							
								
								
									
										337
									
								
								src/snowball.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,337 @@ | ||||
| --============ | ||||
| --Snowballs | ||||
| --============ | ||||
|  | ||||
| -- Snowballs were destroying nodes if the snowballs landed just right. | ||||
| -- Quite a bit of trial-and-error learning here and it boiled down to a | ||||
| -- small handful of code lines making the difference. ~ LazyJ | ||||
|  | ||||
| local creative_mode = minetest.settings:get_bool("creative_mode") | ||||
|  | ||||
|  | ||||
| local snowball_velocity, entity_attack_delay | ||||
| local function update_snowball_vel(v) | ||||
| 	snowball_velocity = v | ||||
| 	local walkspeed = tonumber(minetest.settings:get("movement_speed_walk")) or 4 | ||||
| 	entity_attack_delay = (walkspeed+1)/v | ||||
| end | ||||
| update_snowball_vel(snow.snowball_velocity) | ||||
|  | ||||
| local snowball_gravity = snow.snowball_gravity | ||||
| snow.register_on_configuring(function(name, v) | ||||
| 	if name == "snowball_velocity" then | ||||
| 		update_snowball_vel(v) | ||||
| 	elseif name == "snowball_gravity" then | ||||
| 		snowball_gravity = v | ||||
| 	end | ||||
| end) | ||||
|  | ||||
| local function get_gravity() | ||||
| 	local grav = tonumber(minetest.settings:get("movement_gravity")) or 9.81 | ||||
| 	return grav*snowball_gravity | ||||
| end | ||||
|  | ||||
| local someone_throwing, just_activated | ||||
|  | ||||
| --Shoot snowball | ||||
| function snow.shoot_snowball(item, player) | ||||
| 	local addp = {y = 1.625} -- + (math.random()-0.5)/5} | ||||
| 	local dir = player:get_look_dir() | ||||
| 	local dif = 2*math.sqrt(dir.z*dir.z+dir.x*dir.x) | ||||
| 	addp.x = dir.z/dif -- + (math.random()-0.5)/5 | ||||
| 	addp.z = -dir.x/dif -- + (math.random()-0.5)/5 | ||||
| 	local pos = vector.add(player:getpos(), addp) | ||||
| 	local obj = minetest.add_entity(pos, "snow:snowball_entity") | ||||
| 	obj:setvelocity(vector.multiply(dir, snowball_velocity)) | ||||
| 	obj:setacceleration({x=dir.x*-3, y=-get_gravity(), z=dir.z*-3}) | ||||
| 	obj:get_luaentity().thrower = player:get_player_name() | ||||
| 	if creative_mode then | ||||
| 		if not someone_throwing then | ||||
| 			someone_throwing = true | ||||
| 			just_activated = true | ||||
| 		end | ||||
| 		return | ||||
| 	end | ||||
| 	item:take_item() | ||||
| 	return item | ||||
| end | ||||
|  | ||||
| if creative_mode then | ||||
| 	local function update_step() | ||||
| 		local active | ||||
| 		for _,player in pairs(minetest.get_connected_players()) do | ||||
| 			if player:get_player_control().LMB then | ||||
| 				local item = player:get_wielded_item() | ||||
| 				local itemname = item:get_name() | ||||
| 				if itemname == "default:snow" then | ||||
| 					snow.shoot_snowball(nil, player) | ||||
| 					active = true | ||||
| 					break | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
|  | ||||
| 		-- disable the function if noone currently throws them | ||||
| 		if not active then | ||||
| 			someone_throwing = false | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	-- do automatic throwing using minetest.after | ||||
| 	local function do_step() | ||||
| 		local timer | ||||
| 		-- only if one holds left click | ||||
| 		if someone_throwing | ||||
| 		and not just_activated then | ||||
| 			update_step() | ||||
| 			timer = 0.006 | ||||
| 		else | ||||
| 			timer = 0.5 | ||||
| 			just_activated = false | ||||
| 		end | ||||
| 		minetest.after(timer, do_step) | ||||
| 	end | ||||
| 	minetest.after(3, do_step) | ||||
| end | ||||
|  | ||||
| --The snowball Entity | ||||
| local snow_snowball_ENTITY = { | ||||
| 	physical = false, | ||||
| 	timer = 0, | ||||
| 	collisionbox = {-5/16,-5/16,-5/16, 5/16,5/16,5/16}, | ||||
| } | ||||
|  | ||||
| function snow_snowball_ENTITY.on_activate(self) | ||||
| 	self.object:set_properties({textures = {"default_snowball.png^[transform"..math.random(0,7)}}) | ||||
| 	self.object:setacceleration({x=0, y=-get_gravity(), z=0}) | ||||
| 	self.lastpos = self.object:getpos() | ||||
| 	minetest.after(0.1, function(obj) | ||||
| 		if not obj then | ||||
| 			return | ||||
| 		end | ||||
| 		local vel = obj:getvelocity() | ||||
| 		if vel | ||||
| 		and vel.y ~= 0 then | ||||
| 			return | ||||
| 		end | ||||
| 		minetest.after(0, function(object) | ||||
| 			if not object then | ||||
| 				return | ||||
| 			end | ||||
| 			local vel_obj = object:getvelocity() | ||||
| 			if not vel_obj | ||||
| 			or vel_obj.y == 0 then | ||||
| 				object:remove() | ||||
| 			end | ||||
| 		end, obj) | ||||
| 	end, self.object) | ||||
| end | ||||
|  | ||||
| --Snowball_entity.on_step()--> called when snowball is moving. | ||||
| function snow_snowball_ENTITY.on_step(self, dtime) | ||||
| 	self.timer = self.timer + dtime | ||||
| 	if self.timer > 10 then | ||||
| 		-- 10 seconds is too long for a snowball to fly somewhere | ||||
| 		self.object:remove() | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	if self.physical then | ||||
| 		local vel = self.object:getvelocity() | ||||
| 		local fell = vel.y == 0 | ||||
| 		if not fell then | ||||
| 			if self.probably_stuck then | ||||
| 				self.probably_stuck = nil | ||||
| 			end | ||||
| 			return | ||||
| 		end | ||||
| 		if self.probably_stuck | ||||
| 		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:getpos()) | ||||
| 		if minetest.get_node(pos).name == "air" then | ||||
| 			pos.y = pos.y-1 | ||||
| 			if minetest.get_node(pos).name == "air" then | ||||
| 				if vel.x == 0 | ||||
| 				and vel.z == 0 then | ||||
| 					self.probably_stuck = true | ||||
| 				end | ||||
| 				return | ||||
| 			end | ||||
| 		end | ||||
| 		snow.place(pos) | ||||
| 		self.object:remove() | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	local pos = vector.round(self.object:getpos()) | ||||
| 	if vector.equals(pos, self.lastpos) then | ||||
| 		return | ||||
| 	end | ||||
| 	if minetest.get_node(pos).name ~= "air" then | ||||
| 		self.object:setacceleration({x=0, y=-get_gravity(), z=0}) | ||||
| 		--self.object:setvelocity({x=0, y=0, z=0}) | ||||
| 		pos = self.lastpos | ||||
| 		self.object:setpos(pos) | ||||
| 		minetest.sound_play("default_snow_footstep", {pos=pos, gain=vector.length(self.object:getvelocity())/30}) | ||||
| 		self.object:set_properties({physical = true}) | ||||
| 		self.physical = true | ||||
| 		return | ||||
| 	end | ||||
| 	self.lastpos = vector.new(pos) | ||||
|  | ||||
| 	if self.timer < entity_attack_delay then | ||||
| 		return | ||||
| 	end | ||||
| 	for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do | ||||
| 		local entity = v:get_luaentity() | ||||
| 		if v ~= self.object | ||||
| 		and entity then | ||||
| 			local entity_name = entity.name | ||||
| 			if v:is_player() | ||||
| 			or (entity_name ~= "snow:snowball_entity" | ||||
| 			and entity_name ~= "__builtin:item" | ||||
| 			and entity_name ~= "gauges:hp_bar") then | ||||
| 				local vvel = v:getvelocity() or v:get_player_velocity() | ||||
| 				local veldif = self.object:getvelocity() | ||||
| 				if vvel then | ||||
| 					veldif = vector.subtract(veldif, vvel) | ||||
| 				end | ||||
| 				local gain = vector.length(veldif)/20 | ||||
| 				v:punch( | ||||
| 					(self.thrower and minetest.get_player_by_name(self.thrower)) | ||||
| 						or self.object, | ||||
| 					1, | ||||
| 					{full_punch_interval=1, damage_groups = {fleshy=math.ceil(gain)}} | ||||
| 				) | ||||
| 				minetest.sound_play("default_snow_footstep", {pos=pos, gain=gain}) | ||||
|  | ||||
| 				-- 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() | ||||
| 				return | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
| minetest.register_entity("snow:snowball_entity", snow_snowball_ENTITY) | ||||
|  | ||||
|  | ||||
|  | ||||
| -- Snowball and Default Snowball Merged | ||||
|  | ||||
| -- They both look the same, they do basically the same thing (except one is a leftclick throw | ||||
| -- and the other is a rightclick drop),... Why not combine snow:snowball with default:snow and | ||||
| -- benefit from both? ~ LazyJ, 2014_04_08 | ||||
|  | ||||
| --[[ Save this for reference and occasionally compare to the default code for any updates. | ||||
|  | ||||
| minetest.register_node(":default:snow", { | ||||
| 	description = "Snow", | ||||
| 	tiles = {"default_snow.png"}, | ||||
| 	inventory_image = "default_snowball.png", | ||||
| 	wield_image = "default_snowball.png", | ||||
| 	is_ground_content = true, | ||||
| 	paramtype = "light", | ||||
| 	buildable_to = true, | ||||
| 	leveled = 7, | ||||
| 	drawtype = "nodebox", | ||||
| 	freezemelt = "default:water_flowing", | ||||
| 	node_box = { | ||||
| 		type = "leveled", | ||||
| 		fixed = { | ||||
| 			{-0.5, -0.5, -0.5,  0.5, -0.5+2/16, 0.5}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	groups = {crumbly=3,falling_node=1, melts=1, float=1}, | ||||
| 	sounds = default.node_sound_dirt_defaults({ | ||||
| 		footstep = {name="default_snow_footstep", gain=0.25}, | ||||
| 		dug = {name="default_snow_footstep", gain=0.75}, | ||||
| 	}), | ||||
| 	on_construct = function(pos) | ||||
| 		if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name | ||||
| 		== "default:dirt_with_grass" | ||||
| 		or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "default:dirt" then | ||||
| 			minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="default:dirt_with_snow"}) | ||||
| 		end | ||||
| 		-- Now, let's turn the snow pile into a snowblock. ~ LazyJ | ||||
| 		if minetest.get_node({x=pos.x, y=pos.y-2, z=pos.z}).name == "default:snow" | ||||
| 		and -- Minus 2 because at the end of this, the layer that triggers | ||||
| 		--the change to a snowblock is the second layer more than a full block, | ||||
| 		--starting into a second block (-2) ~ LazyJ, 2014_04_11 | ||||
| 			minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" then | ||||
| 			minetest.set_node({x=pos.x, y=pos.y-2, z=pos.z}, {name="default:snowblock"}) | ||||
| 		end | ||||
| 	end, | ||||
| 	on_use = snow_shoot_snowball  -- This line is from the 'Snow' mod, the reset is default Minetest. | ||||
| }) | ||||
| --]] | ||||
|  | ||||
|  | ||||
|  | ||||
| --[[ | ||||
| A note about default torches, melting, and "buildable_to = true" in default snow. | ||||
|  | ||||
| On servers where buckets are disabled, snow and ice stuff is used to set water for crops and | ||||
| water stuff like fountains, pools, ponds, ect.. It is a common practice to set a default torch on | ||||
| the snow placed where the players want water to be. | ||||
|  | ||||
| If you place a default torch *on* default snow to melt it, instead of melting the snow is | ||||
| *replaced* by the torch. Using "buildable_to = false" would fix this but then the snow would no | ||||
| longer pile-up in layers; the snow would stack like thin shelves in a vertical column. | ||||
|  | ||||
| I tinkered with the default torch's code (see below) to check for snow at the position and one | ||||
| node above (layered snow logs as the next y position above) but default snow's | ||||
| "buildable_to = true" always happened first. An interesting exercise to better learn how Minetest | ||||
| works, but otherwise not worth it. If you set a regular torch near snow, the snow will melt | ||||
| and disappear leaving you with nearly the same end result anyway. I say "nearly the same" | ||||
| because if you set a default torch on layered snow, the torch will replace the snow and be | ||||
| lit on the ground. If you were able to set a default torch *on* layered snow, the snow would | ||||
| melt and the torch would become a dropped item. | ||||
|  | ||||
| ~ LazyJ | ||||
|  | ||||
| --]] | ||||
|  | ||||
|  | ||||
| -- Some of the ideas I tried. ~ LazyJ | ||||
| --[[ | ||||
| local can_place_torch_on_top = function(pos) | ||||
| 			if minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" | ||||
| 			or minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "default:snow" then | ||||
| 				minetest.override_item("default:snow", {buildable_to = false,}) | ||||
| 			end | ||||
| 		end | ||||
| --]] | ||||
|  | ||||
|  | ||||
| --[[ | ||||
| minetest.override_item("default:torch", { | ||||
| 	--on_construct = function(pos) | ||||
| 	on_place = function(itemstack, placer, pointed_thing) | ||||
| 		--if minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name == "default:snow" | ||||
| 			-- Even though layered snow doesn't look like it's in the next position above (y+1) | ||||
| 			-- it registers in that position. Check the terminal's output to see the coord change. | ||||
| 		--or minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "default:snow" | ||||
| 		if pointed_thing.name == "default:snow" | ||||
| 		then minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:torch"}) | ||||
| 		end | ||||
| 	end | ||||
| }) | ||||
| --]] | ||||
							
								
								
									
										101
									
								
								src/stairs.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,101 @@ | ||||
| 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 = false, | ||||
| 		snowblock = false, | ||||
| 	} | ||||
|  | ||||
| 	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 | ||||
							
								
								
									
										55
									
								
								src/util.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,55 @@ | ||||
| --Global config and function table. | ||||
| snow = { | ||||
| 	snowball_gravity = tonumber(minetest.settings:get("snow_snowball_gravity")) or 0.91, | ||||
| 	snowball_velocity = tonumber(minetest.settings:get("snow_snowball_velocity")) or 19, | ||||
| 	sleds = minetest.settings:get_bool("snow_sleds", true), | ||||
| 	enable_snowfall = minetest.settings:get_bool("snow_enable_snowfall", false), | ||||
| 	lighter_snowfall = minetest.settings:get_bool("snow_lighter_snowfall", false), | ||||
| 	debug = minetest.settings:get_bool("snow_debug", false), | ||||
| 	smooth_biomes = minetest.settings:get_bool("snow_smooth_biomes", true), | ||||
| 	christmas_content = minetest.settings:get_bool("snow_christmas_content", true), | ||||
| 	smooth_snow = minetest.settings:get_bool("snow_smooth_snow", true), | ||||
| 	min_height = tonumber(minetest.settings:get("snow_min_height")) or 3, | ||||
| 	mapgen_rarity = tonumber(minetest.settings:get("snow_mapgen_rarity")) or 18, | ||||
| 	mapgen_size = tonumber(minetest.settings:get("snow_mapgen_size")) or 210, | ||||
| 	disable_mapgen =  minetest.settings:get_bool("snow_disable_mapgen", false), | ||||
| } | ||||
|  | ||||
|  | ||||
| -- functions for dynamically changing settings | ||||
|  | ||||
| snow.register_on_configuring = function() end | ||||
| --[[ | ||||
| local on_configurings,n = {},1 | ||||
| function snow.register_on_configuring(func) | ||||
| 	on_configurings[n] = func | ||||
| 	n = n+1 | ||||
| end | ||||
|  | ||||
| local function change_setting(name, value) | ||||
| 	if snow[name] == value then | ||||
| 		return | ||||
| 	end | ||||
| 	for i = 1,n-1 do | ||||
| 		if on_configurings[i](name, value) == false then | ||||
| 			return | ||||
| 		end | ||||
| 	end | ||||
| 	snow[name] = value | ||||
| end | ||||
|  | ||||
|  | ||||
| local function value_from_string(v) | ||||
| 	if v == "true" then | ||||
| 		v = true | ||||
| 	elseif v == "false" then | ||||
| 		v = false | ||||
| 	else | ||||
| 		local a_number = tonumber(v) | ||||
| 		if a_number then | ||||
| 			v = a_number | ||||
| 		end | ||||
| 	end | ||||
| 	return v | ||||
| end | ||||
| --]] | ||||
							
								
								
									
										
											BIN
										
									
								
								textures/character_snow_man.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 1.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								textures/character_snow_man_preview.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 3.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								textures/character_snow_man_preview_back.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 3.3 KiB | 
							
								
								
									
										
											BIN
										
									
								
								textures/default_snowball.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 211 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_apple.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 249 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_dandelion_white.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 122 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_dandelion_yellow.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 118 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_geranium.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 269 B | 
| Before Width: | Height: | Size: 742 B After Width: | Height: | Size: 643 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_ice_brick.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 665 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_ice_normal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 606 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_leaves.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 190 B | 
| Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 619 B | 
| Before Width: | Height: | Size: 860 B After Width: | Height: | Size: 660 B | 
| Before Width: | Height: | Size: 937 B After Width: | Height: | Size: 884 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_needles_decorated_animated.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 1.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_rose.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 120 B | 
| Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 272 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_shrub.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 262 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_shrub_covering.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 229 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_shrub_covering_normal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 269 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_shrub_normal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 297 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_sled.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 327 B | 
| Before Width: | Height: | Size: 345 B | 
| Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 319 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_snow_brick_normal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 484 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_snow_cobble.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 737 B | 
| Before Width: | Height: | Size: 894 B | 
| Before Width: | Height: | Size: 372 B | 
| Before Width: | Height: | Size: 350 B | 
| Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 349 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_star_lit.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 302 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_tulip.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 124 B | 
							
								
								
									
										
											BIN
										
									
								
								textures/snow_viola.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 117 B | 
| Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 299 B |