Compare commits
	
		
			360 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | e7a55734d3 | ||
|  | b36b154257 | ||
|  | 3976dc6a5b | ||
|  | 8ea031ef77 | ||
|  | 8c3f96d738 | ||
|  | 8d3d558e42 | ||
|  | de3adb5859 | ||
|  | acafe5ca86 | ||
|  | 12c763a6c7 | ||
|  | 098ea0d10a | ||
|  | f14b411157 | ||
|  | 1a6298958e | ||
|  | fafbe2c268 | ||
|  | dc7cbdd5ab | ||
|  | 5cd4b5a231 | ||
|  | f62afa02b7 | ||
|  | 7a892c70e6 | ||
|  | 682d79b82a | ||
|  | 8b384fb257 | ||
|  | d6c33da355 | ||
|  | 386dcdef06 | ||
|  | 54b87e955d | ||
|  | f32a3ff57c | ||
|  | 16fe1efcd8 | ||
|  | fa43bd8a56 | ||
|  | e426f64993 | ||
|  | ab7b7c7504 | ||
|  | 80664f9f8a | ||
|  | 0ca43e42bc | ||
|  | 33aa5e77dc | ||
|  | f8e273da15 | ||
|  | 9ece86cc7a | ||
|  | 7d93272caa | ||
|  | 64fe69f382 | ||
|  | a2d4e57716 | ||
|  | 8114c3dbab | ||
|  | e6cef57661 | ||
|  | 0736d30e33 | ||
|  | da5f4a939e | ||
|  | a84e2669c7 | ||
|  | ccee025ce3 | ||
|  | 8c801529df | ||
|  | 3ddff2fbea | ||
|  | eafd1ebc43 | ||
|  | 3623398b78 | ||
|  | b25889e742 | ||
|  | 9f4dc1412b | ||
|  | cfef21f4d9 | ||
|  | 8556dd30e2 | ||
|  | 8cd049c224 | ||
|  | 12d5ca2f48 | ||
|  | 3ecafbcfb4 | ||
|  | 082b36d3e7 | ||
|  | 7be008936e | ||
|  | 6e1a329763 | ||
|  | 47b197e4d5 | ||
|  | be05441e77 | ||
|  | aadac1223d | ||
|  | 9a6cb2d7c8 | ||
|  | f4e77edcc6 | ||
|  | e38f69d549 | ||
|  | 874b1ae326 | ||
|  | 1977ae19ae | ||
|  | 7bbbcbf7b0 | ||
|  | 4d7dbfc826 | ||
|  | 787ccb5747 | ||
|  | 12bcfeab4d | ||
|  | 14334a1d89 | ||
|  | 6749da1070 | ||
|  | 7a29d26e3e | ||
|  | 7cba7af894 | ||
|  | a71948c007 | ||
|  | c3d2bc383b | ||
|  | 7d55320d5c | ||
|  | 0d3bca790c | ||
|  | ffba9d978e | ||
|  | 1a5f89e750 | ||
|  | 51891122f2 | ||
|  | 537f94c28e | ||
|  | da0cc7f6f6 | ||
|  | b57dd0f9b2 | ||
|  | 8fdcfea9f9 | ||
|  | 9de43cdf7d | ||
|  | a2ecc51fbc | ||
|  | d90a081722 | ||
|  | 70248505ae | ||
|  | 22e32a01ad | ||
|  | c94349eaef | ||
|  | 41c2b2aeea | ||
|  | cb57f70aab | ||
|  | f18871d60c | ||
|  | c17c317669 | ||
|  | 7c966db4bc | ||
|  | e5304ce674 | ||
|  | 28884cc784 | ||
|  | dfee51c21e | ||
|  | 20053d6b52 | ||
|  | 079b796031 | ||
|  | 9c887e0b32 | ||
|  | 2fb40be409 | ||
|  | f8f7502e32 | ||
|  | b998ab1b3a | ||
|  | d979293f14 | ||
|  | 676822d286 | ||
|  | a5ad30748d | ||
|  | 45bc0b245f | ||
|  | aa676ab878 | ||
|  | f80fafbcfb | ||
|  | 7f317871d4 | ||
|  | 68f5740dcc | ||
|  | 6c6cc2159a | ||
|  | aa254e2835 | ||
|  | 29252c6fb2 | ||
|  | ac843f8fe7 | ||
|  | 0410b5e0ca | ||
|  | 3a98245f62 | ||
|  | 00a0d9a5d4 | ||
|  | 5d28040915 | ||
|  | 62dbf29301 | ||
|  | 6493e5fefb | ||
|  | 42cc6d2c31 | ||
|  | 3a55e19055 | ||
|  | ea2a7d3b1f | ||
|  | 2c355a8642 | ||
|  | 777088481b | ||
|  | 6b055ae18a | ||
|  | 4c9944b263 | ||
|  | 73d998ccdf | ||
|  | 3fcb7821d7 | ||
|  | ed9fd475de | ||
|  | 2cc6640edf | ||
|  | bbf17c9eca | ||
|  | 1ab0fc12a7 | ||
|  | 5569950b26 | ||
|  | 363b95c003 | ||
|  | 8422f2ef52 | ||
|  | 36d18cb161 | ||
|  | b47a556472 | ||
|  | 7d2dfe4101 | ||
|  | 04f01bc57f | ||
|  | 7a3cff5529 | ||
|  | 8f095c62a8 | ||
|  | f600a9f645 | ||
|  | 9e54b379c8 | ||
|  | 5994ac8dc5 | ||
|  | c198d8c57e | ||
|  | 09dbaf7972 | ||
|  | 0add474af2 | ||
|  | 0ea23a50d3 | ||
|  | 2f39cad09b | ||
|  | a4e144e4c8 | ||
|  | f4512cb5b6 | ||
|  | 38a8351327 | ||
|  | a5d40e13be | ||
|  | 4b8410a982 | ||
|  | 250be40ecd | ||
|  | 322967d2d1 | ||
|  | f41314185e | ||
|  | 6d79d157c3 | ||
|  | 6267f26027 | ||
|  | 535e611eb1 | ||
|  | 223e924edf | ||
|  | 556f0d48e3 | ||
|  | 57939c6c3f | ||
|  | 9542d119f6 | ||
|  | 7488f483c7 | ||
|  | b0ec8f1b5a | ||
|  | c76a91943c | ||
|  | 0472e61a9d | ||
|  | e9a7782c88 | ||
|  | 76471dd137 | ||
|  | 11115c7d15 | ||
|  | 481d1758ad | ||
|  | 32bdb9a393 | ||
|  | 82299b94dc | ||
|  | b1e2ece638 | ||
|  | eaed418b10 | ||
|  | 8704afe5b1 | ||
|  | c3a1545ca1 | ||
|  | a1b8b68e92 | ||
|  | b57ecb94df | ||
|  | c66a98bbed | ||
|  | 25e1f84733 | ||
|  | b8333cf82a | ||
|  | abf0ca9c7e | ||
|  | 135d80eb86 | ||
|  | 0d49978341 | ||
|  | 4ef6810298 | ||
|  | 1d8def5c06 | ||
|  | e41a411f1c | ||
|  | e67e28d226 | ||
|  | 3d6f1685ad | ||
|  | 592ca341ea | ||
|  | a88576afd1 | ||
|  | 6f6d46ddfc | ||
|  | 7c0abe9366 | ||
|  | 321bd66721 | ||
|  | 2729777b94 | ||
|  | f3dc78204c | ||
|  | b292975fbc | ||
|  | 3fb6ee5bdf | ||
|  | ef8b7e230d | ||
|  | c15bd9d529 | ||
|  | 41c1e99b1f | ||
|  | 70e8924082 | ||
|  | f4a412d9c1 | ||
|  | 8148bbf95e | ||
|  | 2119054a95 | ||
|  | ac810dbf9d | ||
|  | 8e51f318b3 | ||
|  | 93a2c40ebc | ||
|  | ff0973fa4f | ||
|  | 1f85f001f9 | ||
|  | 279b85fc45 | ||
|  | 24578ca968 | ||
|  | d0fad4b004 | ||
|  | 4bb9652c0f | ||
|  | b6c12010b1 | ||
|  | f5c8f881d7 | ||
|  | 0004c5e637 | ||
|  | 1cc8300ba9 | ||
|  | fd5721faa8 | ||
|  | 09d910efcb | ||
|  | acb0cecb36 | ||
|  | c2307b8816 | ||
|  | 73113f3443 | ||
|  | 4d9b595a69 | ||
|  | 908d8e5f90 | ||
|  | a0d7644a86 | ||
|  | 2392842948 | ||
|  | 3740efb393 | ||
|  | 835ca02be5 | ||
|  | 99d0442cc9 | ||
|  | b24049950e | ||
|  | 86dab909ed | ||
|  | ffcb3d6356 | ||
|  | c7b9e734ff | ||
|  | 450543f782 | ||
|  | b7a1426b42 | ||
|  | 408ee69fb8 | ||
|  | 35de5241f4 | ||
|  | be4dd6479d | ||
|  | 7066a6a0dd | ||
|  | 6194f9ffea | ||
|  | 47c7b0b187 | ||
|  | 0a3bf5b220 | ||
|  | 14ee61ab92 | ||
|  | f7f178ce03 | ||
|  | 547a7b3304 | ||
|  | 8d1eef025d | ||
|  | 84de5f0f40 | ||
|  | cbea61e8dd | ||
|  | 2885ae6018 | ||
|  | cf781ee218 | ||
|  | 252dffce78 | ||
|  | 83c2a88c91 | ||
|  | e7def5d4e6 | ||
|  | ec68283812 | ||
|  | bc4d0c1344 | ||
|  | e2033025b0 | ||
|  | da9789e3ce | ||
|  | 26866e4c21 | ||
|  | 0cf4fd4c18 | ||
|  | 2ddbf68e31 | ||
|  | 0c5f6dabc0 | ||
|  | fdae2832bb | ||
|  | 6843ddb814 | ||
|  | 166b1c623a | ||
|  | e8cafeb3e7 | ||
|  | 8a7af21e3a | ||
|  | 407b32e04c | ||
|  | f3f8b22698 | ||
|  | 585b2bc22e | ||
|  | 0914e595c7 | ||
|  | 7361eb5e05 | ||
|  | 44ac020f28 | ||
|  | e15fde1624 | ||
|  | 15ef8b0995 | ||
|  | d8dd9332ed | ||
|  | c4fb5bd385 | ||
|  | f09ae11e89 | ||
|  | 8b4a92ef2d | ||
|  | f92d49feff | ||
|  | 64fa8e6be5 | ||
|  | 0aebf864d1 | ||
|  | 016fa0da40 | ||
|  | 7786f7f8b1 | ||
|  | 6919d43d02 | ||
|  | 01ad09036b | ||
|  | 638add603f | ||
|  | 750f9575af | ||
|  | 40e2b945e3 | ||
|  | 03b51e8c8f | ||
|  | a4d056e493 | ||
|  | 23a37e5e79 | ||
|  | 300b14078f | ||
|  | eae3740d85 | ||
|  | 3669ca0a83 | ||
|  | 46c6154444 | ||
|  | 2824562dc9 | ||
|  | 852b337916 | ||
|  | dd34dffa45 | ||
|  | aaa6c260cd | ||
|  | 81259e9fcc | ||
|  | 4bd1094619 | ||
|  | 8bc8dd64c5 | ||
|  | ab4485f824 | ||
|  | fa1b4d0d44 | ||
|  | 055157d084 | ||
|  | fe3c5a7090 | ||
|  | d0070f2b1a | ||
|  | c570f9f494 | ||
|  | f8c8047a52 | ||
|  | f49faadc19 | ||
|  | fe7a982343 | ||
|  | 87468eb6fc | ||
|  | 4a7a51a46e | ||
|  | 9c15ebccab | ||
|  | 525f467057 | ||
|  | 820a97e397 | ||
|  | 3f2e35e827 | ||
|  | ccb4b925ed | ||
|  | 21c874ab52 | ||
|  | 8a8712e4a3 | ||
|  | 9eb9502209 | ||
|  | a192f9fc78 | ||
|  | 794a436d86 | ||
|  | 41837e6193 | ||
|  | 86e0e4b2bf | ||
|  | 2a6050e552 | ||
|  | e604d8d7f3 | ||
|  | 5a2aab855f | ||
|  | f86ac2fdff | ||
|  | df35360372 | ||
|  | 3e912f7b85 | ||
|  | ea7b04a712 | ||
|  | edb02e9d33 | ||
|  | 3b526a7276 | ||
|  | 03c00a831d | ||
|  | 60520b8032 | ||
|  | a9137e8c21 | ||
|  | 75ea7e3160 | ||
|  | 047ecea3a2 | ||
|  | 5518c277f3 | ||
|  | 4468015cbe | ||
|  | 0755a8fa05 | ||
|  | 5d8b2442ce | ||
|  | 6157982787 | ||
|  | 07dcae7258 | ||
|  | d546a5a1fa | ||
|  | 3689bdad75 | ||
|  | 4ce47528e1 | ||
|  | 2edfb55c29 | ||
|  | d1e715ebac | ||
|  | c654c9fd11 | ||
|  | 2c0f716a13 | ||
|  | 64bf6c1b89 | ||
|  | 047bfb9ad1 | ||
|  | cab01b6694 | ||
|  | 554d15fadb | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -5,3 +5,5 @@ | |||||||
| tags | tags | ||||||
| *.vim | *.vim | ||||||
|  |  | ||||||
|  | ## Files related to minetest development cycle | ||||||
|  | *.patch | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								README.txt
									
									
									
									
									
								
							
							
						
						| @@ -1,23 +1,24 @@ | |||||||
| The main game for the Minetest game engine [minetest_game] | Minetest Game [minetest_game] | ||||||
| ========================================================== | ============================= | ||||||
|  | The main subgame for the Minetest engine | ||||||
|  | ======================================== | ||||||
|  |  | ||||||
| To use this game with Minetest, insert this repository as | To use this subgame with the Minetest engine, insert this repository as | ||||||
| 	/games/minetest_game | 	/games/minetest_game | ||||||
| in the Minetest Engine. |  | ||||||
|  |  | ||||||
| The Minetest Engine can be found in: | The Minetest engine can be found in: | ||||||
| 	https://github.com/minetest/minetest/ | 	https://github.com/minetest/minetest/ | ||||||
|  |  | ||||||
| Compatibility | Compatibility | ||||||
| -------------- | -------------- | ||||||
| The minetest_game github master HEAD is generally compatible with the github | The Minetest Game github master HEAD is generally compatible with the github | ||||||
| master HEAD of minetest. | master HEAD of the Minetest engine. | ||||||
|  |  | ||||||
| Additionally, when the minetest engine is tagged to be a certain version (eg. | Additionally, when the Minetest engine is tagged to be a certain version (eg. | ||||||
| 0.4.10), minetest_game is tagged with the version too. | 0.4.10), Minetest Game is tagged with the version too. | ||||||
|  |  | ||||||
| When stable releases are made, minetest_game is packaged and made available in | When stable releases are made, Minetest Game is packaged and made available in | ||||||
|   http://minetest.net/download.php | 	http://minetest.net/download | ||||||
| and in case the repository has grown too much, it may be reset. In that sense, | and in case the repository has grown too much, it may be reset. In that sense, | ||||||
| this is not a "real" git repository. (Package maintainers please note!) | this is not a "real" git repository. (Package maintainers please note!) | ||||||
|  |  | ||||||
| @@ -49,4 +50,4 @@ Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) | |||||||
| http://creativecommons.org/licenses/by-sa/3.0/ | http://creativecommons.org/licenses/by-sa/3.0/ | ||||||
|  |  | ||||||
| License of menu/header.png | License of menu/header.png | ||||||
| Copyright (C) 2013 BlockMen CC BY-3.0 | Copyright (C) 2015 paramat CC BY-SA 3.0 | ||||||
|   | |||||||
							
								
								
									
										664
									
								
								game_api.txt
									
									
									
									
									
								
							
							
						
						| @@ -1,277 +1,593 @@ | |||||||
| minetest_game API | Minetest Game API | ||||||
| ====================== | ================= | ||||||
| GitHub Repo: https://github.com/minetest/minetest_game | GitHub Repo: https://github.com/minetest/minetest_game | ||||||
|  |  | ||||||
| Introduction | Introduction | ||||||
| ------------ | ------------ | ||||||
| The minetest_game gamemode offers multiple new possibilities in addition to Minetest's built-in API, allowing you to |  | ||||||
| add new plants to farming mod, buckets for new liquids, new stairs and custom panes. | The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API, | ||||||
|  | allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes. | ||||||
| For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt | For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt | ||||||
| Please note: | Please note: | ||||||
| 	[XYZ] refers to a section the Minetest API |  | ||||||
| 	[#ABC] refers to a section in this document |  * [XYZ] refers to a section the Minetest API | ||||||
| 	^ Explanation for line above |  * [#ABC] refers to a section in this document | ||||||
|  |  | ||||||
| Bucket API | Bucket API | ||||||
| ---------- | ---------- | ||||||
|  |  | ||||||
| The bucket API allows registering new types of buckets for non-default liquids. | The bucket API allows registering new types of buckets for non-default liquids. | ||||||
|  |  | ||||||
|  |  | ||||||
| 	bucket.register_liquid( | 	bucket.register_liquid( | ||||||
| 		"default:lava_source",		-- Source node name | 		"default:lava_source",   -- name of the source node | ||||||
| 		"default:lava_flowing",		-- Flowing node name | 		"default:lava_flowing",  -- name of the flowing node | ||||||
| 		"bucket:bucket_lava",		-- Name to be used for bucket | 		"bucket:bucket_lava",    -- name of the new bucket item (or nil if liquid is not takeable) | ||||||
| 		"bucket_lava.png",			-- Bucket texture (for wielditem and inventory_image) | 		"bucket_lava.png",       -- texture of the new bucket item (ignored if itemname == nil) | ||||||
| 		"Lava Bucket"				-- Bucket description | 		"Lava Bucket",           -- text description of the bucket item | ||||||
|  | 		{lava_bucket = 1}        -- groups of the bucket item, OPTIONAL | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | Beds API | ||||||
|  | -------- | ||||||
|  |  | ||||||
|  | 	beds.register_bed( | ||||||
|  | 		"beds:bed",    -- Bed name | ||||||
|  | 		def            -- See [#Bed definition] | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  |  * `beds.read_spawns() `   Returns a table containing players respawn positions | ||||||
|  |  * `beds.kick_players()`  Forces all players to leave bed | ||||||
|  |  * `beds.skip_night()`   Sets world time to morning and saves respawn position of all players currently sleeping | ||||||
|  |  | ||||||
|  | ### Bed definition | ||||||
|  |  | ||||||
|  | 	{ | ||||||
|  | 		description = "Simple Bed", | ||||||
|  | 		inventory_image = "beds_bed.png", | ||||||
|  | 		wield_image = "beds_bed.png", | ||||||
|  | 		tiles = { | ||||||
|  | 			bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed. | ||||||
|  | 			top = {Tile definition} -- the tiles of the bottom part of the bed. | ||||||
|  | 		}, | ||||||
|  | 		nodebox = { | ||||||
|  | 			bottom = 'regular nodebox',     -- bottom part of bed (see [Node boxes]) | ||||||
|  | 			top = 'regular nodebox',        -- top part of bed (see [Node boxes]) | ||||||
|  | 		}, | ||||||
|  | 		selectionbox = 'regular nodebox',  -- for both nodeboxes (see [Node boxes]) | ||||||
|  | 		recipe = {                                         -- Craft recipe | ||||||
|  | 			{"group:wool", "group:wool", "group:wool"}, | ||||||
|  | 			{"group:wood", "group:wood", "group:wood"} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| Doors API | Doors API | ||||||
| --------- | --------- | ||||||
| The doors mod allows modders to register custom doors. |  | ||||||
|  |  | ||||||
| 	doors.register_door(name, def) | The doors mod allows modders to register custom doors and trapdoors. | ||||||
| 	^ name: "Door name" |  | ||||||
| 	^ def: See [#Door definition] | `doors.register_door(name, def)` | ||||||
|  |  | ||||||
|  |  * Registers new door | ||||||
|  |  * `name` Name for door | ||||||
|  |  * `def`  See [#Door definition] | ||||||
|  |  | ||||||
|  | `doors.register_trapdoor(name, def)` | ||||||
|  |  | ||||||
|  |  * Registers new trapdoor | ||||||
|  |  * `name` Name for trapdoor | ||||||
|  |  * `def`  See [#Trapdoor definition] | ||||||
|  |  | ||||||
|  | `doors.register_fencegate(name, def)` | ||||||
|  |  | ||||||
|  |  * Registers new fence gate | ||||||
|  |  * `name` Name for fence gate | ||||||
|  |  * `def`  See [#Fence gate definition] | ||||||
|  |  | ||||||
|  | `doors.get(pos)` | ||||||
|  |  | ||||||
|  |  * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}` | ||||||
|  |  * Returns an ObjectRef to a door, or nil if the position does not contain a door | ||||||
|  |  | ||||||
|  |     ### Methods | ||||||
|  |  | ||||||
|  |         :open(player)   -- Open the door object, returns if door was opened | ||||||
|  |         :close(player)  -- Close the door object, returns if door was closed | ||||||
|  |         :toggle(player) -- Toggle the door state, returns if state was toggled | ||||||
|  |         :state()        -- returns the door state, true = open, false = closed | ||||||
|  |  | ||||||
|  |     the "player" parameter can be omitted in all methods. If passed then | ||||||
|  |     the usual permission checks will be performed to make sure the player | ||||||
|  |     has the permissions needed to open this door. If omitted then no | ||||||
|  |     permission checks are performed. | ||||||
|  |  | ||||||
|  | ### Door definition | ||||||
|  |  | ||||||
| #Door definition |  | ||||||
| ---------------- |  | ||||||
| { |  | ||||||
| 	description = "Door description", | 	description = "Door description", | ||||||
| 	inventory_image = "mod_door_inv.png", | 	inventory_image = "mod_door_inv.png", | ||||||
| 	groups = {group = 1}, | 	groups = {choppy = 2}, | ||||||
| 	tiles_bottom: [Tile definition], | 	tiles = {"mod_door.png"}, -- UV map. | ||||||
| 	^ the tiles of the bottom part of the door {front, side} | 	recipe = craftrecipe, | ||||||
| 	tiles_top: [Tile definition], | 	sounds = default.node_sound_wood_defaults(), -- optional | ||||||
| 	^ the tiles of the bottom part of the door {front, side} | 	sound_open = sound play for open door, -- optional | ||||||
| 	node_box_bottom = regular nodebox, see [Node boxes], OPTIONAL, | 	sound_close = sound play for close door, -- optional | ||||||
| 	node_box_top = regular nodebox, see [Node boxes], OPTIONAL, | 	protected = false, -- If true, only placer can open the door (locked for others) | ||||||
| 	selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL, |  | ||||||
| 	selection_box_top = regular nodebox, see [Node boxes], OPTIONAL, | ### Trapdoor definition | ||||||
| 	sound_open_door = sound play for open door, OPTIONAL, |  | ||||||
| 	sound_close_door = sound play for close door, OPTIONAL, | 	description = "Trapdoor description", | ||||||
| 	only_placer_can_open = true/false, | 	inventory_image = "mod_trapdoor_inv.png", | ||||||
| 	^ If true, only placer can open the door (locked for others) | 	groups = {choppy = 2}, | ||||||
| } | 	tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor | ||||||
|  | 	tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor | ||||||
|  | 	sounds = default.node_sound_wood_defaults(), -- optional | ||||||
|  | 	sound_open = sound play for open door, -- optional | ||||||
|  | 	sound_close = sound play for close door, -- optional | ||||||
|  | 	protected = false, -- If true, only placer can open the door (locked for others) | ||||||
|  |  | ||||||
|  | ### Fence gate definition | ||||||
|  |  | ||||||
|  | 	description = "Wooden Fence Gate", | ||||||
|  | 	texture = "default_wood.png", | ||||||
|  | 	material = "default:wood", | ||||||
|  | 	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, | ||||||
|  | 	sounds = default.node_sound_wood_defaults(), -- optional | ||||||
|  |  | ||||||
|  | Fence API | ||||||
|  | --------- | ||||||
|  |  | ||||||
|  | Allows creation of new fences with "fencelike" drawtype. | ||||||
|  |  | ||||||
|  | `default.register_fence(name, item definition)` | ||||||
|  |  | ||||||
|  |  Registers a new fence. Custom fields texture and material are required, as | ||||||
|  |  are name and description. The rest is optional. You can pass most normal | ||||||
|  |  nodedef fields here except drawtype. The fence group will always be added | ||||||
|  |  for this node. | ||||||
|  |  | ||||||
|  | ### fence definition | ||||||
|  |  | ||||||
|  | 	name = "default:fence_wood", | ||||||
|  | 	description = "Wooden Fence", | ||||||
|  | 	texture = "default_wood.png", | ||||||
|  | 	material = "default:wood", | ||||||
|  | 	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, | ||||||
|  | 	sounds = default.node_sound_wood_defaults(), | ||||||
|  |  | ||||||
|  | Walls API | ||||||
|  | --------- | ||||||
|  |  | ||||||
|  | The walls API allows easy addition of stone auto-connecting wall nodes. | ||||||
|  |  | ||||||
|  | walls.register(name, desc, texture, mat, sounds) | ||||||
|  | ^ name = "walls:stone_wall". Node name. | ||||||
|  | ^ desc = "A Stone wall" | ||||||
|  | ^ texture = "default_stone.png" | ||||||
|  | ^ mat = "default:stone". Used to auto-generate crafting recipe. | ||||||
|  | ^ sounds = sounds: see [#Default sounds] | ||||||
|  |  | ||||||
| Farming API | Farming API | ||||||
| ----------- | ----------- | ||||||
|  |  | ||||||
| The farming API allows you to easily register plants and hoes. | The farming API allows you to easily register plants and hoes. | ||||||
|  |  | ||||||
| farming.register_hoe(name, hoe definition) | `farming.register_hoe(name, hoe definition)` | ||||||
|  -> Register a new hoe, see [#hoe definition] |  * Register a new hoe, see [#hoe definition] | ||||||
|  |  | ||||||
| farming.register_plant(name, Plant definition) | `farming.register_plant(name, Plant definition)` | ||||||
|  -> Register a new growing plant, see [#Plant definition] |  * Register a new growing plant, see [#Plant definition] | ||||||
|  |  | ||||||
| #Hoe Definition | ### Hoe Definition | ||||||
| --------------- |  | ||||||
| { |  | ||||||
|  | 	{ | ||||||
| 		description = "",                      -- Description for tooltip | 		description = "",                      -- Description for tooltip | ||||||
| 		inventory_image = "unknown_item.png",  -- Image to be used as wield- and inventory image | 		inventory_image = "unknown_item.png",  -- Image to be used as wield- and inventory image | ||||||
| 		max_uses = 30,                         -- Uses until destroyed | 		max_uses = 30,                         -- Uses until destroyed | ||||||
| 	recipe = {	-- Craft recipe | 		material = "",                         -- Material for recipes | ||||||
|  | 		recipe = {                             -- Craft recipe, if material isn't used | ||||||
| 			{"air", "air", "air"}, | 			{"air", "air", "air"}, | ||||||
| 			{"", "group:stick"}, | 			{"", "group:stick"}, | ||||||
| 			{"", "group:stick"}, | 			{"", "group:stick"}, | ||||||
| 		} | 		} | ||||||
| } | 	} | ||||||
|  |  | ||||||
| #Plant definition | ### Plant definition | ||||||
| ----------------- |  | ||||||
| { | 	{ | ||||||
| 		description = "",                      -- Description of seed item | 		description = "",                      -- Description of seed item | ||||||
| 		inventory_image = "unknown_item.png",  -- Image to be used as seed's wield- and inventory image | 		inventory_image = "unknown_item.png",  -- Image to be used as seed's wield- and inventory image | ||||||
| 		steps = 8,                             -- How many steps the plant has to grow, until it can be harvested | 		steps = 8,                             -- How many steps the plant has to grow, until it can be harvested | ||||||
| 	^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber) | 		-- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) | ||||||
| 		minlight = 13,                         -- Minimum light to grow | 		minlight = 13,                         -- Minimum light to grow | ||||||
| 	maxlight = LIGHT_MAX -- Maximum light to grow | 		maxlight = default.LIGHT_MAX           -- Maximum light to grow | ||||||
| } | 	} | ||||||
|  |  | ||||||
|  | Fire API | ||||||
|  | -------- | ||||||
|  |  | ||||||
|  | New node def property: | ||||||
|  |  | ||||||
|  | `on_burn(pos)` | ||||||
|  |  | ||||||
|  |  * Called when fire attempts to remove a burning node. | ||||||
|  |  * `pos` Position of the burning node. | ||||||
|  |  | ||||||
|  | Give Initial Stuff API | ||||||
|  | ---------------------- | ||||||
|  |  | ||||||
|  | `give_initial_stuff.give(player)` | ||||||
|  |  | ||||||
|  | ^ Give initial stuff to "player" | ||||||
|  |  | ||||||
|  | `give_initial_stuff.add(stack)` | ||||||
|  |  | ||||||
|  | ^ Add item to the initial stuff | ||||||
|  | ^ Stack can be an ItemStack or a item name eg: "default:dirt 99" | ||||||
|  | ^ Can be called after the game has loaded | ||||||
|  |  | ||||||
|  | `give_initial_stuff.clear()` | ||||||
|  |  | ||||||
|  | ^ Removes all items from the initial stuff | ||||||
|  | ^ Can be called after the game has loaded | ||||||
|  |  | ||||||
|  | `give_initial_stuff.get_list()` | ||||||
|  |  | ||||||
|  | ^ returns list of item stacks | ||||||
|  |  | ||||||
|  | `give_initial_stuff.set_list(list)` | ||||||
|  |  | ||||||
|  | ^ List of initial items with numeric indices. | ||||||
|  |  | ||||||
|  | `give_initial_stuff.add_from_csv(str)` | ||||||
|  |  | ||||||
|  | ^ str is a comma separated list of initial stuff | ||||||
|  | ^ Adds items to the list of items to be given | ||||||
|  |  | ||||||
|  |  | ||||||
|  | TNT API | ||||||
|  | ---------- | ||||||
|  |  | ||||||
|  | `tnt.register_tnt(definition)` | ||||||
|  |  | ||||||
|  | ^ Register a new type of tnt. | ||||||
|  |  | ||||||
|  |  * `name` The name of the node. If no prefix is given `tnt` is used. | ||||||
|  |  * `description` A description for your TNT. | ||||||
|  |  * `radius` The radius within which the TNT can destroy nodes. The default is 3. | ||||||
|  |  * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`. | ||||||
|  |  * `disable_drops` Disable drops. By default it is set to false. | ||||||
|  |  * `ignore_protection` Don't check `minetest.is_protected` before removing a node. | ||||||
|  |  * `ignore_on_blast` Don't call `on_blast` even if a node has one. | ||||||
|  |  * `tiles` Textures for node | ||||||
|  |   * `side`  Side tiles. By default the name of the tnt with a suffix of `_side.png`. | ||||||
|  |   * `top`  Top tile. By default the name of the tnt with a suffix of `_top.png`. | ||||||
|  |   * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`. | ||||||
|  |   * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png". | ||||||
|  |  | ||||||
|  | `tnt.boom(position, definition)` | ||||||
|  |  | ||||||
|  | ^ Create an explosion. | ||||||
|  |  | ||||||
|  | * `position` The center of explosion. | ||||||
|  | * `definition` The TNT definion as passed to `tnt.register` | ||||||
|  |  | ||||||
|  | `tnt.burn(position)` | ||||||
|  |  | ||||||
|  | ^ Ignite TNT at position | ||||||
|  |  | ||||||
|  |  | ||||||
|  | To make dropping items from node inventories easier, you can use the | ||||||
|  | following helper function from 'default': | ||||||
|  |  | ||||||
|  | default.get_inventory_drops(pos, inventory, drops) | ||||||
|  |  | ||||||
|  | ^ Return drops from node inventory "inventory" in drops. | ||||||
|  |  | ||||||
|  | * `pos` - the node position | ||||||
|  | * `inventory` - the name of the inventory (string) | ||||||
|  | * `drops` - an initialized list | ||||||
|  |  | ||||||
|  | The function returns no values. The drops are returned in the `drops` | ||||||
|  | parameter, and drops is not reinitialized so you can call it several | ||||||
|  | times in a row to add more inventory items to it. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | `on_blast` callbacks: | ||||||
|  |  | ||||||
|  | Both nodedefs and entitydefs can provide an `on_blast()` callback | ||||||
|  |  | ||||||
|  | `nodedef.on_blast(pos, intensity)` | ||||||
|  | ^ Allow drop and node removal overriding | ||||||
|  | * `pos` - node position | ||||||
|  | * `intensity` - TNT explosion measure. larger or equal to 1.0 | ||||||
|  | ^ Should return a list of drops (e.g. {"default:stone"}) | ||||||
|  | ^ Should perform node removal itself. If callback exists in the nodedef | ||||||
|  | ^ then the TNT code will not destroy this node. | ||||||
|  |  | ||||||
|  | `entitydef.on_blast(luaobj, damage)` | ||||||
|  | ^ Allow TNT effects on entities to be overridden | ||||||
|  | * `luaobj` - LuaEntityRef of the entity | ||||||
|  | * `damage` - suggested HP damage value | ||||||
|  | ^ Should return a list of (bool do_damage, bool do_knockback, table drops) | ||||||
|  | * `do_damage` - if true then TNT mod wil damage the entity | ||||||
|  | * `do_knockback` - if true then TNT mod will knock the entity away | ||||||
|  | * `drops` - a list of drops, e.g. {"wool:red"} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Screwdriver API | ||||||
|  | --------------- | ||||||
|  |  | ||||||
|  | The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it. | ||||||
|  | To use it, add the `on_screwdriver` function to the node definition. | ||||||
|  |  | ||||||
|  | `on_rotate(pos, node, user, mode, new_param2)` | ||||||
|  |  | ||||||
|  |  * `pos` Position of the node that the screwdriver is being used on | ||||||
|  |  * `node` that node | ||||||
|  |  * `user` The player who used the screwdriver | ||||||
|  |  * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS | ||||||
|  |  * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there | ||||||
|  |  * return value: false to disallow rotation, nil to keep default behaviour, true to allow | ||||||
|  |  	it but to indicate that changed have already been made (so the screwdriver will wear out) | ||||||
|  |  * use `on_rotate = screwdriver.disallow` to always disallow rotation | ||||||
|  |  * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation | ||||||
|  |  | ||||||
| Stairs API | Stairs API | ||||||
| ---------- | ---------- | ||||||
|  |  | ||||||
| The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those | The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those | ||||||
| delivered with minetest_game, to keep them compatible with other mods. | delivered with Minetest Game, to keep them compatible with other mods. | ||||||
|  |  | ||||||
| stairs.register_stair(subname, recipeitem, groups, images, description, sounds) | `stairs.register_stair(subname, recipeitem, groups, images, description, sounds)` | ||||||
|  -> Registers a stair. |  | ||||||
|  -> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" |  | ||||||
|  -> recipeitem: Item used in the craft recipe, e.g. "default:cobble" |  | ||||||
|  -> groups: see [Known damage and digging time defining groups] |  | ||||||
|  -> images: see [Tile definition] |  | ||||||
|  -> description: used for the description field in the stair's definition |  | ||||||
|  -> sounds: see [#Default sounds] |  | ||||||
|  |  | ||||||
| stairs.register_slab(subname, recipeitem, groups, images, description, sounds) |  * Registers a stair. | ||||||
|  -> Registers a slabs |  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" | ||||||
|  -> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" |  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble" | ||||||
|  -> recipeitem: Item used in the craft recipe, e.g. "default:cobble" |  * `groups`: see [Known damage and digging time defining groups] | ||||||
|  -> groups: see [Known damage and digging time defining groups] |  * `images`: see [Tile definition] | ||||||
|  -> images: see [Tile definition] |  * `description`: used for the description field in the stair's definition | ||||||
|  -> description: used for the description field in the stair's definition |  * `sounds`: see [#Default sounds] | ||||||
|  -> sounds: see [#Default sounds] |  | ||||||
|  |  | ||||||
| stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds) | `stairs.register_slab(subname, recipeitem, groups, images, description, sounds)` | ||||||
|  -> A wrapper for stairs.register_stair and stairs.register_slab |  | ||||||
|  -> Uses almost the same arguments as stairs.register_stair |  * Registers a slabs | ||||||
|  -> desc_stair: Description for stair node |  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname" | ||||||
|  -> desc_slab: Description for slab node |  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble" | ||||||
|  |  * `groups`: see [Known damage and digging time defining groups] | ||||||
|  |  * `images`: see [Tile definition] | ||||||
|  |  * `description`: used for the description field in the stair's definition | ||||||
|  |  * `sounds`: see [#Default sounds] | ||||||
|  |  | ||||||
|  | `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)` | ||||||
|  |  | ||||||
|  |  * A wrapper for stairs.register_stair and stairs.register_slab | ||||||
|  |  * Uses almost the same arguments as stairs.register_stair | ||||||
|  |  * `desc_stair`: Description for stair node | ||||||
|  |  * `desc_slab`: Description for slab node | ||||||
|  |  | ||||||
| Xpanes API | Xpanes API | ||||||
| ---------- | ---------- | ||||||
|  |  | ||||||
| Creates panes that automatically connect to each other | Creates panes that automatically connect to each other | ||||||
|  |  | ||||||
| xpanes.register_pane(subname, def) | `xpanes.register_pane(subname, def)` | ||||||
|  -> subname: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" |  | ||||||
|  -> def: See [#Pane definition] |  * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}" | ||||||
|  |  * `def`: See [#Pane definition] | ||||||
|  |  | ||||||
|  | ### Pane definition | ||||||
|  |  | ||||||
|  | 	{ | ||||||
|  | 		textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"}, -- More tiles aren't supported | ||||||
|  | 		groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups] | ||||||
|  | 		sounds = SoundSpec,        -- See [#Default sounds] | ||||||
|  | 		recipe = {{"","","","","","","","",""}}, -- Recipe field only | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | Raillike definitions | ||||||
|  | -------------------- | ||||||
|  |  | ||||||
|  | The following nodes use the group `connect_to_raillike` and will only connect to | ||||||
|  | raillike nodes within this group and the same group value. | ||||||
|  | Use `minetest.raillike_group(<Name>)` to get the group value. | ||||||
|  |  | ||||||
|  | | Node type             | Raillike group name | ||||||
|  | |-----------------------|--------------------- | ||||||
|  | | default:rail          | "rail" | ||||||
|  | | tnt:gunpowder         | "gunpowder" | ||||||
|  | | tnt:gunpowder_burning	| "gunpowder" | ||||||
|  |  | ||||||
|  | Example: | ||||||
|  | If you want to add a new rail type and want it to connect with default:rail, | ||||||
|  | add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table | ||||||
|  | of your node. | ||||||
|  |  | ||||||
| #Pane definition |  | ||||||
| ---------------- |  | ||||||
| { |  | ||||||
| 	textures = {"texture_Bottom_top", "texture_left_right", "texture_front_back"}, |  | ||||||
| 	^ More tiles aren't supported |  | ||||||
| 	groups = {group = rating}, |  | ||||||
| 	^ Uses the known node groups, see [Known damage and digging time defining groups] |  | ||||||
| 	sounds = SoundSpec, |  | ||||||
| 	^ See [#Default sounds] |  | ||||||
| 	recipe = {{"","","","","","","","",""}}, |  | ||||||
| 	^ Recipe field only |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Default sounds | Default sounds | ||||||
| -------------- | -------------- | ||||||
|  |  | ||||||
| Sounds inside the default table can be used within the sounds field of node definitions. | Sounds inside the default table can be used within the sounds field of node definitions. | ||||||
|  |  | ||||||
| default.node_sound_defaults() |  * `default.node_sound_defaults()` | ||||||
| default.node_sound_stone_defaults() |  * `default.node_sound_stone_defaults()` | ||||||
| default.node_sound_dirt_defaults() |  * `default.node_sound_dirt_defaults()` | ||||||
| default.node_sound_sand_defaults() |  * `default.node_sound_sand_defaults()` | ||||||
| default.node_sound_wood_defaults() |  * `default.node_sound_wood_defaults()` | ||||||
| default.node_sound_leaves_defaults() |  * `default.node_sound_leaves_defaults()` | ||||||
| default.node_sound_glass_defaults() |  * `default.node_sound_glass_defaults()` | ||||||
|  |  | ||||||
|  | Default constants | ||||||
|  | ----------------- | ||||||
|  |  | ||||||
|  | `default.LIGHT_MAX`  The maximum light level (see [Node definition] light_source) | ||||||
|  |  | ||||||
| Player API | Player API | ||||||
| ---------- | ---------- | ||||||
|  |  | ||||||
| The player API can register player models and update the player's appearence | The player API can register player models and update the player's appearence | ||||||
|  |  | ||||||
| default.player_register_model(name, def) | `default.player_register_model(name, def)` | ||||||
| ^ Register a new model to be used by players. |  | ||||||
|  -> name: model filename such as "character.x", "foo.b3d", etc. |  | ||||||
|  -> def: See [#Model definition] |  | ||||||
|  |  | ||||||
| default.registered_player_models[name] |  * Register a new model to be used by players. | ||||||
| ^ Get a model's definition |  * name: model filename such as "character.x", "foo.b3d", etc. | ||||||
|  -> see [#Model definition] |  * def: See [#Model definition] | ||||||
|  |  | ||||||
| default.player_set_model(player, model_name) | `default.registered_player_models[name]` | ||||||
| ^ Change a player's model |  | ||||||
|  -> player: PlayerRef |  | ||||||
|  -> model_name: model registered with player_register_model() |  | ||||||
|  |  | ||||||
| default.player_set_animation(player, anim_name [, speed]) |  * Get a model's definition | ||||||
| ^ Applies an animation to a player |  * see [#Model definition] | ||||||
|  -> anim_name: name of the animation. |  | ||||||
|  -> speed: frames per second. If nil, default from the model is used |  | ||||||
|  |  | ||||||
| default.player_set_textures(player, textures) | `default.player_set_model(player, model_name)` | ||||||
| ^ Sets player textures |  | ||||||
|  -> player: PlayerRef |  * Change a player's model | ||||||
|  -> textures: array of textures |  * `player`: PlayerRef | ||||||
|  ^ If <textures> is nil, the default textures from the model def are used |  * `model_name`: model registered with player_register_model() | ||||||
|  |  | ||||||
|  | `default.player_set_animation(player, anim_name [, speed])` | ||||||
|  |  | ||||||
|  |  * Applies an animation to a player | ||||||
|  |  * anim_name: name of the animation. | ||||||
|  |  * speed: frames per second. If nil, default from the model is used | ||||||
|  |  | ||||||
|  | `default.player_set_textures(player, textures)` | ||||||
|  |  | ||||||
|  |  * Sets player textures | ||||||
|  |  * `player`: PlayerRef | ||||||
|  |  * `textures`: array of textures, If `textures` is nil, the default textures from the model def are used | ||||||
|  |  | ||||||
| default.player_get_animation(player) | default.player_get_animation(player) | ||||||
| ^ Returns a table containing fields "model", "textures" and "animation". |  | ||||||
| ^ Any of the fields of the returned table may be nil. |  | ||||||
|  -> player: PlayerRef |  | ||||||
|  |  | ||||||
| Model Definition |  * Returns a table containing fields `model`, `textures` and `animation`. | ||||||
| ---------------- |  * Any of the fields of the returned table may be nil. | ||||||
| { |  * player: PlayerRef | ||||||
|  |  | ||||||
|  | ### Model Definition | ||||||
|  |  | ||||||
|  | 	{ | ||||||
| 		animation_speed = 30,            -- Default animation speed, in FPS. | 		animation_speed = 30,            -- Default animation speed, in FPS. | ||||||
| 		textures = {"character.png", },  -- Default array of textures. | 		textures = {"character.png", },  -- Default array of textures. | ||||||
| 	visual_size = {x=1, y=1,}, -- Used to scale the model. | 		visual_size = {x = 1, y = 1},    -- Used to scale the model. | ||||||
| 		animations = { | 		animations = { | ||||||
| 		-- <anim_name> = { x=<start_frame>, y=<end_frame>, }, | 			-- <anim_name> = {x = <start_frame>, y = <end_frame>}, | ||||||
| 		foo = { x= 0, y=19, }, | 			foo = {x = 0, y = 19}, | ||||||
| 		bar = { x=20, y=39, }, | 			bar = {x = 20, y = 39}, | ||||||
| 		-- ... | 		-- ... | ||||||
| 		}, | 		}, | ||||||
| } | 	} | ||||||
|  |  | ||||||
| Leafdecay | Leafdecay | ||||||
| --------- | --------- | ||||||
| To enable leaf decay for a node, add it to the "leafdecay" group. |  | ||||||
|  |  | ||||||
| The rating of the group determines how far from a node in the group "tree" | To enable leaf decay for a node, add it to the `leafdecay` group. | ||||||
|  |  | ||||||
|  | The rating of the group determines how far from a node in the group `tree` | ||||||
| the node can be without decaying. | the node can be without decaying. | ||||||
|  |  | ||||||
| If param2 of the node is ~= 0, the node will always be preserved. Thus, if | If `param2` of the node is ~= 0, the node will always be preserved. Thus, if | ||||||
| the player places a node of that kind, you will want to set param2=1 or so. | the player places a node of that kind, you will want to set `param2 = 1` or so. | ||||||
|  |  | ||||||
| The function default.after_place_leaves can be set as after_place_node of a node | The function `default.after_place_leaves` can be set as `after_place_node of a node` | ||||||
| to set param2 to 1 if the player places the node (should not be used for nodes | to set param2 to 1 if the player places the node (should not be used for nodes | ||||||
| that use param2 otherwise (e.g. facedir)). | that use param2 otherwise (e.g. facedir)). | ||||||
|  |  | ||||||
| If the node is in the leafdecay_drop group then it will always be dropped as an | If the node is in the `leafdecay_drop` group then it will always be dropped as an | ||||||
| item. | item. | ||||||
|  |  | ||||||
| Dyes | Dyes | ||||||
| ---- | ---- | ||||||
|  |  | ||||||
| To make recipes that will work with any dye ever made by anybody, define | To make recipes that will work with any dye ever made by anybody, define | ||||||
| them based on groups. You can select any group of groups, based on your need for | them based on groups. You can select any group of groups, based on your need for | ||||||
| amount of colors. | amount of colors. | ||||||
|  |  | ||||||
| #Color groups | ### Color groups | ||||||
| ------------- |  | ||||||
| Base color groups: |  | ||||||
| - basecolor_white |  | ||||||
| - basecolor_grey |  | ||||||
| - basecolor_black |  | ||||||
| - basecolor_red |  | ||||||
| - basecolor_yellow |  | ||||||
| - basecolor_green |  | ||||||
| - basecolor_cyan |  | ||||||
| - basecolor_blue |  | ||||||
| - basecolor_magenta |  | ||||||
|  |  | ||||||
| Extended color groups (* = equal to a base color): | Base color groups: | ||||||
| * excolor_white |  | ||||||
| - excolor_lightgrey |  * `basecolor_white` | ||||||
| * excolor_grey |  * `basecolor_grey` | ||||||
| - excolor_darkgrey |  * `basecolor_black` | ||||||
| * excolor_black |  * `basecolor_red` | ||||||
| * excolor_red |  * `basecolor_yellow` | ||||||
| - excolor_orange |  * `basecolor_green` | ||||||
| * excolor_yellow |  * `basecolor_cyan` | ||||||
| - excolor_lime |  * `basecolor_blue` | ||||||
| * excolor_green |  * `basecolor_magenta` | ||||||
| - excolor_aqua |  | ||||||
| * excolor_cyan | Extended color groups ( * means also base color ) | ||||||
| - excolor_sky_blue |  | ||||||
| * excolor_blue |  * `excolor_white` * | ||||||
| - excolor_violet |  * `excolor_lightgrey` | ||||||
| * excolor_magenta |  * `excolor_grey` * | ||||||
| - excolor_red_violet |  * `excolor_darkgrey` | ||||||
|  |  * `excolor_black` * | ||||||
|  |  * `excolor_red` * | ||||||
|  |  * `excolor_orange` | ||||||
|  |  * `excolor_yellow` * | ||||||
|  |  * `excolor_lime` | ||||||
|  |  * `excolor_green` * | ||||||
|  |  * `excolor_aqua` | ||||||
|  |  * `excolor_cyan` * | ||||||
|  |  * `excolor_sky_blue` | ||||||
|  |  * `excolor_blue` * | ||||||
|  |  * `excolor_violet` | ||||||
|  |  * `excolor_magenta` * | ||||||
|  |  * `excolor_red_violet` | ||||||
|  |  | ||||||
| The whole unifieddyes palette as groups: | The whole unifieddyes palette as groups: | ||||||
| - unicolor_<excolor> |  | ||||||
|  |  * `unicolor_<excolor>` | ||||||
|  |  | ||||||
| For the following, no white/grey/black is allowed: | For the following, no white/grey/black is allowed: | ||||||
| - unicolor_medium_<excolor> |  | ||||||
| - unicolor_dark_<excolor> |  * `unicolor_medium_<excolor>` | ||||||
| - unicolor_light_<excolor> |  * `unicolor_dark_<excolor>` | ||||||
| - unicolor_<excolor>_s50 |  * `unicolor_light_<excolor>` | ||||||
| - unicolor_medium_<excolor>_s50 |  * `unicolor_<excolor>_s50` | ||||||
| - unicolor_dark_<excolor>_s50 |  * `unicolor_medium_<excolor>_s50` | ||||||
|  |  * `unicolor_dark_<excolor>_s50` | ||||||
|  |  | ||||||
| Example of one shapeless recipe using a color group: | Example of one shapeless recipe using a color group: | ||||||
| minetest.register_craft({ |  | ||||||
|  | 	minetest.register_craft({ | ||||||
| 		type = "shapeless", | 		type = "shapeless", | ||||||
| 		output = '<mod>:item_yellow', | 		output = '<mod>:item_yellow', | ||||||
| 		recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'}, | 		recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'}, | ||||||
| }) | 	}) | ||||||
|  |  | ||||||
| #Color lists | ### Color lists | ||||||
| ------------ |  | ||||||
| dye.basecolors |  | ||||||
| ^ Array containing the names of available base colors |  | ||||||
|  |  | ||||||
| dye.excolors |  * `dye.basecolors` are an array containing the names of available base colors | ||||||
| ^ Array containing the names of the available extended colors |  | ||||||
|  |  * `dye.excolors` are an array containing the names of the available extended colors | ||||||
|  |  | ||||||
|  | Trees | ||||||
|  | ----- | ||||||
|  |  | ||||||
|  |  * `default.grow_tree(pos, is_apple_tree)` | ||||||
|  |   * Grows a mgv6 tree or apple tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_jungle_tree(pos)` | ||||||
|  |   * Grows a mgv6 jungletree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_pine_tree(pos)` | ||||||
|  |   * Grows a mgv6 pinetree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_apple_tree(pos)` | ||||||
|  |   * Grows a new design apple tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_jungle_tree(pos)` | ||||||
|  |   * Grows a new design jungle tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_pine_tree(pos)` | ||||||
|  |   * Grows a new design pine tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_acacia_tree(pos)` | ||||||
|  |   * Grows a new design acacia tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_aspen_tree(pos)` | ||||||
|  |   * Grows a new design aspen tree at pos | ||||||
|  |  | ||||||
|  |  * `default.grow_new_snowy_pine_tree(pos)` | ||||||
|  |   * Grows a new design snowy pine tree at pos | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								menu/header.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 1.9 KiB | 
							
								
								
									
										
											BIN
										
									
								
								menu/icon.png
									
									
									
									
									
								
							
							
						
						| Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 2.9 KiB | 
| @@ -1,6 +0,0 @@ | |||||||
| mg_flags = dungeons |  | ||||||
| mgv6_spflags = biomeblend, jungles |  | ||||||
|  |  | ||||||
| movement_liquid_sink = 25 |  | ||||||
| movement_liquid_fluidity = 0.8 |  | ||||||
| movement_liquid_fluidity_smooth = 2 |  | ||||||
|   | |||||||
| @@ -1,6 +1,4 @@ | |||||||
| # This file contains settings of minetest_game that can be changed in | # This file contains settings of Minetest Game that can be changed in minetest.conf | ||||||
| # minetest.conf |  | ||||||
| # |  | ||||||
| # By default, all the settings are commented and not functional. | # By default, all the settings are commented and not functional. | ||||||
| # Uncomment settings by removing the preceding #. | # Uncomment settings by removing the preceding #. | ||||||
|  |  | ||||||
| @@ -11,14 +9,33 @@ | |||||||
| # 0 to disable | # 0 to disable | ||||||
| #share_bones_time = 1200 | #share_bones_time = 1200 | ||||||
|  |  | ||||||
| # Whether fire should be disabled (all fire nodes will instantly disappear) | # How much earlier the bones of a dead player can be looted by | ||||||
|  | # everyone if the player dies in a protected area they don't own. | ||||||
|  | # 0 to disable. By default it is "share_bones_time" divide by four. | ||||||
|  | #share_bones_time_early = 300 | ||||||
|  |  | ||||||
|  | # Whether standard fire should be disabled ('basic flame' nodes will disappear) | ||||||
|  | # 'permanent flame' nodes will remain with either setting | ||||||
| #disable_fire = false | #disable_fire = false | ||||||
|  |  | ||||||
| # Whether steel tools, torches and cobblestone should be given to new players | # Whether the stuff in initial_stuff should be given to new players | ||||||
| #give_initial_stuff = false | #give_initial_stuff = false | ||||||
|  | #initial_stuff = default:pick_steel,default:axe_steel,default:shovel_steel,default:torch 99,default:cobble 99 | ||||||
|  |  | ||||||
| # Whether the TNT mod should be enabled | # Whether the TNT mod should be enabled | ||||||
| #enable_tnt = <true in singleplayer, false in multiplayer> | #enable_tnt = <true in singleplayer, false in multiplayer> | ||||||
|  |  | ||||||
| # The radius of a TNT explosion | # The radius of a TNT explosion | ||||||
| #tnt_radius = 3 | #tnt_radius = 3 | ||||||
|  |  | ||||||
|  | # Enable the stairs mod ABM that replaces the old 'upside down' | ||||||
|  | # stair and slab nodes in old maps with the new param2 versions. | ||||||
|  | #enable_stairs_replace_abm = false | ||||||
|  |  | ||||||
|  | # Whether you allow respawning in beds | ||||||
|  | # Default value is true | ||||||
|  | #enable_bed_respawn = true | ||||||
|  |  | ||||||
|  | # Whether players can skip night by sleeping | ||||||
|  | # Default value is true | ||||||
|  | #enable_bed_night_skip = true | ||||||
|   | |||||||
							
								
								
									
										30
									
								
								mods/beds/README.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,30 @@ | |||||||
|  | Minetest Game mod: beds | ||||||
|  | ======================= | ||||||
|  | by BlockMen (c) 2014-2015 | ||||||
|  |  | ||||||
|  | Version: 1.1.1 | ||||||
|  |  | ||||||
|  | About | ||||||
|  | ~~~~~ | ||||||
|  | This mod adds a bed to Minetest which allows to skip the night. To sleep rightclick the bed, if playing  | ||||||
|  | in singleplayer mode the night gets skipped imideatly. If playing on server you get shown how many other | ||||||
|  | players are in bed too. If all players are sleeping the night gets skipped aswell. Also the night skip can be forced | ||||||
|  | if more than 50% of the players are lying in bed and use this option. | ||||||
|  |  | ||||||
|  | Another feature is a controled respawning. If you have slept in bed (not just lying in it) your respawn point | ||||||
|  | is set to the beds location and you will respawn there after death. | ||||||
|  | You can disable the respawn at beds by setting "enable_bed_respawn = false" in minetest.conf | ||||||
|  | You can also disable the night skip feature by setting "enable_bed_night_skip = false" in minetest.conf or by using | ||||||
|  | the /set command ingame. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | License of source code, textures: WTFPL | ||||||
|  | --------------------------------------- | ||||||
|  | (c) Copyright BlockMen (2014-2015) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | This program is free software. It comes without any warranty, to | ||||||
|  | the extent permitted by applicable law. You can redistribute it | ||||||
|  | and/or modify it under the terms of the Do What The Fuck You Want | ||||||
|  | To Public License, Version 2, as published by Sam Hocevar. See | ||||||
|  | http://sam.zoy.org/wtfpl/COPYING for more details. | ||||||
							
								
								
									
										157
									
								
								mods/beds/api.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,157 @@ | |||||||
|  |  | ||||||
|  | local reverse = true | ||||||
|  |  | ||||||
|  | local function destruct_bed(pos, n) | ||||||
|  | 	local node = minetest.get_node(pos) | ||||||
|  | 	local other | ||||||
|  |  | ||||||
|  | 	if n == 2 then | ||||||
|  | 		local dir = minetest.facedir_to_dir(node.param2) | ||||||
|  | 		other = vector.subtract(pos, dir) | ||||||
|  | 	elseif n == 1 then | ||||||
|  | 		local dir = minetest.facedir_to_dir(node.param2) | ||||||
|  | 		other = vector.add(pos, dir) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	if reverse then | ||||||
|  | 		reverse = not reverse | ||||||
|  | 		minetest.remove_node(other) | ||||||
|  | 		nodeupdate(other) | ||||||
|  | 	else | ||||||
|  | 		reverse = not reverse | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.register_bed(name, def) | ||||||
|  | 	minetest.register_node(name .. "_bottom", { | ||||||
|  | 		description = def.description, | ||||||
|  | 		inventory_image = def.inventory_image, | ||||||
|  | 		wield_image = def.wield_image, | ||||||
|  | 		drawtype = "nodebox", | ||||||
|  | 		tiles = def.tiles.bottom, | ||||||
|  | 		paramtype = "light", | ||||||
|  | 		paramtype2 = "facedir", | ||||||
|  | 		is_ground_content = false, | ||||||
|  | 		stack_max = 1, | ||||||
|  | 		groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1}, | ||||||
|  | 		sounds = default.node_sound_wood_defaults(), | ||||||
|  | 		node_box = { | ||||||
|  | 			type = "fixed", | ||||||
|  | 			fixed = def.nodebox.bottom, | ||||||
|  | 		}, | ||||||
|  | 		selection_box = { | ||||||
|  | 			type = "fixed", | ||||||
|  | 			fixed = def.selectionbox, | ||||||
|  | 		}, | ||||||
|  |  | ||||||
|  | 		on_place = function(itemstack, placer, pointed_thing) | ||||||
|  | 			local under = pointed_thing.under | ||||||
|  | 			local pos | ||||||
|  | 			if minetest.registered_items[minetest.get_node(under).name].buildable_to then | ||||||
|  | 				pos = under | ||||||
|  | 			else | ||||||
|  | 				pos = pointed_thing.above | ||||||
|  | 			end | ||||||
|  |  | ||||||
|  | 			if minetest.is_protected(pos, placer:get_player_name()) and | ||||||
|  | 					not minetest.check_player_privs(placer, "protection_bypass") then | ||||||
|  | 				minetest.record_protection_violation(pos, placer:get_player_name()) | ||||||
|  | 				return itemstack | ||||||
|  | 			end | ||||||
|  |  | ||||||
|  | 			local def = minetest.registered_nodes[minetest.get_node(pos).name] | ||||||
|  | 			if not def or not def.buildable_to then | ||||||
|  | 				return itemstack | ||||||
|  | 			end | ||||||
|  |  | ||||||
|  | 			local dir = minetest.dir_to_facedir(placer:get_look_dir()) | ||||||
|  | 			local botpos = vector.add(pos, minetest.facedir_to_dir(dir)) | ||||||
|  |  | ||||||
|  | 			if minetest.is_protected(botpos, placer:get_player_name()) and | ||||||
|  | 					not minetest.check_player_privs(placer, "protection_bypass") then | ||||||
|  | 				minetest.record_protection_violation(botpos, placer:get_player_name()) | ||||||
|  | 				return itemstack | ||||||
|  | 			end | ||||||
|  |  | ||||||
|  | 			local botdef = minetest.registered_nodes[minetest.get_node(botpos).name] | ||||||
|  | 			if not botdef or not botdef.buildable_to then | ||||||
|  | 				return itemstack | ||||||
|  | 			end | ||||||
|  |  | ||||||
|  | 			minetest.set_node(pos, {name = name .. "_bottom", param2 = dir}) | ||||||
|  | 			minetest.set_node(botpos, {name = name .. "_top", param2 = dir}) | ||||||
|  |  | ||||||
|  | 			if not minetest.setting_getbool("creative_mode") then | ||||||
|  | 				itemstack:take_item() | ||||||
|  | 			end | ||||||
|  | 			return itemstack | ||||||
|  | 		end, | ||||||
|  |  | ||||||
|  | 		on_destruct = function(pos) | ||||||
|  | 			destruct_bed(pos, 1) | ||||||
|  | 		end, | ||||||
|  |  | ||||||
|  | 		on_rightclick = function(pos, node, clicker) | ||||||
|  | 			beds.on_rightclick(pos, clicker) | ||||||
|  | 		end, | ||||||
|  |  | ||||||
|  | 		on_rotate = function(pos, node, user, mode, new_param2) | ||||||
|  | 			local dir = minetest.facedir_to_dir(node.param2) | ||||||
|  | 			local p = vector.add(pos, dir) | ||||||
|  | 			local node2 = minetest.get_node_or_nil(p) | ||||||
|  | 			if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or | ||||||
|  | 					not node.param2 == node2.param2 then | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
|  | 			if minetest.is_protected(p, user:get_player_name()) then | ||||||
|  | 				minetest.record_protection_violation(p, user:get_player_name()) | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
|  | 			if mode ~= screwdriver.ROTATE_FACE then | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
|  | 			local newp = vector.add(pos, minetest.facedir_to_dir(new_param2)) | ||||||
|  | 			local node3 = minetest.get_node_or_nil(newp) | ||||||
|  | 			local def = node3 and minetest.registered_nodes[node3.name] | ||||||
|  | 			if not def or not def.buildable_to then | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
|  | 			if minetest.is_protected(newp, user:get_player_name()) then | ||||||
|  | 				minetest.record_protection_violation(newp, user:get_player_name()) | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
|  | 			node.param2 = new_param2 | ||||||
|  | 			-- do not remove_node here - it will trigger destroy_bed() | ||||||
|  | 			minetest.set_node(p, {name = "air"}) | ||||||
|  | 			minetest.set_node(pos, node) | ||||||
|  | 			minetest.set_node(newp, {name = name .. "_top", param2 = new_param2}) | ||||||
|  | 			return true | ||||||
|  | 		end, | ||||||
|  | 	}) | ||||||
|  |  | ||||||
|  | 	minetest.register_node(name .. "_top", { | ||||||
|  | 		drawtype = "nodebox", | ||||||
|  | 		tiles = def.tiles.top, | ||||||
|  | 		paramtype = "light", | ||||||
|  | 		paramtype2 = "facedir", | ||||||
|  | 		is_ground_content = false, | ||||||
|  | 		pointable = false, | ||||||
|  | 		groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2}, | ||||||
|  | 		sounds = default.node_sound_wood_defaults(), | ||||||
|  | 		drop = name .. "_bottom", | ||||||
|  | 		node_box = { | ||||||
|  | 			type = "fixed", | ||||||
|  | 			fixed = def.nodebox.top, | ||||||
|  | 		}, | ||||||
|  | 		on_destruct = function(pos) | ||||||
|  | 			destruct_bed(pos, 2) | ||||||
|  | 		end, | ||||||
|  | 	}) | ||||||
|  |  | ||||||
|  | 	minetest.register_alias(name, name .. "_bottom") | ||||||
|  |  | ||||||
|  | 	minetest.register_craft({ | ||||||
|  | 		output = name, | ||||||
|  | 		recipe = def.recipe | ||||||
|  | 	}) | ||||||
|  | end | ||||||
							
								
								
									
										90
									
								
								mods/beds/beds.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,90 @@ | |||||||
|  | -- Fancy shaped bed | ||||||
|  |  | ||||||
|  | beds.register_bed("beds:fancy_bed", { | ||||||
|  | 	description = "Fancy Bed", | ||||||
|  | 	inventory_image = "beds_bed_fancy.png", | ||||||
|  | 	wield_image = "beds_bed_fancy.png", | ||||||
|  | 	tiles = { | ||||||
|  | 		bottom = { | ||||||
|  | 			"beds_bed_top1.png", | ||||||
|  | 			"default_wood.png", | ||||||
|  | 			"beds_bed_side1.png", | ||||||
|  | 			"beds_bed_side1.png^[transformFX", | ||||||
|  | 			"default_wood.png", | ||||||
|  | 			"beds_bed_foot.png", | ||||||
|  | 		}, | ||||||
|  | 		top = { | ||||||
|  | 			"beds_bed_top2.png", | ||||||
|  | 			"default_wood.png", | ||||||
|  | 			"beds_bed_side2.png", | ||||||
|  | 			"beds_bed_side2.png^[transformFX", | ||||||
|  | 			"beds_bed_head.png", | ||||||
|  | 			"default_wood.png", | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	nodebox = { | ||||||
|  | 		bottom = { | ||||||
|  | 			{-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375}, | ||||||
|  | 			{0.375, -0.5, -0.5, 0.5, -0.065, -0.4375}, | ||||||
|  | 			{-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375}, | ||||||
|  | 			{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, | ||||||
|  | 			{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, | ||||||
|  | 			{-0.4375, -0.3125, -0.4375, 0.4375, -0.0625, 0.5}, | ||||||
|  | 		}, | ||||||
|  | 		top = { | ||||||
|  | 			{-0.5, -0.5, 0.4375, -0.375, 0.1875, 0.5}, | ||||||
|  | 			{0.375, -0.5, 0.4375, 0.5, 0.1875, 0.5}, | ||||||
|  | 			{-0.5, 0, 0.4375, 0.5, 0.125, 0.5}, | ||||||
|  | 			{-0.5, -0.375, 0.4375, 0.5, -0.125, 0.5}, | ||||||
|  | 			{-0.5, -0.375, -0.5, -0.4375, -0.125, 0.5}, | ||||||
|  | 			{0.4375, -0.375, -0.5, 0.5, -0.125, 0.5}, | ||||||
|  | 			{-0.4375, -0.3125, -0.5, 0.4375, -0.0625, 0.4375}, | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, | ||||||
|  | 	recipe = { | ||||||
|  | 		{"", "", "group:stick"}, | ||||||
|  | 		{"wool:red", "wool:red", "wool:white"}, | ||||||
|  | 		{"group:wood", "group:wood", "group:wood"}, | ||||||
|  | 	}, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | -- Simple shaped bed | ||||||
|  |  | ||||||
|  | beds.register_bed("beds:bed", { | ||||||
|  | 	description = "Simple Bed", | ||||||
|  | 	inventory_image = "beds_bed.png", | ||||||
|  | 	wield_image = "beds_bed.png", | ||||||
|  | 	tiles = { | ||||||
|  | 		bottom = { | ||||||
|  | 			"beds_bed_top_bottom.png^[transformR90", | ||||||
|  | 			"default_wood.png", | ||||||
|  | 			"beds_bed_side_bottom_r.png", | ||||||
|  | 			"beds_bed_side_bottom_r.png^[transformfx", | ||||||
|  | 			"beds_transparent.png", | ||||||
|  | 			"beds_bed_side_bottom.png" | ||||||
|  | 		}, | ||||||
|  | 		top = { | ||||||
|  | 			"beds_bed_top_top.png^[transformR90", | ||||||
|  | 			"default_wood.png",  | ||||||
|  | 			"beds_bed_side_top_r.png", | ||||||
|  | 			"beds_bed_side_top_r.png^[transformfx", | ||||||
|  | 			"beds_bed_side_top.png", | ||||||
|  | 			"beds_transparent.png", | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	nodebox = { | ||||||
|  | 		bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, | ||||||
|  | 		top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, | ||||||
|  | 	}, | ||||||
|  | 	selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, | ||||||
|  | 	recipe = { | ||||||
|  | 		{"wool:red", "wool:red", "wool:white"}, | ||||||
|  | 		{"group:wood", "group:wood", "group:wood"} | ||||||
|  | 	}, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | -- Aliases for PilzAdam's beds mod | ||||||
|  |  | ||||||
|  | minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom") | ||||||
|  | minetest.register_alias("beds:bed_top_red", "beds:bed_top") | ||||||
							
								
								
									
										2
									
								
								mods/beds/depends.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,2 @@ | |||||||
|  | default | ||||||
|  | wool | ||||||
							
								
								
									
										225
									
								
								mods/beds/functions.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,225 @@ | |||||||
|  | local pi = math.pi | ||||||
|  | local player_in_bed = 0 | ||||||
|  | local is_sp = minetest.is_singleplayer() | ||||||
|  | local enable_respawn = minetest.setting_getbool("enable_bed_respawn") | ||||||
|  | if enable_respawn == nil then | ||||||
|  | 	enable_respawn = true | ||||||
|  | end | ||||||
|  |  | ||||||
|  | -- Helper functions | ||||||
|  |  | ||||||
|  | local function get_look_yaw(pos) | ||||||
|  | 	local n = minetest.get_node(pos) | ||||||
|  | 	if n.param2 == 1 then | ||||||
|  | 		return pi / 2, n.param2 | ||||||
|  | 	elseif n.param2 == 3 then | ||||||
|  | 		return -pi / 2, n.param2 | ||||||
|  | 	elseif n.param2 == 0 then | ||||||
|  | 		return pi, n.param2 | ||||||
|  | 	else | ||||||
|  | 		return 0, n.param2 | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  | local function is_night_skip_enabled() | ||||||
|  | 	local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip") | ||||||
|  | 	if enable_night_skip == nil then | ||||||
|  | 		enable_night_skip = true | ||||||
|  | 	end | ||||||
|  | 	return enable_night_skip | ||||||
|  | end | ||||||
|  |  | ||||||
|  | local function check_in_beds(players) | ||||||
|  | 	local in_bed = beds.player | ||||||
|  | 	if not players then | ||||||
|  | 		players = minetest.get_connected_players() | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	for n, player in ipairs(players) do | ||||||
|  | 		local name = player:get_player_name() | ||||||
|  | 		if not in_bed[name] then | ||||||
|  | 			return false | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	return #players > 0 | ||||||
|  | end | ||||||
|  |  | ||||||
|  | local function lay_down(player, pos, bed_pos, state, skip) | ||||||
|  | 	local name = player:get_player_name() | ||||||
|  | 	local hud_flags = player:hud_get_flags() | ||||||
|  |  | ||||||
|  | 	if not player or not name then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- stand up | ||||||
|  | 	if state ~= nil and not state then | ||||||
|  | 		local p = beds.pos[name] or nil | ||||||
|  | 		if beds.player[name] ~= nil then | ||||||
|  | 			beds.player[name] = nil | ||||||
|  | 			player_in_bed = player_in_bed - 1 | ||||||
|  | 		end | ||||||
|  | 		-- skip here to prevent sending player specific changes (used for leaving players) | ||||||
|  | 		if skip then | ||||||
|  | 			return | ||||||
|  | 		end | ||||||
|  | 		if p then | ||||||
|  | 			player:setpos(p) | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		-- physics, eye_offset, etc | ||||||
|  | 		player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) | ||||||
|  | 		player:set_look_yaw(math.random(1, 180) / 100) | ||||||
|  | 		default.player_attached[name] = false | ||||||
|  | 		player:set_physics_override(1, 1, 1) | ||||||
|  | 		hud_flags.wielditem = true | ||||||
|  | 		default.player_set_animation(player, "stand" , 30) | ||||||
|  |  | ||||||
|  | 	-- lay down | ||||||
|  | 	else | ||||||
|  | 		beds.player[name] = 1 | ||||||
|  | 		beds.pos[name] = pos | ||||||
|  | 		player_in_bed = player_in_bed + 1 | ||||||
|  |  | ||||||
|  | 		-- physics, eye_offset, etc | ||||||
|  | 		player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0}) | ||||||
|  | 		local yaw, param2 = get_look_yaw(bed_pos) | ||||||
|  | 		player:set_look_yaw(yaw) | ||||||
|  | 		local dir = minetest.facedir_to_dir(param2) | ||||||
|  | 		local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2} | ||||||
|  | 		player:set_physics_override(0, 0, 0) | ||||||
|  | 		player:setpos(p) | ||||||
|  | 		default.player_attached[name] = true | ||||||
|  | 		hud_flags.wielditem = false | ||||||
|  | 		default.player_set_animation(player, "lay" , 0) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	player:hud_set_flags(hud_flags) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | local function update_formspecs(finished) | ||||||
|  | 	local ges = #minetest.get_connected_players() | ||||||
|  | 	local form_n = "" | ||||||
|  | 	local is_majority = (ges / 2) < player_in_bed | ||||||
|  |  | ||||||
|  | 	if finished then | ||||||
|  | 		form_n = beds.formspec .. "label[2.7,11; Good morning.]" | ||||||
|  | 	else | ||||||
|  | 		form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. | ||||||
|  | 			" of " .. tostring(ges) .. " players are in bed]" | ||||||
|  | 		if is_majority and is_night_skip_enabled() then | ||||||
|  | 			form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]" | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	for name,_ in pairs(beds.player) do | ||||||
|  | 		minetest.show_formspec(name, "beds_form", form_n) | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  |  | ||||||
|  | -- Public functions | ||||||
|  |  | ||||||
|  | function beds.kick_players() | ||||||
|  | 	for name, _ in pairs(beds.player) do | ||||||
|  | 		local player = minetest.get_player_by_name(name) | ||||||
|  | 		lay_down(player, nil, nil, false) | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.skip_night() | ||||||
|  | 	minetest.set_timeofday(0.23) | ||||||
|  | 	beds.set_spawns() | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.on_rightclick(pos, player) | ||||||
|  | 	local name = player:get_player_name() | ||||||
|  | 	local ppos = player:getpos() | ||||||
|  | 	local tod = minetest.get_timeofday() | ||||||
|  |  | ||||||
|  | 	if tod > 0.2 and tod < 0.805 then | ||||||
|  | 		if beds.player[name] then | ||||||
|  | 			lay_down(player, nil, nil, false) | ||||||
|  | 		end | ||||||
|  | 		minetest.chat_send_player(name, "You can only sleep at night.") | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- move to bed | ||||||
|  | 	if not beds.player[name] then | ||||||
|  | 		lay_down(player, ppos, pos) | ||||||
|  | 	else | ||||||
|  | 		lay_down(player, nil, nil, false) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	if not is_sp then | ||||||
|  | 		update_formspecs(false) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- skip the night and let all players stand up | ||||||
|  | 	if check_in_beds() then | ||||||
|  | 		minetest.after(2, function() | ||||||
|  | 			if not is_sp then | ||||||
|  | 				update_formspecs(is_night_skip_enabled()) | ||||||
|  | 			end | ||||||
|  | 			if is_night_skip_enabled() then | ||||||
|  | 				beds.skip_night() | ||||||
|  | 				beds.kick_players() | ||||||
|  | 			end | ||||||
|  | 		end) | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  |  | ||||||
|  | -- Callbacks | ||||||
|  |  | ||||||
|  | minetest.register_on_joinplayer(function(player) | ||||||
|  | 	beds.read_spawns() | ||||||
|  | end) | ||||||
|  |  | ||||||
|  | -- respawn player at bed if enabled and valid position is found | ||||||
|  | minetest.register_on_respawnplayer(function(player) | ||||||
|  | 	if not enable_respawn then | ||||||
|  | 		return false | ||||||
|  | 	end | ||||||
|  | 	local name = player:get_player_name() | ||||||
|  | 	local pos = beds.spawn[name] or nil | ||||||
|  | 	if pos then | ||||||
|  | 		player:setpos(pos) | ||||||
|  | 		return true | ||||||
|  | 	end | ||||||
|  | end) | ||||||
|  |  | ||||||
|  | minetest.register_on_leaveplayer(function(player) | ||||||
|  | 	local name = player:get_player_name() | ||||||
|  | 	lay_down(player, nil, nil, false, true) | ||||||
|  | 	beds.player[name] = nil | ||||||
|  | 	if check_in_beds() then | ||||||
|  | 		minetest.after(2, function() | ||||||
|  | 			update_formspecs(is_night_skip_enabled()) | ||||||
|  | 			if is_night_skip_enabled() then | ||||||
|  | 				beds.skip_night() | ||||||
|  | 				beds.kick_players() | ||||||
|  | 			end | ||||||
|  | 		end) | ||||||
|  | 	end | ||||||
|  | end) | ||||||
|  |  | ||||||
|  | minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||||
|  | 	if formname ~= "beds_form" then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	if fields.quit or fields.leave then | ||||||
|  | 		lay_down(player, nil, nil, false) | ||||||
|  | 		update_formspecs(false) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	if fields.force then | ||||||
|  | 		update_formspecs(is_night_skip_enabled()) | ||||||
|  | 		if is_night_skip_enabled() then | ||||||
|  | 			beds.skip_night() | ||||||
|  | 			beds.kick_players() | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  | end) | ||||||
							
								
								
									
										17
									
								
								mods/beds/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,17 @@ | |||||||
|  | beds = {} | ||||||
|  | beds.player = {} | ||||||
|  | beds.pos = {} | ||||||
|  | beds.spawn = {} | ||||||
|  |  | ||||||
|  | beds.formspec = "size[8,15;true]" .. | ||||||
|  | 	"bgcolor[#080808BB; true]" .. | ||||||
|  | 	"button_exit[2,12;4,0.75;leave;Leave Bed]" | ||||||
|  |  | ||||||
|  | local modpath = minetest.get_modpath("beds") | ||||||
|  |  | ||||||
|  | -- Load files | ||||||
|  |  | ||||||
|  | dofile(modpath .. "/functions.lua") | ||||||
|  | dofile(modpath .. "/api.lua") | ||||||
|  | dofile(modpath .. "/beds.lua") | ||||||
|  | dofile(modpath .. "/spawns.lua") | ||||||
							
								
								
									
										63
									
								
								mods/beds/spawns.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,63 @@ | |||||||
|  | local world_path = minetest.get_worldpath() | ||||||
|  | local org_file = world_path .. "/beds_spawns" | ||||||
|  | local file = world_path .. "/beds_spawns" | ||||||
|  | local bkwd = false | ||||||
|  |  | ||||||
|  | -- check for PA's beds mod spawns | ||||||
|  | local cf = io.open(world_path .. "/beds_player_spawns", "r") | ||||||
|  | if cf ~= nil then | ||||||
|  | 	io.close(cf) | ||||||
|  | 	file = world_path .. "/beds_player_spawns" | ||||||
|  | 	bkwd = true | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.read_spawns() | ||||||
|  | 	local spawns = beds.spawn | ||||||
|  | 	local input = io.open(file, "r") | ||||||
|  | 	if input and not bkwd then | ||||||
|  | 		repeat | ||||||
|  | 			local x = input:read("*n") | ||||||
|  | 			if x == nil then | ||||||
|  | 				break | ||||||
|  | 			end | ||||||
|  | 			local y = input:read("*n") | ||||||
|  | 			local z = input:read("*n") | ||||||
|  | 			local name = input:read("*l") | ||||||
|  | 			spawns[name:sub(2)] = {x = x, y = y, z = z} | ||||||
|  | 		until input:read(0) == nil | ||||||
|  | 		io.close(input) | ||||||
|  | 	elseif input and bkwd then | ||||||
|  | 		beds.spawn = minetest.deserialize(input:read("*all")) | ||||||
|  | 		input:close() | ||||||
|  | 		beds.save_spawns() | ||||||
|  | 		os.rename(file, file .. ".backup") | ||||||
|  | 		file = org_file | ||||||
|  | 	else | ||||||
|  | 		spawns = {} | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.save_spawns() | ||||||
|  | 	if not beds.spawn then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	local data = {} | ||||||
|  | 	local output = io.open(org_file, "w") | ||||||
|  | 	for k, v in pairs(beds.spawn) do | ||||||
|  | 		table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k)) | ||||||
|  | 	end | ||||||
|  | 	output:write(table.concat(data)) | ||||||
|  | 	io.close(output) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function beds.set_spawns() | ||||||
|  | 	for name,_ in pairs(beds.player) do | ||||||
|  | 		local player = minetest.get_player_by_name(name) | ||||||
|  | 		local p = player:getpos() | ||||||
|  | 		-- but don't change spawn location if borrowing a bed | ||||||
|  | 		if not minetest.is_protected(p, name) then | ||||||
|  | 			beds.spawn[name] = p | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  | 	beds.save_spawns() | ||||||
|  | end | ||||||
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 540 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_fancy.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 537 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_foot.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 390 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_head.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 387 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side1.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 296 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 316 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side_bottom.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 561 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side_bottom_r.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 537 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side_top.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 611 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_side_top_r.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 596 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_top1.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 583 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_top2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 616 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_top_bottom.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 495 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_bed_top_top.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 556 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/beds/textures/beds_transparent.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 143 B | 
| @@ -1,6 +1,6 @@ | |||||||
| Minetest 0.4 mod: boats | Minetest Game mod: boats | ||||||
| ======================= | ======================== | ||||||
| by PilzAdam, slightly modified for NeXt | by PilzAdam | ||||||
|  |  | ||||||
| License of source code: | License of source code: | ||||||
| ----------------------- | ----------------------- | ||||||
|   | |||||||
| @@ -1,4 +1,3 @@ | |||||||
|  |  | ||||||
| -- | -- | ||||||
| -- Helper functions | -- Helper functions | ||||||
| -- | -- | ||||||
| @@ -8,6 +7,7 @@ local function is_water(pos) | |||||||
| 	return minetest.get_item_group(nn, "water") ~= 0 | 	return minetest.get_item_group(nn, "water") ~= 0 | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_sign(i) | local function get_sign(i) | ||||||
| 	if i == 0 then | 	if i == 0 then | ||||||
| 		return 0 | 		return 0 | ||||||
| @@ -16,12 +16,14 @@ local function get_sign(i) | |||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_velocity(v, yaw, y) | local function get_velocity(v, yaw, y) | ||||||
| 	local x = -math.sin(yaw) * v | 	local x = -math.sin(yaw) * v | ||||||
| 	local z =  math.cos(yaw) * v | 	local z =  math.cos(yaw) * v | ||||||
| 	return {x = x, y = y, z = z} | 	return {x = x, y = y, z = z} | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local function get_v(v) | local function get_v(v) | ||||||
| 	return math.sqrt(v.x ^ 2 + v.z ^ 2) | 	return math.sqrt(v.x ^ 2 + v.z ^ 2) | ||||||
| end | end | ||||||
| @@ -32,9 +34,9 @@ end | |||||||
|  |  | ||||||
| local boat = { | local boat = { | ||||||
| 	physical = true, | 	physical = true, | ||||||
| 	collisionbox = {-0.5, -0.4, -0.5, 0.5, 0.3, 0.5}, | 	collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5}, | ||||||
| 	visual = "mesh", | 	visual = "mesh", | ||||||
| 	mesh = "boat.x", | 	mesh = "boats_boat.obj", | ||||||
| 	textures = {"default_wood.png"}, | 	textures = {"default_wood.png"}, | ||||||
|  |  | ||||||
| 	driver = nil, | 	driver = nil, | ||||||
| @@ -43,6 +45,7 @@ local boat = { | |||||||
| 	removed = false | 	removed = false | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| function boat.on_rightclick(self, clicker) | function boat.on_rightclick(self, clicker) | ||||||
| 	if not clicker or not clicker:is_player() then | 	if not clicker or not clicker:is_player() then | ||||||
| 		return | 		return | ||||||
| @@ -53,9 +56,23 @@ function boat.on_rightclick(self, clicker) | |||||||
| 		clicker:set_detach() | 		clicker:set_detach() | ||||||
| 		default.player_attached[name] = false | 		default.player_attached[name] = false | ||||||
| 		default.player_set_animation(clicker, "stand" , 30) | 		default.player_set_animation(clicker, "stand" , 30) | ||||||
|  | 		local pos = clicker:getpos() | ||||||
|  | 		pos = {x = pos.x, y = pos.y + 0.2, z = pos.z} | ||||||
|  | 		minetest.after(0.1, function() | ||||||
|  | 			clicker:setpos(pos) | ||||||
|  | 		end) | ||||||
| 	elseif not self.driver then | 	elseif not self.driver then | ||||||
|  | 		local attach = clicker:get_attach() | ||||||
|  | 		if attach and attach:get_luaentity() then | ||||||
|  | 			local luaentity = attach:get_luaentity() | ||||||
|  | 			if luaentity.driver then | ||||||
|  | 				luaentity.driver = nil | ||||||
|  | 			end | ||||||
|  | 			clicker:set_detach() | ||||||
|  | 		end | ||||||
| 		self.driver = clicker | 		self.driver = clicker | ||||||
| 		clicker:set_attach(self.object, "", {x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0}) | 		clicker:set_attach(self.object, "", | ||||||
|  | 			{x = 0, y = 11, z = -3}, {x = 0, y = 0, z = 0}) | ||||||
| 		default.player_attached[name] = true | 		default.player_attached[name] = true | ||||||
| 		minetest.after(0.2, function() | 		minetest.after(0.2, function() | ||||||
| 			default.player_set_animation(clicker, "sit" , 30) | 			default.player_set_animation(clicker, "sit" , 30) | ||||||
| @@ -64,6 +81,7 @@ function boat.on_rightclick(self, clicker) | |||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| function boat.on_activate(self, staticdata, dtime_s) | function boat.on_activate(self, staticdata, dtime_s) | ||||||
| 	self.object:set_armor_groups({immortal = 1}) | 	self.object:set_armor_groups({immortal = 1}) | ||||||
| 	if staticdata then | 	if staticdata then | ||||||
| @@ -72,11 +90,13 @@ function boat.on_activate(self, staticdata, dtime_s) | |||||||
| 	self.last_v = self.v | 	self.last_v = self.v | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| function boat.get_staticdata(self) | function boat.get_staticdata(self) | ||||||
| 	return tostring(self.v) | 	return tostring(self.v) | ||||||
| end | end | ||||||
|  |  | ||||||
| function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, direction) |  | ||||||
|  | function boat.on_punch(self, puncher) | ||||||
| 	if not puncher or not puncher:is_player() or self.removed then | 	if not puncher or not puncher:is_player() or self.removed then | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| @@ -92,11 +112,17 @@ function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d | |||||||
| 			self.object:remove() | 			self.object:remove() | ||||||
| 		end) | 		end) | ||||||
| 		if not minetest.setting_getbool("creative_mode") then | 		if not minetest.setting_getbool("creative_mode") then | ||||||
| 			puncher:get_inventory():add_item("main", "boats:boat") | 			local inv = puncher:get_inventory() | ||||||
|  | 			if inv:room_for_item("main", "boats:boat") then | ||||||
|  | 				inv:add_item("main", "boats:boat") | ||||||
|  | 			else | ||||||
|  | 				minetest.add_item(self.object:getpos(), "boats:boat") | ||||||
|  | 			end | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| function boat.on_step(self, dtime) | function boat.on_step(self, dtime) | ||||||
| 	self.v = get_v(self.object:getvelocity()) * get_sign(self.v) | 	self.v = get_v(self.object:getvelocity()) * get_sign(self.v) | ||||||
| 	if self.driver then | 	if self.driver then | ||||||
| @@ -133,8 +159,8 @@ function boat.on_step(self, dtime) | |||||||
| 		self.v = 0 | 		self.v = 0 | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	if math.abs(self.v) > 4.5 then | 	if math.abs(self.v) > 5 then | ||||||
| 		self.v = 4.5 * get_sign(self.v) | 		self.v = 5 * get_sign(self.v) | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	local p = self.object:getpos() | 	local p = self.object:getpos() | ||||||
| @@ -149,14 +175,15 @@ function boat.on_step(self, dtime) | |||||||
| 		else | 		else | ||||||
| 			new_acce = {x = 0, y = -9.8, z = 0} | 			new_acce = {x = 0, y = -9.8, z = 0} | ||||||
| 		end | 		end | ||||||
| 		new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y) | 		new_velo = get_velocity(self.v, self.object:getyaw(), | ||||||
|  | 			self.object:getvelocity().y) | ||||||
| 		self.object:setpos(self.object:getpos()) | 		self.object:setpos(self.object:getpos()) | ||||||
| 	else | 	else | ||||||
| 		p.y = p.y + 1 | 		p.y = p.y + 1 | ||||||
| 		if is_water(p) then | 		if is_water(p) then | ||||||
| 			local y = self.object:getvelocity().y | 			local y = self.object:getvelocity().y | ||||||
| 			if y >= 4.5 then | 			if y >= 5 then | ||||||
| 				y = 4.5 | 				y = 5 | ||||||
| 			elseif y < 0 then | 			elseif y < 0 then | ||||||
| 				new_acce = {x = 0, y = 20, z = 0} | 				new_acce = {x = 0, y = 20, z = 0} | ||||||
| 			else | 			else | ||||||
| @@ -172,7 +199,8 @@ function boat.on_step(self, dtime) | |||||||
| 				self.object:setpos(pos) | 				self.object:setpos(pos) | ||||||
| 				new_velo = get_velocity(self.v, self.object:getyaw(), 0) | 				new_velo = get_velocity(self.v, self.object:getyaw(), 0) | ||||||
| 			else | 			else | ||||||
| 				new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y) | 				new_velo = get_velocity(self.v, self.object:getyaw(), | ||||||
|  | 					self.object:getvelocity().y) | ||||||
| 				self.object:setpos(self.object:getpos()) | 				self.object:setpos(self.object:getpos()) | ||||||
| 			end | 			end | ||||||
| 		end | 		end | ||||||
| @@ -181,12 +209,14 @@ function boat.on_step(self, dtime) | |||||||
| 	self.object:setacceleration(new_acce) | 	self.object:setacceleration(new_acce) | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
| minetest.register_entity("boats:boat", boat) | minetest.register_entity("boats:boat", boat) | ||||||
|  |  | ||||||
|  |  | ||||||
| minetest.register_craftitem("boats:boat", { | minetest.register_craftitem("boats:boat", { | ||||||
| 	description = "Boat", | 	description = "Boat", | ||||||
| 	inventory_image = "boat_inventory.png", | 	inventory_image = "boats_inventory.png", | ||||||
| 	wield_image = "boat_wield.png", | 	wield_image = "boats_wield.png", | ||||||
| 	wield_scale = {x = 2, y = 2, z = 1}, | 	wield_scale = {x = 2, y = 2, z = 1}, | ||||||
| 	liquids_pointable = true, | 	liquids_pointable = true, | ||||||
|  |  | ||||||
| @@ -206,6 +236,7 @@ minetest.register_craftitem("boats:boat", { | |||||||
| 	end, | 	end, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = "boats:boat", | 	output = "boats:boat", | ||||||
| 	recipe = { | 	recipe = { | ||||||
| @@ -214,4 +245,3 @@ minetest.register_craft({ | |||||||
| 		{"group:wood", "group:wood", "group:wood"}, | 		{"group:wood", "group:wood", "group:wood"}, | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										11110
									
								
								mods/boats/models/boat.x
									
									
									
									
									
								
							
							
						
						
							
								
								
									
										358
									
								
								mods/boats/models/boats_boat.obj
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,358 @@ | |||||||
|  | # Blender v2.76 (sub 11) OBJ File: 'boat.blend' | ||||||
|  | # www.blender.org | ||||||
|  | mtllib boat.mtl | ||||||
|  | o boats_boat | ||||||
|  | v -6.786140 -3.033999 -9.415440 | ||||||
|  | v -6.786140 -1.967150 -9.415440 | ||||||
|  | v -6.786140 -1.967150 8.793510 | ||||||
|  | v -6.786140 -3.033999 8.793510 | ||||||
|  | v 5.732520 -1.967150 -9.415440 | ||||||
|  | v 5.732520 -3.033999 -9.415440 | ||||||
|  | v 5.732520 -3.033999 8.793510 | ||||||
|  | v 5.732520 -1.967150 8.793510 | ||||||
|  | v -2.233900 -3.033999 -9.415440 | ||||||
|  | v -2.233900 -1.967150 -9.415440 | ||||||
|  | v -2.233900 -1.967150 8.793510 | ||||||
|  | v -2.233900 -3.033999 8.793510 | ||||||
|  | v 2.318340 -3.033999 -9.415440 | ||||||
|  | v 2.318340 -1.967150 -9.415440 | ||||||
|  | v 2.318340 -1.967150 8.793510 | ||||||
|  | v 2.318340 -3.033999 8.793510 | ||||||
|  | v -3.371960 -3.033999 8.793510 | ||||||
|  | v -3.371960 -1.967150 8.793510 | ||||||
|  | v -3.371960 -1.967150 -9.415440 | ||||||
|  | v -3.371960 -3.033999 -9.415440 | ||||||
|  | v 2.318340 0.276645 8.793510 | ||||||
|  | v 1.180280 -1.967150 8.793510 | ||||||
|  | v 5.732520 0.276645 8.793510 | ||||||
|  | v 5.732520 1.039180 8.793510 | ||||||
|  | v 6.870580 0.276645 8.793510 | ||||||
|  | v 6.870580 -1.967150 8.793510 | ||||||
|  | v 2.318340 1.039180 8.793510 | ||||||
|  | v 1.180280 0.276645 8.793510 | ||||||
|  | v 1.180280 1.039180 8.793510 | ||||||
|  | v 1.180280 -3.033999 8.793510 | ||||||
|  | v -2.233900 0.276645 8.793510 | ||||||
|  | v -3.371960 0.276645 8.793510 | ||||||
|  | v -2.233900 1.039180 8.793510 | ||||||
|  | v -3.371960 1.039180 8.793510 | ||||||
|  | v -6.786140 0.276645 8.793510 | ||||||
|  | v -7.786200 0.276645 8.793510 | ||||||
|  | v -7.786200 -1.967150 8.793510 | ||||||
|  | v -6.786140 1.039180 8.793510 | ||||||
|  | v 1.180280 -1.967150 -9.415440 | ||||||
|  | v 1.180280 -3.033999 -9.415440 | ||||||
|  | v 2.318340 0.276645 -9.415440 | ||||||
|  | v 1.180280 0.276645 -9.415440 | ||||||
|  | v 2.318340 1.039180 -9.415440 | ||||||
|  | v 5.732520 0.276645 -9.415440 | ||||||
|  | v 6.870580 -1.967150 -9.415440 | ||||||
|  | v 5.732520 1.039180 -9.415440 | ||||||
|  | v 6.870580 0.276645 -9.415440 | ||||||
|  | v 0.042220 1.039180 -9.415440 | ||||||
|  | v 1.180280 1.039180 -9.415440 | ||||||
|  | v 0.042220 -1.967150 -9.415440 | ||||||
|  | v -1.095840 -1.967150 -9.415440 | ||||||
|  | v -2.233900 0.276645 -9.415440 | ||||||
|  | v -3.371960 0.276645 -9.415440 | ||||||
|  | v -2.233900 1.039180 -9.415440 | ||||||
|  | v -1.095840 1.039180 -9.415440 | ||||||
|  | v -3.371960 1.039180 -9.415440 | ||||||
|  | v -6.786140 0.276645 -9.415440 | ||||||
|  | v -6.786140 1.039180 -9.415440 | ||||||
|  | v -7.786200 -1.967150 -9.415440 | ||||||
|  | v -7.786200 0.276645 -9.415440 | ||||||
|  | v -1.095840 0.156645 -12.044100 | ||||||
|  | v -1.095840 -4.601110 -9.415440 | ||||||
|  | v -1.095840 1.039181 -10.802900 | ||||||
|  | v -1.095840 2.868579 -10.802900 | ||||||
|  | v -1.095840 2.868580 -7.883420 | ||||||
|  | v -1.095840 3.746069 -12.034100 | ||||||
|  | v -1.095840 3.746070 -7.883420 | ||||||
|  | v -1.095840 0.156645 -14.294900 | ||||||
|  | v -1.095840 -4.601110 -14.284900 | ||||||
|  | v 0.042220 -4.601110 -14.284900 | ||||||
|  | v 0.042220 -4.601110 -9.415440 | ||||||
|  | v 0.042220 1.039181 -10.802900 | ||||||
|  | v 0.042220 0.156645 -12.044100 | ||||||
|  | v 0.042220 2.868579 -10.802900 | ||||||
|  | v 0.042220 0.156645 -14.294900 | ||||||
|  | v 0.042220 3.746069 -12.034100 | ||||||
|  | v 0.042220 3.746070 -7.883420 | ||||||
|  | v 0.042220 2.868580 -7.883420 | ||||||
|  | v -1.096322 -3.033999 -9.415440 | ||||||
|  | v 0.044046 -3.035397 -9.415440 | ||||||
|  | vt 1.000000 0.187500 | ||||||
|  | vt -1.000000 0.312500 | ||||||
|  | vt 1.000000 0.312500 | ||||||
|  | vt 0.687500 1.000000 | ||||||
|  | vt 0.500000 0.875000 | ||||||
|  | vt 0.500000 0.625000 | ||||||
|  | vt -1.000000 0.062500 | ||||||
|  | vt 1.000000 0.062500 | ||||||
|  | vt 1.000000 -0.000000 | ||||||
|  | vt -1.000000 0.125000 | ||||||
|  | vt 1.000000 0.125000 | ||||||
|  | vt 0.437500 0.125000 | ||||||
|  | vt 0.312500 0.500000 | ||||||
|  | vt 0.312500 0.125000 | ||||||
|  | vt 1.000000 0.625000 | ||||||
|  | vt -1.000000 0.500000 | ||||||
|  | vt 1.000000 0.500000 | ||||||
|  | vt 0.187500 0.687500 | ||||||
|  | vt -0.187500 0.687500 | ||||||
|  | vt -0.187500 0.312500 | ||||||
|  | vt 1.000000 0.812500 | ||||||
|  | vt -1.000000 0.937500 | ||||||
|  | vt -1.000000 0.812500 | ||||||
|  | vt 0.812500 0.687500 | ||||||
|  | vt 1.187500 0.687500 | ||||||
|  | vt 0.812500 0.312500 | ||||||
|  | vt 1.000000 0.562500 | ||||||
|  | vt 0.312500 0.437500 | ||||||
|  | vt 1.000000 0.437500 | ||||||
|  | vt 1.000000 0.750000 | ||||||
|  | vt -1.000000 0.875000 | ||||||
|  | vt -1.000000 0.750000 | ||||||
|  | vt -1.000000 1.000000 | ||||||
|  | vt 1.000000 1.000000 | ||||||
|  | vt 0.437500 0.625000 | ||||||
|  | vt 0.562500 0.437500 | ||||||
|  | vt 0.562500 0.625000 | ||||||
|  | vt -1.000000 0.437500 | ||||||
|  | vt -1.000000 0.000000 | ||||||
|  | vt 0.500000 0.062500 | ||||||
|  | vt 0.375000 0.750000 | ||||||
|  | vt 0.500000 0.750000 | ||||||
|  | vt -1.000000 0.250000 | ||||||
|  | vt -1.000000 0.687500 | ||||||
|  | vt 1.000000 0.687500 | ||||||
|  | vt 0.625000 0.375000 | ||||||
|  | vt 1.000000 0.375000 | ||||||
|  | vt 1.000000 0.250000 | ||||||
|  | vt 1.000000 0.937500 | ||||||
|  | vt 0.437500 0.812500 | ||||||
|  | vt 0.312500 0.312500 | ||||||
|  | vt 0.312500 0.812500 | ||||||
|  | vt 0.437500 0.312500 | ||||||
|  | vt 0.437500 0.437500 | ||||||
|  | vt 0.687500 0.812500 | ||||||
|  | vt 0.000000 0.687500 | ||||||
|  | vt 0.000000 0.812500 | ||||||
|  | vt -1.000000 0.562500 | ||||||
|  | vt 0.875000 0.812500 | ||||||
|  | vt 0.875000 0.687500 | ||||||
|  | vt 0.250000 0.312500 | ||||||
|  | vt 0.562500 0.187500 | ||||||
|  | vt 0.250000 0.187500 | ||||||
|  | vt -1.000000 0.187500 | ||||||
|  | vt 0.312500 0.625000 | ||||||
|  | vt 0.312500 0.187500 | ||||||
|  | vt 0.312500 -0.187500 | ||||||
|  | vt 1.000000 -0.187500 | ||||||
|  | vt 0.687500 0.500000 | ||||||
|  | vt -0.000000 1.000000 | ||||||
|  | vt 0.000000 0.875000 | ||||||
|  | vt 0.437500 0.500000 | ||||||
|  | vt -1.000000 0.625000 | ||||||
|  | vt 0.812500 0.187500 | ||||||
|  | vt 1.187500 0.187500 | ||||||
|  | vt 1.187500 0.312500 | ||||||
|  | vt 1.312500 0.312500 | ||||||
|  | vt 1.312500 0.687500 | ||||||
|  | vt 0.687500 0.187500 | ||||||
|  | vt 0.687500 0.312500 | ||||||
|  | vt 1.187500 0.812500 | ||||||
|  | vt 0.812500 0.812500 | ||||||
|  | vt 0.187500 0.312500 | ||||||
|  | vt 0.312500 0.687500 | ||||||
|  | vt 0.687500 0.687500 | ||||||
|  | vt -0.187500 0.187500 | ||||||
|  | vt 0.187500 0.187500 | ||||||
|  | vt -0.312500 0.687500 | ||||||
|  | vt -0.312500 0.312500 | ||||||
|  | vt 0.187500 0.812500 | ||||||
|  | vt -0.187500 0.812500 | ||||||
|  | vt 0.437500 0.687500 | ||||||
|  | vt 0.437500 0.187500 | ||||||
|  | vt 0.562500 0.812500 | ||||||
|  | vt 0.562500 0.687500 | ||||||
|  | vt 0.312500 0.562500 | ||||||
|  | vt 1.000000 0.875000 | ||||||
|  | vt 0.375000 0.062500 | ||||||
|  | vt -1.000000 0.375000 | ||||||
|  | vt 0.625000 0.500000 | ||||||
|  | vt 0.875000 0.562500 | ||||||
|  | vt 0.937500 0.812500 | ||||||
|  | vt 0.937500 0.687500 | ||||||
|  | vt 0.875000 0.937500 | ||||||
|  | vt 0.562500 0.312500 | ||||||
|  | vn -1.000000 0.000000 0.000000 | ||||||
|  | vn 1.000000 0.000000 0.000000 | ||||||
|  | vn 0.000000 0.000000 1.000000 | ||||||
|  | vn 0.000000 0.000000 -1.000000 | ||||||
|  | vn 0.000000 -1.000000 0.000000 | ||||||
|  | vn 0.000000 1.000000 0.000000 | ||||||
|  | vn 0.000000 -0.002100 -1.000000 | ||||||
|  | vn 0.001200 -1.000000 0.000000 | ||||||
|  | vn 0.000000 0.002800 -1.000000 | ||||||
|  | vn -0.001200 -1.000000 0.000200 | ||||||
|  | g boats_boat_boats_boat_None | ||||||
|  | usemtl None | ||||||
|  | s off | ||||||
|  | f 41/1/1 27/2/1 43/3/1 | ||||||
|  | f 76/4/2 74/5/2 72/6/2 | ||||||
|  | f 8/7/2 6/1/2 5/8/2 | ||||||
|  | f 15/9/1 13/10/1 16/11/1 | ||||||
|  | f 51/12/3 71/13/3 50/14/3 | ||||||
|  | f 56/15/2 32/16/2 53/17/2 | ||||||
|  | f 15/18/3 8/19/3 23/20/3 | ||||||
|  | f 22/21/2 40/22/2 39/23/2 | ||||||
|  | f 19/24/4 2/25/4 53/26/4 | ||||||
|  | f 70/27/5 62/28/5 69/29/5 | ||||||
|  | f 11/30/5 19/31/5 10/32/5 | ||||||
|  | f 4/15/5 20/33/5 17/34/5 | ||||||
|  | f 72/35/3 64/36/3 63/37/3 | ||||||
|  | f 13/8/5 7/38/5 16/7/5 | ||||||
|  | f 23/39/6 47/11/6 44/9/6 | ||||||
|  | f 68/40/7 70/41/7 69/42/7 | ||||||
|  | f 80/43/8 40/10/8 30/11/8 | ||||||
|  | f 3/15/1 1/32/1 4/30/1 | ||||||
|  | f 20/44/2 18/27/2 17/45/2 | ||||||
|  | f 74/17/5 65/46/5 64/47/5 | ||||||
|  | f 31/43/1 54/47/1 52/48/1 | ||||||
|  | f 22/47/5 14/43/5 15/48/5 | ||||||
|  | f 46/1/2 23/7/2 44/8/2 | ||||||
|  | f 57/21/1 38/22/1 58/49/1 | ||||||
|  | f 61/50/9 76/51/9 73/52/9 | ||||||
|  | f 37/45/5 2/23/5 3/21/5 | ||||||
|  | f 78/28/3 67/53/3 65/54/3 | ||||||
|  | f 64/5/1 66/4/1 63/6/1 | ||||||
|  | f 76/55/6 67/56/6 77/57/6 | ||||||
|  | f 47/17/2 26/10/2 45/11/2 | ||||||
|  | f 5/16/5 26/47/5 8/17/5 | ||||||
|  | f 33/58/6 48/59/6 55/60/6 | ||||||
|  | f 29/38/2 42/3/2 49/29/2 | ||||||
|  | f 32/44/6 52/21/6 53/45/6 | ||||||
|  | f 58/15/6 34/33/6 56/34/6 | ||||||
|  | f 27/7/6 46/29/6 43/8/6 | ||||||
|  | f 73/61/6 68/62/6 61/63/6 | ||||||
|  | f 21/58/6 42/29/6 28/38/6 | ||||||
|  | f 11/29/1 9/58/1 12/27/1 | ||||||
|  | f 59/45/1 36/2/1 60/3/1 | ||||||
|  | f 60/9/6 35/10/6 57/11/6 | ||||||
|  | f 41/1/1 21/64/1 27/2/1 | ||||||
|  | f 72/6/2 48/65/2 50/66/2 | ||||||
|  | f 50/66/2 71/67/2 70/68/2 | ||||||
|  | f 70/68/2 75/17/2 73/69/2 | ||||||
|  | f 76/4/2 77/70/2 74/5/2 | ||||||
|  | f 77/70/2 78/71/2 74/5/2 | ||||||
|  | f 50/66/2 70/68/2 73/69/2 | ||||||
|  | f 73/69/2 76/4/2 72/6/2 | ||||||
|  | f 72/6/2 50/66/2 73/69/2 | ||||||
|  | f 8/7/2 7/64/2 6/1/2 | ||||||
|  | f 15/9/1 14/39/1 13/10/1 | ||||||
|  | f 51/12/3 62/72/3 71/13/3 | ||||||
|  | f 56/15/2 34/73/2 32/16/2 | ||||||
|  | f 32/26/3 34/74/3 38/75/3 | ||||||
|  | f 35/76/3 36/77/3 37/78/3 | ||||||
|  | f 32/26/3 38/75/3 35/76/3 | ||||||
|  | f 29/66/3 33/79/3 31/80/3 | ||||||
|  | f 32/26/3 35/76/3 3/25/3 | ||||||
|  | f 28/51/3 29/66/3 31/80/3 | ||||||
|  | f 31/80/3 32/26/3 18/24/3 | ||||||
|  | f 3/25/3 4/81/3 17/82/3 | ||||||
|  | f 35/76/3 37/78/3 3/25/3 | ||||||
|  | f 21/83/3 28/51/3 22/84/3 | ||||||
|  | f 3/25/3 17/82/3 18/24/3 | ||||||
|  | f 11/85/3 12/55/3 30/52/3 | ||||||
|  | f 32/26/3 3/25/3 18/24/3 | ||||||
|  | f 11/85/3 30/52/3 22/84/3 | ||||||
|  | f 31/80/3 18/24/3 11/85/3 | ||||||
|  | f 24/86/3 27/87/3 21/83/3 | ||||||
|  | f 28/51/3 31/80/3 11/85/3 | ||||||
|  | f 11/85/3 22/84/3 28/51/3 | ||||||
|  | f 24/86/3 21/83/3 23/20/3 | ||||||
|  | f 26/88/3 25/89/3 23/20/3 | ||||||
|  | f 23/20/3 21/83/3 15/18/3 | ||||||
|  | f 15/18/3 16/90/3 7/91/3 | ||||||
|  | f 21/83/3 22/84/3 15/18/3 | ||||||
|  | f 8/19/3 26/88/3 23/20/3 | ||||||
|  | f 15/18/3 7/91/3 8/19/3 | ||||||
|  | f 22/21/2 30/49/2 40/22/2 | ||||||
|  | f 47/89/4 45/88/4 5/19/4 | ||||||
|  | f 5/19/4 6/91/4 13/90/4 | ||||||
|  | f 5/19/4 13/90/4 14/18/4 | ||||||
|  | f 44/20/4 47/89/4 5/19/4 | ||||||
|  | f 43/87/4 46/86/4 44/20/4 | ||||||
|  | f 41/83/4 43/87/4 44/20/4 | ||||||
|  | f 44/20/4 5/19/4 14/18/4 | ||||||
|  | f 39/84/4 40/52/4 80/50/4 | ||||||
|  | f 44/20/4 14/18/4 41/83/4 | ||||||
|  | f 42/51/4 41/83/4 39/84/4 | ||||||
|  | f 39/84/4 80/50/4 50/92/4 | ||||||
|  | f 41/83/4 14/18/4 39/84/4 | ||||||
|  | f 48/93/4 49/66/4 42/51/4 | ||||||
|  | f 50/92/4 48/93/4 42/51/4 | ||||||
|  | f 80/50/4 79/94/4 50/92/4 | ||||||
|  | f 50/92/4 42/51/4 39/84/4 | ||||||
|  | f 54/79/4 55/62/4 52/80/4 | ||||||
|  | f 50/92/4 79/94/4 51/95/4 | ||||||
|  | f 52/80/4 55/62/4 51/95/4 | ||||||
|  | f 51/95/4 79/94/4 10/85/4 | ||||||
|  | f 79/94/4 9/55/4 10/85/4 | ||||||
|  | f 53/26/4 52/80/4 10/85/4 | ||||||
|  | f 58/75/4 56/74/4 53/26/4 | ||||||
|  | f 59/78/4 60/77/4 57/76/4 | ||||||
|  | f 57/76/4 58/75/4 53/26/4 | ||||||
|  | f 52/80/4 51/95/4 10/85/4 | ||||||
|  | f 19/24/4 20/82/4 1/81/4 | ||||||
|  | f 53/26/4 10/85/4 19/24/4 | ||||||
|  | f 59/78/4 57/76/4 2/25/4 | ||||||
|  | f 19/24/4 1/81/4 2/25/4 | ||||||
|  | f 2/25/4 57/76/4 53/26/4 | ||||||
|  | f 70/27/5 71/96/5 62/28/5 | ||||||
|  | f 11/30/5 18/97/5 19/31/5 | ||||||
|  | f 4/15/5 1/73/5 20/33/5 | ||||||
|  | f 72/35/3 74/54/3 64/36/3 | ||||||
|  | f 13/8/5 6/29/5 7/38/5 | ||||||
|  | f 23/39/6 25/10/6 47/11/6 | ||||||
|  | f 68/40/7 75/98/7 70/41/7 | ||||||
|  | f 30/11/5 12/17/5 79/99/5 | ||||||
|  | f 79/99/10 80/43/10 30/11/10 | ||||||
|  | f 12/17/5 9/16/5 79/99/5 | ||||||
|  | f 3/15/1 2/73/1 1/32/1 | ||||||
|  | f 20/44/2 19/58/2 18/27/2 | ||||||
|  | f 74/17/5 78/100/5 65/46/5 | ||||||
|  | f 31/43/1 33/99/1 54/47/1 | ||||||
|  | f 22/47/5 39/99/5 14/43/5 | ||||||
|  | f 46/1/2 24/64/2 23/7/2 | ||||||
|  | f 57/21/1 35/23/1 38/22/1 | ||||||
|  | f 61/50/9 66/53/9 76/51/9 | ||||||
|  | f 37/45/5 59/44/5 2/23/5 | ||||||
|  | f 78/28/3 77/51/3 67/53/3 | ||||||
|  | f 62/67/1 51/66/1 69/68/1 | ||||||
|  | f 51/66/1 55/65/1 63/6/1 | ||||||
|  | f 68/17/1 69/68/1 61/69/1 | ||||||
|  | f 61/69/1 69/68/1 51/66/1 | ||||||
|  | f 61/69/1 51/66/1 63/6/1 | ||||||
|  | f 65/71/1 67/70/1 64/5/1 | ||||||
|  | f 61/69/1 63/6/1 66/4/1 | ||||||
|  | f 64/5/1 67/70/1 66/4/1 | ||||||
|  | f 76/55/6 66/85/6 67/56/6 | ||||||
|  | f 47/17/2 25/16/2 26/10/2 | ||||||
|  | f 5/16/5 45/99/5 26/47/5 | ||||||
|  | f 55/60/6 54/101/6 33/58/6 | ||||||
|  | f 33/58/6 29/22/6 48/59/6 | ||||||
|  | f 48/59/6 72/102/6 63/103/6 | ||||||
|  | f 29/22/6 49/104/6 48/59/6 | ||||||
|  | f 48/59/6 63/103/6 55/60/6 | ||||||
|  | f 29/38/2 28/2/2 42/3/2 | ||||||
|  | f 32/44/6 31/23/6 52/21/6 | ||||||
|  | f 58/15/6 38/73/6 34/33/6 | ||||||
|  | f 27/7/6 24/38/6 46/29/6 | ||||||
|  | f 73/61/6 75/105/6 68/62/6 | ||||||
|  | f 21/58/6 41/27/6 42/29/6 | ||||||
|  | f 11/29/1 10/38/1 9/58/1 | ||||||
|  | f 59/45/1 37/44/1 36/2/1 | ||||||
|  | f 60/9/6 36/39/6 35/10/6 | ||||||
| Before Width: | Height: | Size: 1.4 KiB | 
| Before Width: | Height: | Size: 847 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/boats/textures/boats_inventory.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 851 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/boats/textures/boats_wield.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 546 B | 
| @@ -1,5 +1,5 @@ | |||||||
| Minetest 0.4 mod: bones | Minetest Game mod: bones | ||||||
| ======================= | ======================== | ||||||
|  |  | ||||||
| License of source code: | License of source code: | ||||||
| ----------------------- | ----------------------- | ||||||
|   | |||||||
| @@ -1,14 +1,31 @@ | |||||||
| -- Minetest 0.4 mod: bones | -- Minetest 0.4 mod: bones | ||||||
| -- See README.txt for licensing and other information.  | -- See README.txt for licensing and other information.  | ||||||
|  |  | ||||||
|  | bones = {} | ||||||
|  |  | ||||||
| local function is_owner(pos, name) | local function is_owner(pos, name) | ||||||
| 	local owner = minetest.get_meta(pos):get_string("owner") | 	local owner = minetest.get_meta(pos):get_string("owner") | ||||||
| 	if owner == "" or owner == name then | 	if owner == "" or owner == name or minetest.check_player_privs(name, "protection_bypass") then | ||||||
| 		return true | 		return true | ||||||
| 	end | 	end | ||||||
| 	return false | 	return false | ||||||
| end | end | ||||||
|  |  | ||||||
|  | bones.bones_formspec = | ||||||
|  | 	"size[8,9]" .. | ||||||
|  | 	default.gui_bg .. | ||||||
|  | 	default.gui_bg_img .. | ||||||
|  | 	default.gui_slots .. | ||||||
|  | 	"list[current_name;main;0,0.3;8,4;]" .. | ||||||
|  | 	"list[current_player;main;0,4.85;8,1;]" .. | ||||||
|  | 	"list[current_player;main;0,6.08;8,3;8]" .. | ||||||
|  | 	"listring[current_name;main]" .. | ||||||
|  | 	"listring[current_player;main]" .. | ||||||
|  | 	default.get_hotbar_bg(0,4.85) | ||||||
|  |  | ||||||
|  | local share_bones_time = tonumber(minetest.setting_get("share_bones_time")) or 1200 | ||||||
|  | local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early")) or share_bones_time / 4 | ||||||
|  |  | ||||||
| minetest.register_node("bones:bones", { | minetest.register_node("bones:bones", { | ||||||
| 	description = "Bones", | 	description = "Bones", | ||||||
| 	tiles = { | 	tiles = { | ||||||
| @@ -28,7 +45,11 @@ minetest.register_node("bones:bones", { | |||||||
| 	 | 	 | ||||||
| 	can_dig = function(pos, player) | 	can_dig = function(pos, player) | ||||||
| 		local inv = minetest.get_meta(pos):get_inventory() | 		local inv = minetest.get_meta(pos):get_inventory() | ||||||
| 		return is_owner(pos, player:get_player_name()) and inv:is_empty("main") | 		local name = "" | ||||||
|  | 		if player then | ||||||
|  | 			name = player:get_player_name() | ||||||
|  | 		end | ||||||
|  | 		return is_owner(pos, name) and inv:is_empty("main") | ||||||
| 	end, | 	end, | ||||||
| 	 | 	 | ||||||
| 	allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) | 	allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) | ||||||
| @@ -61,6 +82,10 @@ minetest.register_node("bones:bones", { | |||||||
| 			return | 			return | ||||||
| 		end | 		end | ||||||
| 		 | 		 | ||||||
|  | 		if(minetest.get_meta(pos):get_string("infotext") == "") then | ||||||
|  | 			return | ||||||
|  | 		end | ||||||
|  | 		 | ||||||
| 		local inv = minetest.get_meta(pos):get_inventory() | 		local inv = minetest.get_meta(pos):get_inventory() | ||||||
| 		local player_inv = player:get_inventory() | 		local player_inv = player:get_inventory() | ||||||
| 		local has_space = true | 		local has_space = true | ||||||
| @@ -78,29 +103,60 @@ minetest.register_node("bones:bones", { | |||||||
| 		 | 		 | ||||||
| 		-- remove bones if player emptied them | 		-- remove bones if player emptied them | ||||||
| 		if has_space then | 		if has_space then | ||||||
|  | 			if player_inv:room_for_item("main", {name = "bones:bones"}) then | ||||||
|  | 				player_inv:add_item("main", {name = "bones:bones"}) | ||||||
|  | 			else | ||||||
|  | 				minetest.add_item(pos,"bones:bones") | ||||||
|  | 			end | ||||||
| 			minetest.remove_node(pos) | 			minetest.remove_node(pos) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	 | 	 | ||||||
| 	on_timer = function(pos, elapsed) | 	on_timer = function(pos, elapsed) | ||||||
| 		local meta = minetest.get_meta(pos) | 		local meta = minetest.get_meta(pos) | ||||||
| 		local time = meta:get_int("time")+elapsed | 		local time = meta:get_int("time") + elapsed | ||||||
| 		local publish = 1200 | 		if time >= share_bones_time then | ||||||
| 		if tonumber(minetest.setting_get("share_bones_time")) then |  | ||||||
| 			publish = tonumber(minetest.setting_get("share_bones_time")) |  | ||||||
| 		end |  | ||||||
| 		if publish == 0 then |  | ||||||
| 			return |  | ||||||
| 		end |  | ||||||
| 		if time >= publish then |  | ||||||
| 			meta:set_string("infotext", meta:get_string("owner").."'s old bones") | 			meta:set_string("infotext", meta:get_string("owner").."'s old bones") | ||||||
| 			meta:set_string("owner", "") | 			meta:set_string("owner", "") | ||||||
| 		else | 		else | ||||||
|  | 			meta:set_int("time", time) | ||||||
| 			return true | 			return true | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
|  | 	on_blast = function(pos) | ||||||
|  | 	end, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | local function may_replace(pos, player) | ||||||
|  | 	local node_name = minetest.get_node(pos).name | ||||||
|  | 	local node_definition = minetest.registered_nodes[node_name] | ||||||
|  |  | ||||||
|  | 	-- if the node is unknown, we let the protection mod decide | ||||||
|  | 	-- this is consistent with when a player could dig or not dig it | ||||||
|  | 	-- unknown decoration would often be removed | ||||||
|  | 	-- while unknown building materials in use would usually be left | ||||||
|  | 	if not node_definition then | ||||||
|  | 		-- only replace nodes that are not protected | ||||||
|  | 		return not minetest.is_protected(pos, player:get_player_name()) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- allow replacing air and liquids | ||||||
|  | 	if node_name == "air" or node_definition.liquidtype ~= "none" then | ||||||
|  | 		return true | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- don't replace filled chests and other nodes that don't allow it | ||||||
|  | 	local can_dig_func = node_definition.can_dig | ||||||
|  | 	if can_dig_func and not can_dig_func(pos, player) then | ||||||
|  | 		return false | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- default to each nodes buildable_to; if a placed block would replace it, why shouldn't bones? | ||||||
|  | 	-- flowers being squished by bones are more realistical than a squished stone, too | ||||||
|  | 	-- exception are of course any protected buildable_to | ||||||
|  | 	return node_definition.buildable_to and not minetest.is_protected(pos, player:get_player_name()) | ||||||
|  | end | ||||||
|  |  | ||||||
| minetest.register_on_dieplayer(function(player) | minetest.register_on_dieplayer(function(player) | ||||||
| 	if minetest.setting_getbool("creative_mode") then | 	if minetest.setting_getbool("creative_mode") then | ||||||
| 		return | 		return | ||||||
| @@ -120,10 +176,13 @@ minetest.register_on_dieplayer(function(player) | |||||||
| 	local player_name = player:get_player_name() | 	local player_name = player:get_player_name() | ||||||
| 	local player_inv = player:get_inventory() | 	local player_inv = player:get_inventory() | ||||||
|  |  | ||||||
| 	local nn = minetest.get_node(pos).name | 	if (not may_replace(pos, player)) then | ||||||
| 	if minetest.registered_nodes[nn].can_dig and | 		if (may_replace({x=pos.x, y=pos.y+1, z=pos.z}, player)) then | ||||||
| 		not minetest.registered_nodes[nn].can_dig(pos, player) then | 			-- drop one node above if there's space | ||||||
|  | 			-- this should solve most cases of protection related deaths in which players dig straight down | ||||||
|  | 			-- yet keeps the bones reachable | ||||||
|  | 			pos.y = pos.y+1 | ||||||
|  | 		else | ||||||
| 			-- drop items instead of delete | 			-- drop items instead of delete | ||||||
| 			for i=1,player_inv:get_size("main") do | 			for i=1,player_inv:get_size("main") do | ||||||
| 				minetest.add_item(pos, player_inv:get_stack("main", i)) | 				minetest.add_item(pos, player_inv:get_stack("main", i)) | ||||||
| @@ -136,9 +195,9 @@ minetest.register_on_dieplayer(function(player) | |||||||
| 			player_inv:set_list("craft", {}) | 			player_inv:set_list("craft", {}) | ||||||
| 			return | 			return | ||||||
| 		end | 		end | ||||||
|  | 	end | ||||||
| 	 | 	 | ||||||
| 	minetest.dig_node(pos) | 	minetest.set_node(pos, {name="bones:bones", param2=param2}) | ||||||
| 	minetest.add_node(pos, {name="bones:bones", param2=param2}) |  | ||||||
| 	 | 	 | ||||||
| 	local meta = minetest.get_meta(pos) | 	local meta = minetest.get_meta(pos) | ||||||
| 	local inv = meta:get_inventory() | 	local inv = meta:get_inventory() | ||||||
| @@ -158,13 +217,20 @@ minetest.register_on_dieplayer(function(player) | |||||||
| 	player_inv:set_list("main", {}) | 	player_inv:set_list("main", {}) | ||||||
| 	player_inv:set_list("craft", {}) | 	player_inv:set_list("craft", {}) | ||||||
| 	 | 	 | ||||||
| 	meta:set_string("formspec", "size[8,9;]".. | 	meta:set_string("formspec", bones.bones_formspec) | ||||||
| 			"list[current_name;main;0,0;8,4;]".. |  | ||||||
| 			"list[current_player;main;0,5;8,4;]") |  | ||||||
| 	meta:set_string("infotext", player_name.."'s fresh bones") |  | ||||||
| 	meta:set_string("owner", player_name) | 	meta:set_string("owner", player_name) | ||||||
| 	meta:set_int("time", 0) |  | ||||||
| 	 | 	 | ||||||
| 	local timer  = minetest.get_node_timer(pos) | 	if share_bones_time ~= 0 then | ||||||
| 	timer:start(10) | 		meta:set_string("infotext", player_name.."'s fresh bones") | ||||||
|  |  | ||||||
|  | 		if share_bones_time_early == 0 or not minetest.is_protected(pos, player_name) then | ||||||
|  | 			meta:set_int("time", 0) | ||||||
|  | 		else | ||||||
|  | 			meta:set_int("time", (share_bones_time - share_bones_time_early)) | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		minetest.get_node_timer(pos):start(10) | ||||||
|  | 	else | ||||||
|  | 		meta:set_string("infotext", player_name.."'s bones") | ||||||
|  | 	end | ||||||
| end) | end) | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| Minetest 0.4 mod: bucket | Minetest Game mod: bucket | ||||||
| ========================= | ========================= | ||||||
|  |  | ||||||
| License of source code: | License of source code: | ||||||
|   | |||||||
| @@ -34,8 +34,10 @@ end | |||||||
| --    flowing = name of the flowing node | --    flowing = name of the flowing node | ||||||
| --    itemname = name of the new bucket item (or nil if liquid is not takeable) | --    itemname = name of the new bucket item (or nil if liquid is not takeable) | ||||||
| --    inventory_image = texture of the new bucket item (ignored if itemname == nil) | --    inventory_image = texture of the new bucket item (ignored if itemname == nil) | ||||||
|  | --    name = text description of the bucket item | ||||||
|  | --    groups = (optional) groups of the bucket item, for example {water_bucket = 1} | ||||||
| -- This function can be called from any mod (that depends on bucket). | -- This function can be called from any mod (that depends on bucket). | ||||||
| function bucket.register_liquid(source, flowing, itemname, inventory_image, name) | function bucket.register_liquid(source, flowing, itemname, inventory_image, name, groups) | ||||||
| 	bucket.liquids[source] = { | 	bucket.liquids[source] = { | ||||||
| 		source = source, | 		source = source, | ||||||
| 		flowing = flowing, | 		flowing = flowing, | ||||||
| @@ -49,6 +51,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name | |||||||
| 			inventory_image = inventory_image, | 			inventory_image = inventory_image, | ||||||
| 			stack_max = 1, | 			stack_max = 1, | ||||||
| 			liquids_pointable = true, | 			liquids_pointable = true, | ||||||
|  | 			groups = groups, | ||||||
| 			on_place = function(itemstack, user, pointed_thing) | 			on_place = function(itemstack, user, pointed_thing) | ||||||
| 				-- Must be pointing to node | 				-- Must be pointing to node | ||||||
| 				if pointed_thing.type ~= "node" then | 				if pointed_thing.type ~= "node" then | ||||||
| @@ -105,7 +108,7 @@ end | |||||||
| minetest.register_craftitem("bucket:bucket_empty", { | minetest.register_craftitem("bucket:bucket_empty", { | ||||||
| 	description = "Empty Bucket", | 	description = "Empty Bucket", | ||||||
| 	inventory_image = "bucket.png", | 	inventory_image = "bucket.png", | ||||||
| 	stack_max = 1, | 	stack_max = 99, | ||||||
| 	liquids_pointable = true, | 	liquids_pointable = true, | ||||||
| 	on_use = function(itemstack, user, pointed_thing) | 	on_use = function(itemstack, user, pointed_thing) | ||||||
| 		-- Must be pointing to node | 		-- Must be pointing to node | ||||||
| @@ -115,17 +118,41 @@ minetest.register_craftitem("bucket:bucket_empty", { | |||||||
| 		-- Check if pointing to a liquid source | 		-- Check if pointing to a liquid source | ||||||
| 		local node = minetest.get_node(pointed_thing.under) | 		local node = minetest.get_node(pointed_thing.under) | ||||||
| 		local liquiddef = bucket.liquids[node.name] | 		local liquiddef = bucket.liquids[node.name] | ||||||
| 		if liquiddef ~= nil and liquiddef.itemname ~= nil and | 		local item_count = user:get_wielded_item():get_count() | ||||||
| 				node.name == liquiddef.source then |  | ||||||
|  | 		if liquiddef ~= nil | ||||||
|  | 		and liquiddef.itemname ~= nil | ||||||
|  | 		and node.name == liquiddef.source then | ||||||
| 			if check_protection(pointed_thing.under, | 			if check_protection(pointed_thing.under, | ||||||
| 					user:get_player_name(), | 					user:get_player_name(), | ||||||
| 					"take ".. node.name) then | 					"take ".. node.name) then | ||||||
| 				return | 				return | ||||||
| 			end | 			end | ||||||
|  |  | ||||||
|  | 			-- default set to return filled bucket | ||||||
|  | 			local giving_back = liquiddef.itemname | ||||||
|  |  | ||||||
|  | 			-- check if holding more than 1 empty bucket | ||||||
|  | 			if item_count > 1 then | ||||||
|  |  | ||||||
|  | 				-- if space in inventory add filled bucked, otherwise drop as item | ||||||
|  | 				local inv = user:get_inventory() | ||||||
|  | 				if inv:room_for_item("main", {name=liquiddef.itemname}) then | ||||||
|  | 					inv:add_item("main", liquiddef.itemname) | ||||||
|  | 				else | ||||||
|  | 					local pos = user:getpos() | ||||||
|  | 					pos.y = math.floor(pos.y + 0.5) | ||||||
|  | 					core.add_item(pos, liquiddef.itemname) | ||||||
|  | 				end | ||||||
|  |  | ||||||
|  | 				-- set to return empty buckets minus 1 | ||||||
|  | 				giving_back = "bucket:bucket_empty "..tostring(item_count-1) | ||||||
|  |  | ||||||
|  | 			end | ||||||
|  |  | ||||||
| 			minetest.add_node(pointed_thing.under, {name="air"}) | 			minetest.add_node(pointed_thing.under, {name="air"}) | ||||||
|  |  | ||||||
| 			return ItemStack(liquiddef.itemname) | 			return ItemStack(giving_back) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| }) | }) | ||||||
| @@ -135,7 +162,17 @@ bucket.register_liquid( | |||||||
| 	"default:water_flowing", | 	"default:water_flowing", | ||||||
| 	"bucket:bucket_water", | 	"bucket:bucket_water", | ||||||
| 	"bucket_water.png", | 	"bucket_water.png", | ||||||
| 	"Water Bucket" | 	"Water Bucket", | ||||||
|  | 	{water_bucket = 1} | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | bucket.register_liquid( | ||||||
|  | 	"default:river_water_source", | ||||||
|  | 	"default:river_water_flowing", | ||||||
|  | 	"bucket:bucket_river_water", | ||||||
|  | 	"bucket_river_water.png", | ||||||
|  | 	"River Water Bucket", | ||||||
|  | 	{water_bucket = 1} | ||||||
| ) | ) | ||||||
|  |  | ||||||
| bucket.register_liquid( | bucket.register_liquid( | ||||||
| @@ -152,3 +189,4 @@ minetest.register_craft({ | |||||||
| 	burntime = 60, | 	burntime = 60, | ||||||
| 	replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, | 	replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								mods/bucket/textures/bucket.png
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						| Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 205 B | 
| Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 221 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/bucket/textures/bucket_river_water.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 221 B | 
| Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 221 B | 
| @@ -1,5 +1,5 @@ | |||||||
| Minetest 0.4 mod: creative | Minetest Game mod: creative | ||||||
| ========================== | =========================== | ||||||
|  |  | ||||||
| Implements creative mode. | Implements creative mode. | ||||||
|  |  | ||||||
| @@ -13,6 +13,7 @@ are added to the creative inventory. | |||||||
| License of source code and media files: | License of source code and media files: | ||||||
| --------------------------------------- | --------------------------------------- | ||||||
| Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com> | Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com> | ||||||
|  | Copyright (C) 2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> | ||||||
|  |  | ||||||
| This program is free software. It comes without any warranty, to | This program is free software. It comes without any warranty, to | ||||||
| the extent permitted by applicable law. You can redistribute it | the extent permitted by applicable law. You can redistribute it | ||||||
|   | |||||||
| @@ -1,13 +1,21 @@ | |||||||
| -- minetest/creative/init.lua | -- minetest/creative/init.lua | ||||||
|  |  | ||||||
| creative_inventory = {} | creative = {} | ||||||
| creative_inventory.creative_inventory_size = 0 | local player_inventory = {} | ||||||
|  | local creative_mode = minetest.setting_getbool("creative_mode") | ||||||
|  |  | ||||||
| -- Create detached creative inventory after loading all mods | -- Create detached creative inventory after loading all mods | ||||||
| minetest.after(0, function() | creative.init_creative_inventory = function(player) | ||||||
| 	local inv = minetest.create_detached_inventory("creative", { | 	local player_name = player:get_player_name() | ||||||
|  | 	player_inventory[player_name] = {} | ||||||
|  | 	player_inventory[player_name].size = 0 | ||||||
|  | 	player_inventory[player_name].filter = "" | ||||||
|  | 	player_inventory[player_name].start_i = 1 | ||||||
|  | 	player_inventory[player_name].tab_id = 2 | ||||||
|  |  | ||||||
|  | 	minetest.create_detached_inventory("creative_" .. player_name, { | ||||||
| 		allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) | 		allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) | ||||||
| 			if minetest.setting_getbool("creative_mode") then | 			if creative_mode and not to_list == "main" then | ||||||
| 				return count | 				return count | ||||||
| 			else | 			else | ||||||
| 				return 0 | 				return 0 | ||||||
| @@ -17,7 +25,7 @@ minetest.after(0, function() | |||||||
| 			return 0 | 			return 0 | ||||||
| 		end, | 		end, | ||||||
| 		allow_take = function(inv, listname, index, stack, player) | 		allow_take = function(inv, listname, index, stack, player) | ||||||
| 			if minetest.setting_getbool("creative_mode") then | 			if creative_mode then | ||||||
| 				return -1 | 				return -1 | ||||||
| 			else | 			else | ||||||
| 				return 0 | 				return 0 | ||||||
| @@ -28,123 +36,205 @@ minetest.after(0, function() | |||||||
| 		on_put = function(inv, listname, index, stack, player) | 		on_put = function(inv, listname, index, stack, player) | ||||||
| 		end, | 		end, | ||||||
| 		on_take = function(inv, listname, index, stack, player) | 		on_take = function(inv, listname, index, stack, player) | ||||||
| 			--print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack)) | 			local player_name, stack_name = player:get_player_name(), stack:get_name() | ||||||
|  | 			--print(player_name .. " takes item from creative inventory; listname = " .. listname .. ", index = " .. index .. ", stack = " .. dump(stack:to_table())) | ||||||
| 			if stack then | 			if stack then | ||||||
| 				minetest.log("action", player:get_player_name().." takes "..dump(stack:get_name()).." from creative inventory") | 				minetest.log("action", player_name .. " takes " .. stack_name .. " from creative inventory") | ||||||
| 				--print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count())) | 				--print("Stack name: " .. stack_name .. ", Stack count: " .. stack:get_count()) | ||||||
| 			end | 			end | ||||||
| 		end, | 		end, | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|  | 	creative.update_creative_inventory(player_name) | ||||||
|  | 	--print("creative inventory size: " .. player_inventory[player_name].size) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | local function tab_category(tab_id) | ||||||
|  | 	local id_category = { | ||||||
|  | 		nil, -- Reserved for crafting tab. | ||||||
|  | 		minetest.registered_items, | ||||||
|  | 		minetest.registered_nodes, | ||||||
|  | 		minetest.registered_tools, | ||||||
|  | 		minetest.registered_craftitems | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	-- If index out of range, show default ("All") page. | ||||||
|  | 	return id_category[tab_id] or id_category[2] | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function creative.update_creative_inventory(player_name) | ||||||
| 	local creative_list = {} | 	local creative_list = {} | ||||||
| 	for name,def in pairs(minetest.registered_items) do | 	local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name}) | ||||||
| 		if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) | 	local inv = player_inventory[player_name] | ||||||
| 				and def.description and def.description ~= "" then |  | ||||||
| 			table.insert(creative_list, name) | 	for name, def in pairs(tab_category(inv.tab_id)) do | ||||||
|  | 		if not (def.groups.not_in_creative_inventory == 1) and | ||||||
|  | 				def.description and def.description ~= "" and | ||||||
|  | 				(def.name:find(inv.filter, 1, true) or | ||||||
|  | 					def.description:lower():find(inv.filter, 1, true)) then | ||||||
|  | 			creative_list[#creative_list+1] = name | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	table.sort(creative_list) | 	table.sort(creative_list) | ||||||
| 	inv:set_size("main", #creative_list) | 	player_inv:set_size("main", #creative_list) | ||||||
| 	for _,itemstring in ipairs(creative_list) do | 	player_inv:set_list("main", creative_list) | ||||||
| 		inv:add_item("main", ItemStack(itemstring)) | 	inv.size = #creative_list | ||||||
| 	end | end | ||||||
| 	creative_inventory.creative_inventory_size = #creative_list |  | ||||||
| 	--print("creative inventory size: "..dump(creative_inventory.creative_inventory_size)) |  | ||||||
| end) |  | ||||||
|  |  | ||||||
| -- Create the trash field | -- Create the trash field | ||||||
| local trash = minetest.create_detached_inventory("creative_trash", { | local trash = minetest.create_detached_inventory("creative_trash", { | ||||||
| 	-- Allow the stack to be placed and remove it in on_put() | 	-- Allow the stack to be placed and remove it in on_put() | ||||||
| 	-- This allows the creative inventory to restore the stack | 	-- This allows the creative inventory to restore the stack | ||||||
| 	allow_put = function(inv, listname, index, stack, player) | 	allow_put = function(inv, listname, index, stack, player) | ||||||
| 		if minetest.setting_getbool("creative_mode") then | 		if creative_mode then | ||||||
| 			return stack:get_count() | 			return stack:get_count() | ||||||
| 		else | 		else | ||||||
| 			return 0 | 			return 0 | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	on_put = function(inv, listname, index, stack, player) | 	on_put = function(inv, listname) | ||||||
| 		inv:set_stack(listname, index, "") | 		inv:set_list(listname, {}) | ||||||
| 	end, | 	end, | ||||||
| }) | }) | ||||||
| trash:set_size("main", 1) | trash:set_size("main", 1) | ||||||
|  |  | ||||||
|  | creative.formspec_add = "" | ||||||
|  |  | ||||||
| creative_inventory.set_creative_formspec = function(player, start_i, pagenum) | creative.set_creative_formspec = function(player, start_i) | ||||||
| 	pagenum = math.floor(pagenum) | 	local player_name = player:get_player_name() | ||||||
| 	local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1) | 	local inv = player_inventory[player_name] | ||||||
| 	player:set_inventory_formspec( | 	local pagenum = math.floor(start_i / (3*8) + 1) | ||||||
| 			"size[13,7.5]".. | 	local pagemax = math.ceil(inv.size / (3*8)) | ||||||
| 			--"image[6,0.6;1,2;player.png]".. |  | ||||||
| 			default.gui_bg.. | 	player:set_inventory_formspec([[ | ||||||
| 			default.gui_bg_img.. | 		size[8,8.6] | ||||||
| 			default.gui_slots.. | 		image[4.06,3.4;0.8,0.8;creative_trash_icon.png] | ||||||
| 			"list[current_player;main;5,3.5;8,1;]".. | 		list[current_player;main;0,4.7;8,1;] | ||||||
| 			"list[current_player;main;5,4.75;8,3;8]".. | 		list[current_player;main;0,5.85;8,3;8] | ||||||
| 			"list[current_player;craft;8,0;3,3;]".. | 		list[detached:creative_trash;main;4,3.3;1,1;] | ||||||
| 			"list[current_player;craftpreview;12,1;1,1;]".. | 		listring[] | ||||||
| 			"list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]".. | 		tablecolumns[color;text;color;text] | ||||||
| 			"label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]".. | 		tableoptions[background=#00000000;highlight=#00000000;border=false] | ||||||
| 			"button[0.3,6.5;1.6,1;creative_prev;<<]".. | 		button[5.4,3.2;0.8,0.9;creative_prev;<] | ||||||
| 			"button[2.7,6.5;1.6,1;creative_next;>>]".. | 		button[7.25,3.2;0.8,0.9;creative_next;>] | ||||||
| 			"label[5,1.5;Trash:]".. | 		button[2.1,3.4;0.8,0.5;creative_search;?] | ||||||
| 			"list[detached:creative_trash;main;5,2;1,1;]".. | 		button[2.75,3.4;0.8,0.5;creative_clear;X] | ||||||
| 			default.get_hotbar_bg(5,3.5) | 		tooltip[creative_search;Search] | ||||||
|  | 		tooltip[creative_clear;Reset] | ||||||
|  | 		listring[current_player;main] | ||||||
|  | 		]] .. | ||||||
|  | 		"field[0.3,3.5;2.2,1;creative_filter;;" .. inv.filter .. "]" .. | ||||||
|  | 		"listring[detached:creative_" .. player_name .. ";main]" .. | ||||||
|  | 		"tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;" .. tostring(inv.tab_id) .. ";true;false]" .. | ||||||
|  | 		"list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" .. | ||||||
|  | 		"table[6.05,3.35;1.15,0.5;pagenum;#FFFF00," .. tostring(pagenum) .. ",#FFFFFF,/ " .. tostring(pagemax) .. "]" .. | ||||||
|  | 		default.get_hotbar_bg(0,4.7) .. | ||||||
|  | 		default.gui_bg .. default.gui_bg_img .. default.gui_slots | ||||||
|  | 		.. creative.formspec_add | ||||||
| 	) | 	) | ||||||
| end | end | ||||||
|  |  | ||||||
|  | creative.set_crafting_formspec = function(player) | ||||||
|  | 	player:set_inventory_formspec([[ | ||||||
|  | 		size[8,8.6] | ||||||
|  | 		list[current_player;craft;2,0.75;3,3;] | ||||||
|  | 		list[current_player;craftpreview;6,1.75;1,1;] | ||||||
|  | 		list[current_player;main;0,4.7;8,1;] | ||||||
|  | 		list[current_player;main;0,5.85;8,3;8] | ||||||
|  | 		list[detached:creative_trash;main;0,2.75;1,1;] | ||||||
|  | 		image[0.06,2.85;0.8,0.8;creative_trash_icon.png] | ||||||
|  | 		image[5,1.75;1,1;gui_furnace_arrow_bg.png^[transformR270] | ||||||
|  | 		tabheader[0,0;creative_tabs;Crafting,All,Nodes,Tools,Items;1;true;false] | ||||||
|  | 		listring[current_player;main] | ||||||
|  | 		listring[current_player;craft] | ||||||
|  | 		]] .. | ||||||
|  | 		default.get_hotbar_bg(0,4.7) .. | ||||||
|  | 		default.gui_bg .. default.gui_bg_img .. default.gui_slots | ||||||
|  | 	) | ||||||
|  | end | ||||||
|  |  | ||||||
| minetest.register_on_joinplayer(function(player) | minetest.register_on_joinplayer(function(player) | ||||||
| 	-- If in creative mode, modify player's inventory forms | 	-- If in creative mode, modify player's inventory forms | ||||||
| 	if not minetest.setting_getbool("creative_mode") then | 	if not creative_mode then | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	creative_inventory.set_creative_formspec(player, 0, 1) | 	creative.init_creative_inventory(player) | ||||||
|  | 	creative.set_creative_formspec(player, 0) | ||||||
| end) | end) | ||||||
|  |  | ||||||
| minetest.register_on_player_receive_fields(function(player, formname, fields) | minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||||
| 	if not minetest.setting_getbool("creative_mode") then | 	if formname ~= "" or not creative_mode then | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	-- Figure out current page from formspec |  | ||||||
| 	local current_page = 0 | 	local player_name = player:get_player_name() | ||||||
|  | 	local inv = player_inventory[player_name] | ||||||
|  |  | ||||||
|  | 	if fields.quit then | ||||||
|  | 		if inv.tab_id == 1 then | ||||||
|  | 			creative.set_crafting_formspec(player) | ||||||
|  | 		end | ||||||
|  | 	elseif fields.creative_tabs then | ||||||
|  | 		local tab = tonumber(fields.creative_tabs) | ||||||
|  | 		inv.tab_id = tab | ||||||
|  |  | ||||||
|  | 		if tab == 1 then | ||||||
|  | 			creative.set_crafting_formspec(player) | ||||||
|  | 		else | ||||||
|  | 			creative.update_creative_inventory(player_name) | ||||||
|  | 			creative.set_creative_formspec(player, 0) | ||||||
|  | 		end | ||||||
|  | 	elseif fields.creative_clear then | ||||||
|  | 		inv.filter = "" | ||||||
|  | 		creative.update_creative_inventory(player_name) | ||||||
|  | 		creative.set_creative_formspec(player, 0) | ||||||
|  | 	elseif fields.creative_search then | ||||||
|  | 		inv.filter = fields.creative_filter:lower() | ||||||
|  | 		creative.update_creative_inventory(player_name) | ||||||
|  | 		creative.set_creative_formspec(player, 0) | ||||||
|  | 	else | ||||||
| 		local formspec = player:get_inventory_formspec() | 		local formspec = player:get_inventory_formspec() | ||||||
| 	local start_i = string.match(formspec, "list%[detached:creative;main;[%d.]+,[%d.]+;[%d.]+,[%d.]+;(%d+)%]") | 		local start_i = player_inventory[player_name].start_i or 0 | ||||||
| 	start_i = tonumber(start_i) or 0 |  | ||||||
|  |  | ||||||
| 		if fields.creative_prev then | 		if fields.creative_prev then | ||||||
| 		start_i = start_i - 4*6 | 			start_i = start_i - 3*8 | ||||||
| 	end |  | ||||||
| 	if fields.creative_next then |  | ||||||
| 		start_i = start_i + 4*6 |  | ||||||
| 	end |  | ||||||
|  |  | ||||||
| 			if start_i < 0 then | 			if start_i < 0 then | ||||||
| 		start_i = start_i + 4*6 | 				start_i = inv.size - (inv.size % (3*8)) | ||||||
|  | 				if inv.size == start_i then | ||||||
|  | 					start_i = math.max(0, inv.size - (3*8)) | ||||||
| 				end | 				end | ||||||
| 	if start_i >= creative_inventory.creative_inventory_size then |  | ||||||
| 		start_i = start_i - 4*6 |  | ||||||
| 			end | 			end | ||||||
| 		 | 		elseif fields.creative_next then | ||||||
| 	if start_i < 0 or start_i >= creative_inventory.creative_inventory_size then | 			start_i = start_i + 3*8 | ||||||
|  | 			if start_i >= inv.size then | ||||||
| 				start_i = 0 | 				start_i = 0 | ||||||
| 			end | 			end | ||||||
|  | 		end | ||||||
|  |  | ||||||
| 	creative_inventory.set_creative_formspec(player, start_i, start_i / (6*4) + 1) | 		player_inventory[player_name].start_i = start_i | ||||||
|  | 		creative.set_creative_formspec(player, start_i) | ||||||
|  | 	end | ||||||
| end) | end) | ||||||
|  |  | ||||||
| if minetest.setting_getbool("creative_mode") then | if creative_mode then | ||||||
| 	local digtime = 0.5 | 	local digtime = 0.5 | ||||||
|  | 	local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 3} | ||||||
|  |  | ||||||
| 	minetest.register_item(":", { | 	minetest.register_item(":", { | ||||||
| 		type = "none", | 		type = "none", | ||||||
| 		wield_image = "wieldhand.png", | 		wield_image = "wieldhand.png", | ||||||
| 		wield_scale = {x=1,y=1,z=2.5}, | 		wield_scale = {x = 1, y = 1, z = 2.5}, | ||||||
| 		range = 10, | 		range = 10, | ||||||
| 		tool_capabilities = { | 		tool_capabilities = { | ||||||
| 			full_punch_interval = 0.5, | 			full_punch_interval = 0.5, | ||||||
| 			max_drop_level = 3, | 			max_drop_level = 3, | ||||||
| 			groupcaps = { | 			groupcaps = { | ||||||
| 				crumbly = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, | 				crumbly = caps, | ||||||
| 				cracky = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, | 				cracky  = caps, | ||||||
| 				snappy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, | 				snappy  = caps, | ||||||
| 				choppy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, | 				choppy  = caps, | ||||||
| 				oddly_breakable_by_hand = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3}, | 				oddly_breakable_by_hand = caps, | ||||||
| 			}, | 			}, | ||||||
| 			damage_groups = {fleshy = 10}, | 			damage_groups = {fleshy = 10}, | ||||||
| 		} | 		} | ||||||
| @@ -160,7 +250,7 @@ if minetest.setting_getbool("creative_mode") then | |||||||
| 		end | 		end | ||||||
| 		local inv = digger:get_inventory() | 		local inv = digger:get_inventory() | ||||||
| 		if inv then | 		if inv then | ||||||
| 			for _,item in ipairs(drops) do | 			for _, item in ipairs(drops) do | ||||||
| 				item = ItemStack(item):get_name() | 				item = ItemStack(item):get_name() | ||||||
| 				if not inv:contains_item("main", item) then | 				if not inv:contains_item("main", item) then | ||||||
| 					inv:add_item("main", item) | 					inv:add_item("main", item) | ||||||
| @@ -168,5 +258,4 @@ if minetest.setting_getbool("creative_mode") then | |||||||
| 			end | 			end | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| 	 |  | ||||||
| end | end | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								mods/creative/textures/creative_trash_icon.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 179 B | 
| @@ -1,4 +1,4 @@ | |||||||
| Minetest 0.4 mod: default | Minetest Game mod: default | ||||||
| ========================== | ========================== | ||||||
|  |  | ||||||
| License of source code: | License of source code: | ||||||
| @@ -24,11 +24,9 @@ Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com> | |||||||
|  |  | ||||||
| Cisoun's WTFPL texture pack: | Cisoun's WTFPL texture pack: | ||||||
|   default_jungletree.png |   default_jungletree.png | ||||||
|   default_jungletree_top.png |  | ||||||
|   default_lava.png |   default_lava.png | ||||||
|   default_leaves.png |   default_leaves.png | ||||||
|   default_sapling.png |   default_sapling.png | ||||||
|   default_sign_wall.png |  | ||||||
|   default_stone.png |   default_stone.png | ||||||
|   default_tree.png |   default_tree.png | ||||||
|   default_tree_top.png |   default_tree_top.png | ||||||
| @@ -57,17 +55,13 @@ VanessaE (WTFPL): | |||||||
|   default_nc_front.png |   default_nc_front.png | ||||||
|   default_nc_rb.png |   default_nc_rb.png | ||||||
|   default_nc_side.png |   default_nc_side.png | ||||||
|   default_grass_*.png |  | ||||||
|   default_desert_sand.png |   default_desert_sand.png | ||||||
|   default_desert_stone.png |   default_desert_stone.png | ||||||
|   default_desert_stone_brick.png |  | ||||||
|   default_sand.png |   default_sand.png | ||||||
|   default_sandstone_brick.png |  | ||||||
|  |  | ||||||
| Calinou (CC BY-SA): | Calinou (CC BY-SA): | ||||||
|   default_brick.png |   default_brick.png | ||||||
|   default_papyrus.png |   default_papyrus.png | ||||||
|   default_copper_lump.png |  | ||||||
|   default_mineral_copper.png |   default_mineral_copper.png | ||||||
|   default_glass_detail.png |   default_glass_detail.png | ||||||
|  |  | ||||||
| @@ -80,10 +74,8 @@ Jordach (CC BY-SA 3.0): | |||||||
| PilzAdam (WTFPL): | PilzAdam (WTFPL): | ||||||
|   default_jungleleaves.png |   default_jungleleaves.png | ||||||
|   default_junglesapling.png |   default_junglesapling.png | ||||||
|   default_junglewood.png |  | ||||||
|   default_obsidian_glass.png |   default_obsidian_glass.png | ||||||
|   default_obsidian_shard.png |   default_obsidian_shard.png | ||||||
|   default_gold_lump.png |  | ||||||
|   default_mineral_gold.png |   default_mineral_gold.png | ||||||
|   default_snowball.png |   default_snowball.png | ||||||
|  |  | ||||||
| @@ -95,8 +87,6 @@ InfinityProject (WTFPL): | |||||||
|  |  | ||||||
| Splizard (CC BY-SA 3.0): | Splizard (CC BY-SA 3.0): | ||||||
|   default_snow.png |   default_snow.png | ||||||
|   default_snow_side.png |  | ||||||
|   default_ice.png |  | ||||||
|   default_pine_sapling.png |   default_pine_sapling.png | ||||||
|  |  | ||||||
| Zeg9 (CC BY-SA 3.0): | Zeg9 (CC BY-SA 3.0): | ||||||
| @@ -107,38 +97,66 @@ Zeg9 (CC BY-SA 3.0): | |||||||
|   default_gold_block.png |   default_gold_block.png | ||||||
|  |  | ||||||
| paramat (CC BY-SA 3.0): | paramat (CC BY-SA 3.0): | ||||||
|   wieldhand.png, based on character.png by Jordach (CC BY-SA 3.0) |   wieldhand.png -- Copied from character.png by Jordach (CC BY-SA 3.0) | ||||||
|   default_pinetree.png |   default_pinetree.png | ||||||
|   default_pinetree_top.png |   default_pinetree_top.png | ||||||
|   default_pinewood.png |   default_pinewood.png | ||||||
|  |   default_acacia_leaves.png | ||||||
|  |   default_acacia_sapling.png | ||||||
|  |   default_acacia_tree.png | ||||||
|  |   default_acacia_tree_top.png | ||||||
|  |   default_acacia_wood.png | ||||||
|  |   default_junglewood.png | ||||||
|  |   default_jungletree_top.png | ||||||
|  |   default_sandstone_brick.png | ||||||
|  |   default_obsidian_brick.png | ||||||
|  |   default_stone_brick.png | ||||||
|  |   default_desert_stone_brick.png | ||||||
|  |   default_river_water.png | ||||||
|  |   default_river_water_source_animated.png | ||||||
|  |   default_river_water_flowing_animated.png | ||||||
|  |   default_dry_grass.png | ||||||
|  |   default_dry_grass_side.png | ||||||
|  |   default_dry_grass_*.png | ||||||
|  |   default_grass.png | ||||||
|  |   default_grass_side.png | ||||||
|  |   default_snow_side.png | ||||||
|  |  | ||||||
| brunob.santos (CC BY-SA 4.0): | brunob.santos (CC BY-SA 4.0): | ||||||
|   default_desert_cobble.png |   default_desert_cobble.png | ||||||
|  |  | ||||||
| BlockMen (CC BY-SA 3.0): | BlockMen (CC BY-SA 3.0): | ||||||
|   default_stone_brick.png |  | ||||||
|   default_wood.png |   default_wood.png | ||||||
|   default_clay_brick.png |   default_clay_brick.png | ||||||
|   default_tool_steelsword.png |   default_iron_ingot.png | ||||||
|   default_bronze_ingot.png |  | ||||||
|   default_copper_ingot.png |  | ||||||
|   default_gold_ingot.png |   default_gold_ingot.png | ||||||
|  |   default_tool_steelsword.png | ||||||
|   default_diamond.png |   default_diamond.png | ||||||
|   default_diamond_block.png |   default_book.png | ||||||
|   default_tool_*.png |   default_tool_*.png | ||||||
|   default_lava_source_animated.png |   default_lava_source_animated.png | ||||||
|   default_lava_flowing_animated.png |   default_lava_flowing_animated.png | ||||||
|   default_book.png |  | ||||||
|   default_paper.png |  | ||||||
|   default_stick.png |   default_stick.png | ||||||
|   default_chest_front.png |   default_chest_front.png | ||||||
|   default_chest_lock.png |   default_chest_lock.png | ||||||
|   default_chest_side.png |   default_chest_side.png | ||||||
|   default_chest_top.png |   default_chest_top.png | ||||||
|  |   default_mineral_mese.png | ||||||
|  |   default_meselamp.png | ||||||
|   bubble.png |   bubble.png | ||||||
|   heart.png |  | ||||||
|   gui_*.png |   gui_*.png | ||||||
|  |  | ||||||
|  | sofar (CC BY-SA 3.0): | ||||||
|  |   default_book_written.png, based on default_book.png | ||||||
|  |   default_aspen_sapling | ||||||
|  |   default_aspen_leaves | ||||||
|  |   default_aspen_tree | ||||||
|  |   default_aspen_tree_top, derived from default_pine_tree_top (by paramat) | ||||||
|  |   default_aspen_wood, derived from default_pine_wood (by paramat) | ||||||
|  |  | ||||||
|  | sofar (WTFPL): | ||||||
|  |   default_gravel.png -- Derived from Gambit's PixelBOX texture pack light gravel | ||||||
|  |  | ||||||
| Neuromancer (CC BY-SA 2.0): | Neuromancer (CC BY-SA 2.0): | ||||||
|   default_cobble.png, based on texture by Brane praefect |   default_cobble.png, based on texture by Brane praefect | ||||||
|   default_mossycobble.png, based on texture by Brane praefect |   default_mossycobble.png, based on texture by Brane praefect | ||||||
| @@ -146,9 +164,26 @@ Neuromancer (CC BY-SA 3.0): | |||||||
|   default_dirt.png |   default_dirt.png | ||||||
|   default_furnace_*.png |   default_furnace_*.png | ||||||
|  |  | ||||||
| Philipbenr (CC BY-SA 3.0): | Gambit (WTFPL): | ||||||
|   default_grass.png |   default_bronze_ingot.png | ||||||
|   default_grass_side.png |   default_copper_ingot.png | ||||||
|  |   default_copper_lump.png | ||||||
|  |   default_iron_lump.png | ||||||
|  |   default_gold_lump.png | ||||||
|  |   default_clay_lump.png | ||||||
|  |   default_coal.png | ||||||
|  |   default_grass_*.png | ||||||
|  |   default_paper.png | ||||||
|  |   default_diamond_block.png | ||||||
|  |   default_ladder_steel.png | ||||||
|  |   default_sign_wall_wood.png | ||||||
|  |   default_flint.png | ||||||
|  |  | ||||||
|  | asl97 (WTFPL): | ||||||
|  |   default_ice.png | ||||||
|  |  | ||||||
|  | KevDoy (CC BY-SA 3.0) | ||||||
|  |   heart.png | ||||||
|  |  | ||||||
| Glass breaking sounds (CC BY 3.0): | Glass breaking sounds (CC BY 3.0): | ||||||
|   1: http://www.freesound.org/people/cmusounddesign/sounds/71947/ |   1: http://www.freesound.org/people/cmusounddesign/sounds/71947/ | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| -- aliases (Minetest 0.4 mod) | -- mods/default/aliases.lua | ||||||
| -- Provides alias for most default items |  | ||||||
|  |  | ||||||
|  | -- Aliases to support loading worlds using nodes following the old naming convention | ||||||
|  | -- These can also be helpful when using chat commands, for example /giveme | ||||||
| minetest.register_alias("stone", "default:stone") | minetest.register_alias("stone", "default:stone") | ||||||
| minetest.register_alias("stone_with_coal", "default:stone_with_coal") | minetest.register_alias("stone_with_coal", "default:stone_with_coal") | ||||||
| minetest.register_alias("stone_with_iron", "default:stone_with_iron") | minetest.register_alias("stone_with_iron", "default:stone_with_iron") | ||||||
| @@ -22,7 +23,7 @@ minetest.register_alias("bookshelf", "default:bookshelf") | |||||||
| minetest.register_alias("glass", "default:glass") | minetest.register_alias("glass", "default:glass") | ||||||
| minetest.register_alias("wooden_fence", "default:fence_wood") | minetest.register_alias("wooden_fence", "default:fence_wood") | ||||||
| minetest.register_alias("rail", "default:rail") | minetest.register_alias("rail", "default:rail") | ||||||
| minetest.register_alias("ladder", "default:ladder") | minetest.register_alias("ladder", "default:ladder_wood") | ||||||
| minetest.register_alias("wood", "default:wood") | minetest.register_alias("wood", "default:wood") | ||||||
| minetest.register_alias("mese", "default:mese") | minetest.register_alias("mese", "default:mese") | ||||||
| minetest.register_alias("cloud", "default:cloud") | minetest.register_alias("cloud", "default:cloud") | ||||||
| @@ -31,7 +32,7 @@ minetest.register_alias("water_source", "default:water_source") | |||||||
| minetest.register_alias("lava_flowing", "default:lava_flowing") | minetest.register_alias("lava_flowing", "default:lava_flowing") | ||||||
| minetest.register_alias("lava_source", "default:lava_source") | minetest.register_alias("lava_source", "default:lava_source") | ||||||
| minetest.register_alias("torch", "default:torch") | minetest.register_alias("torch", "default:torch") | ||||||
| minetest.register_alias("sign_wall", "default:sign_wall") | minetest.register_alias("sign_wall", "default:sign_wall_wood") | ||||||
| minetest.register_alias("furnace", "default:furnace") | minetest.register_alias("furnace", "default:furnace") | ||||||
| minetest.register_alias("chest", "default:chest") | minetest.register_alias("chest", "default:chest") | ||||||
| minetest.register_alias("locked_chest", "default:chest_locked") | minetest.register_alias("locked_chest", "default:chest_locked") | ||||||
| @@ -65,3 +66,15 @@ minetest.register_alias("lump_of_iron", "default:iron_lump") | |||||||
| minetest.register_alias("lump_of_clay", "default:clay_lump") | minetest.register_alias("lump_of_clay", "default:clay_lump") | ||||||
| minetest.register_alias("steel_ingot", "default:steel_ingot") | minetest.register_alias("steel_ingot", "default:steel_ingot") | ||||||
| minetest.register_alias("clay_brick", "default:clay_brick") | minetest.register_alias("clay_brick", "default:clay_brick") | ||||||
|  | minetest.register_alias("snow", "default:snow") | ||||||
|  |  | ||||||
|  | -- 'mese_block' was used for a while for the block form of mese | ||||||
|  | minetest.register_alias("default:mese_block", "default:mese") | ||||||
|  |  | ||||||
|  | -- Aliases for corrected pine node names | ||||||
|  | minetest.register_alias("default:pinetree", "default:pine_tree") | ||||||
|  | minetest.register_alias("default:pinewood", "default:pine_wood") | ||||||
|  |  | ||||||
|  | minetest.register_alias("default:ladder", "default:ladder_wood") | ||||||
|  | minetest.register_alias("default:sign_wall", "default:sign_wall_wood") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,9 +15,23 @@ minetest.register_craft({ | |||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:pinewood 4', | 	output = 'default:pine_wood 4', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| 		{'default:pinetree'}, | 		{'default:pine_tree'}, | ||||||
|  | 	} | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	output = 'default:acacia_wood 4', | ||||||
|  | 	recipe = { | ||||||
|  | 		{'default:acacia_tree'}, | ||||||
|  | 	} | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	output = 'default:aspen_wood 4', | ||||||
|  | 	recipe = { | ||||||
|  | 		{'default:aspen_tree'}, | ||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  |  | ||||||
| @@ -29,15 +43,16 @@ minetest.register_craft({ | |||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:fence_wood 2', | 	output = 'default:sign_wall_steel 3', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| 		{'group:stick', 'group:stick', 'group:stick'}, | 		{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, | ||||||
| 		{'group:stick', 'group:stick', 'group:stick'}, | 		{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, | ||||||
|  | 		{'', 'group:stick', ''}, | ||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:sign_wall', | 	output = 'default:sign_wall_wood 3', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| 		{'group:wood', 'group:wood', 'group:wood'}, | 		{'group:wood', 'group:wood', 'group:wood'}, | ||||||
| 		{'group:wood', 'group:wood', 'group:wood'}, | 		{'group:wood', 'group:wood', 'group:wood'}, | ||||||
| @@ -324,7 +339,7 @@ minetest.register_craft({ | |||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:rail 15', | 	output = 'default:rail 24', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| 		{'default:steel_ingot', '', 'default:steel_ingot'}, | 		{'default:steel_ingot', '', 'default:steel_ingot'}, | ||||||
| 		{'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, | 		{'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, | ||||||
| @@ -492,6 +507,13 @@ minetest.register_craft({ | |||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	output = 'default:clay_lump 4', | ||||||
|  | 	recipe = { | ||||||
|  | 		{'default:clay'}, | ||||||
|  | 	} | ||||||
|  | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:brick', | 	output = 'default:brick', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| @@ -533,7 +555,7 @@ minetest.register_craft({ | |||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:ladder', | 	output = 'default:ladder_wood 3', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| 		{'group:stick', '', 'group:stick'}, | 		{'group:stick', '', 'group:stick'}, | ||||||
| 		{'group:stick', 'group:stick', 'group:stick'}, | 		{'group:stick', 'group:stick', 'group:stick'}, | ||||||
| @@ -541,6 +563,15 @@ minetest.register_craft({ | |||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	output = 'default:ladder_steel 15', | ||||||
|  | 	recipe = { | ||||||
|  | 		{'default:steel_ingot', '', 'default:steel_ingot'}, | ||||||
|  | 		{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, | ||||||
|  | 		{'default:steel_ingot', '', 'default:steel_ingot'}, | ||||||
|  | 	} | ||||||
|  | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:mese', | 	output = 'default:mese', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| @@ -564,6 +595,14 @@ minetest.register_craft({ | |||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	output = 'default:meselamp 1', | ||||||
|  | 	recipe = { | ||||||
|  | 		{'', 'default:mese_crystal',''}, | ||||||
|  | 		{'default:mese_crystal', 'default:glass', 'default:mese_crystal'}, | ||||||
|  | 	} | ||||||
|  | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = 'default:obsidian_shard 9', | 	output = 'default:obsidian_shard 9', | ||||||
| 	recipe = { | 	recipe = { | ||||||
| @@ -650,6 +689,12 @@ minetest.register_craft({ | |||||||
| 	recipe = "default:cobble", | 	recipe = "default:cobble", | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "cooking", | ||||||
|  | 	output = "default:stone", | ||||||
|  | 	recipe = "default:mossycobble", | ||||||
|  | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "cooking", | 	type = "cooking", | ||||||
| 	output = "default:desert_stone", | 	output = "default:desert_stone", | ||||||
| @@ -728,7 +773,31 @@ minetest.register_craft({ | |||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "fuel", | 	type = "fuel", | ||||||
| 	recipe = "default:ladder", | 	recipe = "default:fence_acacia_wood", | ||||||
|  | 	burntime = 15, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "default:fence_junglewood", | ||||||
|  | 	burntime = 15, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "default:fence_pine_wood", | ||||||
|  | 	burntime = 15, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "default:fence_aspen_wood", | ||||||
|  | 	burntime = 15, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "default:ladder_wood", | ||||||
| 	burntime = 5, | 	burntime = 5, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| @@ -752,7 +821,7 @@ minetest.register_craft({ | |||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "fuel", | 	type = "fuel", | ||||||
| 	recipe = "default:sign_wall", | 	recipe = "default:sign_wall_wood", | ||||||
| 	burntime = 10, | 	burntime = 10, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| @@ -782,7 +851,7 @@ minetest.register_craft({ | |||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "fuel", | 	type = "fuel", | ||||||
| 	recipe = "default:sapling", | 	recipe = "group:sapling", | ||||||
| 	burntime = 10, | 	burntime = 10, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| @@ -804,12 +873,6 @@ minetest.register_craft({ | |||||||
| 	burntime = 370, | 	burntime = 370, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ |  | ||||||
| 	type = "fuel", |  | ||||||
| 	recipe = "default:junglesapling", |  | ||||||
| 	burntime = 10, |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "fuel", | 	type = "fuel", | ||||||
| 	recipe = "default:grass_1", | 	recipe = "default:grass_1", | ||||||
| @@ -818,7 +881,7 @@ minetest.register_craft({ | |||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	type = "fuel", | 	type = "fuel", | ||||||
| 	recipe = "default:pine_sapling", | 	recipe = "default:dry_grass_1", | ||||||
| 	burntime = 10, | 	burntime = 2, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| minetest.register_craftitem("default:stick", { | minetest.register_craftitem("default:stick", { | ||||||
| 	description = "Stick", | 	description = "Stick", | ||||||
| 	inventory_image = "default_stick.png", | 	inventory_image = "default_stick.png", | ||||||
| 	groups = {stick=1}, | 	groups = {stick = 1}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craftitem("default:paper", { | minetest.register_craftitem("default:paper", { | ||||||
| @@ -11,12 +11,166 @@ minetest.register_craftitem("default:paper", { | |||||||
| 	inventory_image = "default_paper.png", | 	inventory_image = "default_paper.png", | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | local lpp = 14 -- Lines per book's page | ||||||
|  | local function book_on_use(itemstack, user) | ||||||
|  | 	local player_name = user:get_player_name() | ||||||
|  | 	local data = minetest.deserialize(itemstack:get_metadata()) | ||||||
|  | 	local formspec, title, text, owner = "", "", "", player_name | ||||||
|  | 	local page, page_max, lines, string = 1, 1, {}, "" | ||||||
|  |  | ||||||
|  | 	if data then | ||||||
|  | 		title = data.title | ||||||
|  | 		text = data.text | ||||||
|  | 		owner = data.owner | ||||||
|  |  | ||||||
|  | 		for str in (text .. "\n"):gmatch("([^\n]*)[\n]") do | ||||||
|  | 			lines[#lines+1] = str | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		if data.page then | ||||||
|  | 			page = data.page | ||||||
|  | 			page_max = data.page_max | ||||||
|  |  | ||||||
|  | 			for i = ((lpp * page) - lpp) + 1, lpp * page do | ||||||
|  | 				if not lines[i] then break end | ||||||
|  | 				string = string .. lines[i] .. "\n" | ||||||
|  | 			end | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	if owner == player_name then | ||||||
|  | 		formspec = "size[8,8]" .. default.gui_bg .. | ||||||
|  | 			default.gui_bg_img .. | ||||||
|  | 			"field[0.5,1;7.5,0;title;Title:;" .. | ||||||
|  | 				minetest.formspec_escape(title) .. "]" .. | ||||||
|  | 			"textarea[0.5,1.5;7.5,7;text;Contents:;" .. | ||||||
|  | 				minetest.formspec_escape(text) .. "]" .. | ||||||
|  | 			"button_exit[2.5,7.5;3,1;save;Save]" | ||||||
|  | 	else | ||||||
|  | 		formspec = "size[8,8]" .. default.gui_bg .. | ||||||
|  | 			default.gui_bg_img .. | ||||||
|  | 			"label[0.5,0.5;by " .. owner .. "]" .. | ||||||
|  | 			"tablecolumns[color;text]" .. | ||||||
|  | 			"tableoptions[background=#00000000;highlight=#00000000;border=false]" .. | ||||||
|  | 			"table[0.4,0;7,0.5;title;#FFFF00," .. minetest.formspec_escape(title) .. "]" .. | ||||||
|  | 			"textarea[0.5,1.5;7.5,7;;" .. | ||||||
|  | 				minetest.formspec_escape(string ~= "" and string or text) .. ";]" .. | ||||||
|  | 			"button[2.4,7.6;0.8,0.8;book_prev;<]" .. | ||||||
|  | 			"label[3.2,7.7;Page " .. page .. " of " .. page_max .. "]" .. | ||||||
|  | 			"button[4.9,7.6;0.8,0.8;book_next;>]" | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	minetest.show_formspec(player_name, "default:book", formspec) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||||
|  | 	if formname ~= "default:book" then return end | ||||||
|  | 	local inv = player:get_inventory() | ||||||
|  | 	local stack = player:get_wielded_item() | ||||||
|  |  | ||||||
|  | 	if fields.save and fields.title ~= "" and fields.text ~= "" then | ||||||
|  | 		local new_stack, data | ||||||
|  | 		if stack:get_name() ~= "default:book_written" then | ||||||
|  | 			local count = stack:get_count() | ||||||
|  | 			if count == 1 then | ||||||
|  | 				stack:set_name("default:book_written") | ||||||
|  | 			else | ||||||
|  | 				stack:set_count(count - 1) | ||||||
|  | 				new_stack = ItemStack("default:book_written") | ||||||
|  | 			end | ||||||
|  | 		else | ||||||
|  | 			data = minetest.deserialize(stack:get_metadata()) | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		if not data then data = {} end | ||||||
|  | 		data.title = fields.title | ||||||
|  | 		data.text = fields.text | ||||||
|  | 		data.text_len = #data.text | ||||||
|  | 		data.page = 1 | ||||||
|  | 		data.page_max = math.ceil((#data.text:gsub("[^\n]", "") + 1) / lpp) | ||||||
|  | 		data.owner = player:get_player_name() | ||||||
|  | 		local data_str = minetest.serialize(data) | ||||||
|  |  | ||||||
|  | 		if new_stack then | ||||||
|  | 			new_stack:set_metadata(data_str) | ||||||
|  | 			if inv:room_for_item("main", new_stack) then | ||||||
|  | 				inv:add_item("main", new_stack) | ||||||
|  | 			else | ||||||
|  | 				minetest.add_item(player:getpos(), new_stack) | ||||||
|  | 			end | ||||||
|  | 		else | ||||||
|  | 			stack:set_metadata(data_str) | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 	elseif fields.book_next or fields.book_prev then | ||||||
|  | 		local data = minetest.deserialize(stack:get_metadata()) | ||||||
|  | 		if not data.page then return end | ||||||
|  |  | ||||||
|  | 		if fields.book_next then | ||||||
|  | 			data.page = data.page + 1 | ||||||
|  | 			if data.page > data.page_max then | ||||||
|  | 				data.page = 1 | ||||||
|  | 			end | ||||||
|  | 		else | ||||||
|  | 			data.page = data.page - 1 | ||||||
|  | 			if data.page == 0 then | ||||||
|  | 				data.page = data.page_max | ||||||
|  | 			end | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		local data_str = minetest.serialize(data) | ||||||
|  | 		stack:set_metadata(data_str) | ||||||
|  | 		book_on_use(stack, player) | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	player:set_wielded_item(stack) | ||||||
|  | end) | ||||||
|  |  | ||||||
| minetest.register_craftitem("default:book", { | minetest.register_craftitem("default:book", { | ||||||
| 	description = "Book", | 	description = "Book", | ||||||
| 	inventory_image = "default_book.png", | 	inventory_image = "default_book.png", | ||||||
| 	groups = {book=1}, | 	groups = {book = 1}, | ||||||
|  | 	on_use = book_on_use, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craftitem("default:book_written", { | ||||||
|  | 	description = "Book With Text", | ||||||
|  | 	inventory_image = "default_book_written.png", | ||||||
|  | 	groups = {book = 1, not_in_creative_inventory = 1}, | ||||||
|  | 	stack_max = 1, | ||||||
|  | 	on_use = book_on_use, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "shapeless", | ||||||
|  | 	output = "default:book_written", | ||||||
|  | 	recipe = {"default:book", "default:book_written"} | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) | ||||||
|  | 	if itemstack:get_name() ~= "default:book_written" then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	local copy = ItemStack("default:book_written") | ||||||
|  | 	local original | ||||||
|  | 	local index | ||||||
|  | 	for i = 1, player:get_inventory():get_size("craft") do | ||||||
|  | 		if old_craft_grid[i]:get_name() == "default:book_written" then | ||||||
|  | 			original = old_craft_grid[i] | ||||||
|  | 			index = i | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  | 	if not original then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	local copymeta = original:get_metadata() | ||||||
|  | 	-- copy of the book held by player's mouse cursor | ||||||
|  | 	itemstack:set_metadata(copymeta) | ||||||
|  | 	-- put the book with metadata back in the craft grid | ||||||
|  | 	craft_inv:set_stack("craft", index, original) | ||||||
|  | end) | ||||||
|  |  | ||||||
| minetest.register_craftitem("default:coal_lump", { | minetest.register_craftitem("default:coal_lump", { | ||||||
| 	description = "Coal Lump", | 	description = "Coal Lump", | ||||||
| 	inventory_image = "default_coal_lump.png", | 	inventory_image = "default_coal_lump.png", | ||||||
| @@ -87,3 +241,9 @@ minetest.register_craftitem("default:obsidian_shard", { | |||||||
| 	description = "Obsidian Shard", | 	description = "Obsidian Shard", | ||||||
| 	inventory_image = "default_obsidian_shard.png", | 	inventory_image = "default_obsidian_shard.png", | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craftitem("default:flint", { | ||||||
|  | 	description = "Flint", | ||||||
|  | 	inventory_image = "default_flint.png" | ||||||
|  | }) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,20 +7,20 @@ | |||||||
| function default.node_sound_defaults(table) | function default.node_sound_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="", gain=1.0} | 			{name = "", gain = 1.0} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_dug_node", gain=0.25} | 			{name = "default_dug_node", gain = 0.25} | ||||||
| 	table.place = table.place or | 	table.place = table.place or | ||||||
| 			{name="default_place_node_hard", gain=1.0} | 			{name = "default_place_node_hard", gain = 1.0} | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
|  |  | ||||||
| function default.node_sound_stone_defaults(table) | function default.node_sound_stone_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_hard_footstep", gain=0.5} | 			{name = "default_hard_footstep", gain = 0.5} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_hard_footstep", gain=1.0} | 			{name = "default_hard_footstep", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
| @@ -28,11 +28,11 @@ end | |||||||
| function default.node_sound_dirt_defaults(table) | function default.node_sound_dirt_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_dirt_footstep", gain=1.0} | 			{name = "default_dirt_footstep", gain = 1.0} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_dirt_footstep", gain=1.5} | 			{name = "default_dirt_footstep", gain = 1.5} | ||||||
| 	table.place = table.place or | 	table.place = table.place or | ||||||
| 			{name="default_place_node", gain=1.0} | 			{name = "default_place_node", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
| @@ -40,11 +40,23 @@ end | |||||||
| function default.node_sound_sand_defaults(table) | function default.node_sound_sand_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_sand_footstep", gain=0.2} | 			{name = "default_sand_footstep", gain = 0.12} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_sand_footstep", gain=0.4} | 			{name = "default_sand_footstep", gain = 0.24} | ||||||
| 	table.place = table.place or | 	table.place = table.place or | ||||||
| 			{name="default_place_node", gain=1.0} | 			{name = "default_place_node", gain = 1.0} | ||||||
|  | 	default.node_sound_defaults(table) | ||||||
|  | 	return table | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function default.node_sound_gravel_defaults(table) | ||||||
|  | 	table = table or {} | ||||||
|  | 	table.footstep = table.footstep or | ||||||
|  | 			{name = "default_gravel_footstep", gain = 0.5} | ||||||
|  | 	table.dug = table.dug or | ||||||
|  | 			{name = "default_gravel_footstep", gain = 1.0} | ||||||
|  | 	table.place = table.place or | ||||||
|  | 			{name = "default_place_node", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
| @@ -52,9 +64,9 @@ end | |||||||
| function default.node_sound_wood_defaults(table) | function default.node_sound_wood_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_wood_footstep", gain=0.5} | 			{name = "default_wood_footstep", gain = 0.5} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_wood_footstep", gain=1.0} | 			{name = "default_wood_footstep", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
| @@ -62,13 +74,13 @@ end | |||||||
| function default.node_sound_leaves_defaults(table) | function default.node_sound_leaves_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_grass_footstep", gain=0.35} | 			{name = "default_grass_footstep", gain = 0.35} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_grass_footstep", gain=0.7} | 			{name = "default_grass_footstep", gain = 0.7} | ||||||
| 	table.dig = table.dig or | 	table.dig = table.dig or | ||||||
| 			{name="default_dig_crumbly", gain=0.4} | 			{name = "default_dig_crumbly", gain = 0.4} | ||||||
| 	table.place = table.place or | 	table.place = table.place or | ||||||
| 			{name="default_place_node", gain=1.0} | 			{name = "default_place_node", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
| @@ -76,146 +88,127 @@ end | |||||||
| function default.node_sound_glass_defaults(table) | function default.node_sound_glass_defaults(table) | ||||||
| 	table = table or {} | 	table = table or {} | ||||||
| 	table.footstep = table.footstep or | 	table.footstep = table.footstep or | ||||||
| 			{name="default_glass_footstep", gain=0.5} | 			{name = "default_glass_footstep", gain = 0.5} | ||||||
| 	table.dug = table.dug or | 	table.dug = table.dug or | ||||||
| 			{name="default_break_glass", gain=1.0} | 			{name = "default_break_glass", gain = 1.0} | ||||||
| 	default.node_sound_defaults(table) | 	default.node_sound_defaults(table) | ||||||
| 	return table | 	return table | ||||||
| end | end | ||||||
|  |  | ||||||
| -- |  | ||||||
| -- Legacy |  | ||||||
| -- |  | ||||||
|  |  | ||||||
| function default.spawn_falling_node(p, nodename) |  | ||||||
| 	spawn_falling_node(p, nodename) |  | ||||||
| end |  | ||||||
|  |  | ||||||
| -- Horrible crap to support old code |  | ||||||
| -- Don't use this and never do what this does, it's completely wrong! |  | ||||||
| -- (More specifically, the client and the C++ code doesn't get the group) |  | ||||||
| function default.register_falling_node(nodename, texture) |  | ||||||
| 	minetest.log("error", debug.traceback()) |  | ||||||
| 	minetest.log('error', "WARNING: default.register_falling_node is deprecated") |  | ||||||
| 	if minetest.registered_nodes[nodename] then |  | ||||||
| 		minetest.registered_nodes[nodename].groups.falling_node = 1 |  | ||||||
| 	end |  | ||||||
| end |  | ||||||
|  |  | ||||||
| -- |  | ||||||
| -- Global callbacks |  | ||||||
| -- |  | ||||||
|  |  | ||||||
| -- Global environment step function |  | ||||||
| function on_step(dtime) |  | ||||||
| 	-- print("on_step") |  | ||||||
| end |  | ||||||
| minetest.register_globalstep(on_step) |  | ||||||
|  |  | ||||||
| function on_placenode(p, node) |  | ||||||
| 	--print("on_placenode") |  | ||||||
| end |  | ||||||
| minetest.register_on_placenode(on_placenode) |  | ||||||
|  |  | ||||||
| function on_dignode(p, node) |  | ||||||
| 	--print("on_dignode") |  | ||||||
| end |  | ||||||
| minetest.register_on_dignode(on_dignode) |  | ||||||
|  |  | ||||||
| function on_punchnode(p, node) |  | ||||||
| end |  | ||||||
| minetest.register_on_punchnode(on_punchnode) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| -- | -- | ||||||
| -- Lavacooling | -- Lavacooling | ||||||
| -- | -- | ||||||
|  |  | ||||||
| default.cool_lava_source = function(pos) | default.cool_lava = function(pos, node) | ||||||
| 	minetest.set_node(pos, {name="default:obsidian"}) | 	if node.name == "default:lava_source" then | ||||||
| 	minetest.sound_play("default_cool_lava", {pos = pos,  gain = 0.25}) | 		minetest.set_node(pos, {name = "default:obsidian"}) | ||||||
| end | 	else -- Lava flowing | ||||||
|  | 		minetest.set_node(pos, {name = "default:stone"}) | ||||||
| default.cool_lava_flowing = function(pos) | 	end | ||||||
| 	minetest.set_node(pos, {name="default:stone"}) | 	minetest.sound_play("default_cool_lava", | ||||||
| 	minetest.sound_play("default_cool_lava", {pos = pos,  gain = 0.25}) | 		{pos = pos, max_hear_distance = 16, gain = 0.25}) | ||||||
| end | end | ||||||
|  |  | ||||||
| minetest.register_abm({ | minetest.register_abm({ | ||||||
| 	nodenames = {"default:lava_flowing"}, | 	nodenames = {"default:lava_source", "default:lava_flowing"}, | ||||||
| 	neighbors = {"group:water"}, | 	neighbors = {"group:water"}, | ||||||
| 	interval = 1, | 	interval = 1, | ||||||
| 	chance = 1, | 	chance = 1, | ||||||
| 	action = function(pos, node, active_object_count, active_object_count_wider) | 	catch_up = false, | ||||||
| 		default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider) | 	action = function(...) | ||||||
|  | 		default.cool_lava(...) | ||||||
| 	end, | 	end, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_abm({ |  | ||||||
| 	nodenames = {"default:lava_source"}, | -- | ||||||
| 	neighbors = {"group:water"}, | -- optimized helper to put all items in an inventory into a drops list | ||||||
| 	interval = 1, | -- | ||||||
| 	chance = 1, | function default.get_inventory_drops(pos, inventory, drops) | ||||||
| 	action = function(pos, node, active_object_count, active_object_count_wider) | 	local inv = minetest.get_meta(pos):get_inventory() | ||||||
| 		default.cool_lava_source(pos, node, active_object_count, active_object_count_wider) | 	local n = #drops | ||||||
| 	end, | 	for i = 1, inv:get_size(inventory) do | ||||||
| }) | 		local stack = inv:get_stack(inventory, i) | ||||||
|  | 		if stack:get_count() > 0 then | ||||||
|  | 			drops[n+1] = stack:to_table() | ||||||
|  | 			n = n + 1 | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
| -- | -- | ||||||
| -- Papyrus and cactus growing | -- Papyrus and cactus growing | ||||||
| -- | -- | ||||||
|  |  | ||||||
|  | -- wrapping the functions in abm action is necessary to make overriding them possible | ||||||
|  |  | ||||||
|  | function default.grow_cactus(pos, node) | ||||||
|  | 	if node.param2 >= 4 then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	pos.y = pos.y - 1 | ||||||
|  | 	if minetest.get_item_group(minetest.get_node(pos).name, "sand") == 0 then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	pos.y = pos.y + 1 | ||||||
|  | 	local height = 0 | ||||||
|  | 	while node.name == "default:cactus" and height < 4 do | ||||||
|  | 		height = height + 1 | ||||||
|  | 		pos.y = pos.y + 1 | ||||||
|  | 		node = minetest.get_node(pos) | ||||||
|  | 	end | ||||||
|  | 	if height == 4 or node.name ~= "air" then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	minetest.set_node(pos, {name = "default:cactus"}) | ||||||
|  | 	return true | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function default.grow_papyrus(pos, node) | ||||||
|  | 	pos.y = pos.y - 1 | ||||||
|  | 	local name = minetest.get_node(pos).name | ||||||
|  | 	if name ~= "default:dirt_with_grass" and name ~= "default:dirt" then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	if not minetest.find_node_near(pos, 3, {"group:water"}) then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	pos.y = pos.y + 1 | ||||||
|  | 	local height = 0 | ||||||
|  | 	while node.name == "default:papyrus" and height < 4 do | ||||||
|  | 		height = height + 1 | ||||||
|  | 		pos.y = pos.y + 1 | ||||||
|  | 		node = minetest.get_node(pos) | ||||||
|  | 	end | ||||||
|  | 	if height == 4 or node.name ~= "air" then | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
|  | 	minetest.set_node(pos, {name = "default:papyrus"}) | ||||||
|  | 	return true | ||||||
|  | end | ||||||
|  |  | ||||||
| minetest.register_abm({ | minetest.register_abm({ | ||||||
| 	nodenames = {"default:cactus"}, | 	nodenames = {"default:cactus"}, | ||||||
| 	neighbors = {"group:sand"}, | 	neighbors = {"group:sand"}, | ||||||
| 	interval = 50, | 	interval = 12, | ||||||
| 	chance = 20, | 	chance = 83, | ||||||
| 	action = function(pos, node) | 	action = function(...) | ||||||
| 		pos.y = pos.y-1 | 		default.grow_cactus(...) | ||||||
| 		local name = minetest.get_node(pos).name |  | ||||||
| 		if minetest.get_item_group(name, "sand") ~= 0 then |  | ||||||
| 			pos.y = pos.y+1 |  | ||||||
| 			local height = 0 |  | ||||||
| 			while minetest.get_node(pos).name == "default:cactus" and height < 4 do |  | ||||||
| 				height = height+1 |  | ||||||
| 				pos.y = pos.y+1 |  | ||||||
| 	end | 	end | ||||||
| 			if height < 4 then |  | ||||||
| 				if minetest.get_node(pos).name == "air" then |  | ||||||
| 					minetest.set_node(pos, {name="default:cactus"}) |  | ||||||
| 				end |  | ||||||
| 			end |  | ||||||
| 		end |  | ||||||
| 	end, |  | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_abm({ | minetest.register_abm({ | ||||||
| 	nodenames = {"default:papyrus"}, | 	nodenames = {"default:papyrus"}, | ||||||
| 	neighbors = {"default:dirt", "default:dirt_with_grass"}, | 	neighbors = {"default:dirt", "default:dirt_with_grass"}, | ||||||
| 	interval = 50, | 	interval = 14, | ||||||
| 	chance = 20, | 	chance = 71, | ||||||
| 	action = function(pos, node) | 	action = function(...) | ||||||
| 		pos.y = pos.y-1 | 		default.grow_papyrus(...) | ||||||
| 		local name = minetest.get_node(pos).name |  | ||||||
| 		if name == "default:dirt" or name == "default:dirt_with_grass" then |  | ||||||
| 			if minetest.find_node_near(pos, 3, {"group:water"}) == nil then |  | ||||||
| 				return |  | ||||||
| 	end | 	end | ||||||
| 			pos.y = pos.y+1 |  | ||||||
| 			local height = 0 |  | ||||||
| 			while minetest.get_node(pos).name == "default:papyrus" and height < 4 do |  | ||||||
| 				height = height+1 |  | ||||||
| 				pos.y = pos.y+1 |  | ||||||
| 			end |  | ||||||
| 			if height < 4 then |  | ||||||
| 				if minetest.get_node(pos).name == "air" then |  | ||||||
| 					minetest.set_node(pos, {name="default:papyrus"}) |  | ||||||
| 				end |  | ||||||
| 			end |  | ||||||
| 		end |  | ||||||
| 	end, |  | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  |  | ||||||
| -- | -- | ||||||
| -- dig upwards | -- dig upwards | ||||||
| -- | -- | ||||||
| @@ -229,6 +222,63 @@ function default.dig_up(pos, node, digger) | |||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
|  |  | ||||||
|  | -- | ||||||
|  | -- Fence registration helper | ||||||
|  | -- | ||||||
|  | function default.register_fence(name, def) | ||||||
|  | 	minetest.register_craft({ | ||||||
|  | 		output = name .. " 4", | ||||||
|  | 		recipe = { | ||||||
|  | 			{ def.material, 'group:stick', def.material }, | ||||||
|  | 			{ def.material, 'group:stick', def.material }, | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  |  | ||||||
|  | 	local fence_texture = "default_fence_overlay.png^" .. def.texture .. | ||||||
|  | 			"^default_fence_overlay.png^[makealpha:255,126,126" | ||||||
|  | 	-- Allow almost everything to be overridden | ||||||
|  | 	local default_fields = { | ||||||
|  | 		paramtype = "light", | ||||||
|  | 		drawtype = "nodebox", | ||||||
|  | 		node_box = { | ||||||
|  | 			type = "connected", | ||||||
|  | 			fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}}, | ||||||
|  | 			-- connect_top = | ||||||
|  | 			-- connect_bottom = | ||||||
|  | 			connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8}, | ||||||
|  | 				{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}}, | ||||||
|  | 			connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16}, | ||||||
|  | 				{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}}, | ||||||
|  | 			connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2}, | ||||||
|  | 				{-1/16,-5/16,1/8,1/16,-3/16,1/2}}, | ||||||
|  | 			connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16}, | ||||||
|  | 				{1/8,-5/16,-1/16,1/2,-3/16,1/16}}, | ||||||
|  | 		}, | ||||||
|  | 		connects_to = {"group:fence", "group:wood", "group:tree"}, | ||||||
|  | 		inventory_image = fence_texture, | ||||||
|  | 		wield_image = fence_texture, | ||||||
|  | 		tiles = {def.texture}, | ||||||
|  | 		sunlight_propagates = true, | ||||||
|  | 		is_ground_content = false, | ||||||
|  | 		groups = {}, | ||||||
|  | 	} | ||||||
|  | 	for k, v in pairs(default_fields) do | ||||||
|  | 		if not def[k] then | ||||||
|  | 			def[k] = v | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	-- Always add to the fence group, even if no group provided | ||||||
|  | 	def.groups.fence = 1 | ||||||
|  |  | ||||||
|  | 	def.texture = nil | ||||||
|  | 	def.material = nil | ||||||
|  |  | ||||||
|  | 	minetest.register_node(name, def) | ||||||
|  | end | ||||||
|  |  | ||||||
|  |  | ||||||
| -- | -- | ||||||
| -- Leafdecay | -- Leafdecay | ||||||
| -- | -- | ||||||
| @@ -245,9 +295,11 @@ minetest.register_globalstep(function(dtime) | |||||||
| end) | end) | ||||||
|  |  | ||||||
| default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) | default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) | ||||||
|  | 	if placer and not placer:get_player_control().sneak then | ||||||
| 		local node = minetest.get_node(pos) | 		local node = minetest.get_node(pos) | ||||||
| 		node.param2 = 1 | 		node.param2 = 1 | ||||||
| 		minetest.set_node(pos, node) | 		minetest.set_node(pos, node) | ||||||
|  | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
| minetest.register_abm({ | minetest.register_abm({ | ||||||
| @@ -277,8 +329,10 @@ minetest.register_abm({ | |||||||
| 			if trunkp then | 			if trunkp then | ||||||
| 				local n = minetest.get_node(trunkp) | 				local n = minetest.get_node(trunkp) | ||||||
| 				local reg = minetest.registered_nodes[n.name] | 				local reg = minetest.registered_nodes[n.name] | ||||||
| 				-- Assume ignore is a trunk, to make the thing work at the border of the active area | 				-- Assume ignore is a trunk, to make the thing | ||||||
| 				if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then | 				-- work at the border of the active area | ||||||
|  | 				if n.name == "ignore" or (reg and reg.groups.tree and | ||||||
|  | 						reg.groups.tree ~= 0) then | ||||||
| 					--print("cached trunk still exists") | 					--print("cached trunk still exists") | ||||||
| 					return | 					return | ||||||
| 				end | 				end | ||||||
| @@ -292,7 +346,8 @@ minetest.register_abm({ | |||||||
| 		end | 		end | ||||||
| 		default.leafdecay_trunk_find_allow_accumulator = | 		default.leafdecay_trunk_find_allow_accumulator = | ||||||
| 				default.leafdecay_trunk_find_allow_accumulator - 1 | 				default.leafdecay_trunk_find_allow_accumulator - 1 | ||||||
| 		-- Assume ignore is a trunk, to make the thing work at the border of the active area | 		-- Assume ignore is a trunk, to make the thing | ||||||
|  | 		-- work at the border of the active area | ||||||
| 		local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"}) | 		local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"}) | ||||||
| 		if p1 then | 		if p1 then | ||||||
| 			do_preserve = true | 			do_preserve = true | ||||||
| @@ -323,3 +378,100 @@ minetest.register_abm({ | |||||||
| 	end | 	end | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | -- | ||||||
|  | -- Convert dirt to something that fits the environment | ||||||
|  | -- | ||||||
|  |  | ||||||
|  | minetest.register_abm({ | ||||||
|  | 	nodenames = {"default:dirt"}, | ||||||
|  | 	neighbors = { | ||||||
|  | 		"default:dirt_with_grass", | ||||||
|  | 		"default:dirt_with_dry_grass", | ||||||
|  | 		"default:dirt_with_snow", | ||||||
|  | 		"group:grass", | ||||||
|  | 		"group:dry_grass", | ||||||
|  | 		"default:snow", | ||||||
|  | 	}, | ||||||
|  | 	interval = 6, | ||||||
|  | 	chance = 67, | ||||||
|  | 	catch_up = false, | ||||||
|  | 	action = function(pos, node) | ||||||
|  | 		-- Most likely case, half the time it's too dark for this. | ||||||
|  | 		local above = {x = pos.x, y = pos.y + 1, z = pos.z} | ||||||
|  | 		if (minetest.get_node_light(above) or 0) < 13 then | ||||||
|  | 			return | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		-- Look for likely neighbors. | ||||||
|  | 		local p2 = minetest.find_node_near(pos, 1, {"default:dirt_with_grass", | ||||||
|  | 				"default:dirt_with_dry_grass", "default:dirt_with_snow"}) | ||||||
|  | 		if p2 then | ||||||
|  | 			-- But the node needs to be under air in this case. | ||||||
|  | 			local n2 = minetest.get_node(above) | ||||||
|  | 			if n2 and n2.name == "air" then | ||||||
|  | 				local n3 = minetest.get_node(p2) | ||||||
|  | 				minetest.set_node(pos, {name = n3.name}) | ||||||
|  | 				return | ||||||
|  | 			end | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		-- Anything on top? | ||||||
|  | 		local n2 = minetest.get_node(above) | ||||||
|  | 		if not n2 then | ||||||
|  | 			return | ||||||
|  | 		end | ||||||
|  |  | ||||||
|  | 		local name = n2.name | ||||||
|  | 		-- Snow check is cheapest, so comes first. | ||||||
|  | 		if name == "default:snow" then | ||||||
|  | 			minetest.set_node(pos, {name = "default:dirt_with_snow"}) | ||||||
|  | 		-- Most likely case first. | ||||||
|  | 		elseif minetest.get_item_group(name, "grass") ~= 0 then | ||||||
|  | 			minetest.set_node(pos, {name = "default:dirt_with_grass"}) | ||||||
|  | 		elseif minetest.get_item_group(name, "dry_grass") ~= 0 then | ||||||
|  | 			minetest.set_node(pos, {name = "default:dirt_with_dry_grass"}) | ||||||
|  | 		end | ||||||
|  | 	end | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | -- | ||||||
|  | -- Grass and dry grass removed in darkness | ||||||
|  | -- | ||||||
|  |  | ||||||
|  | minetest.register_abm({ | ||||||
|  | 	nodenames = { | ||||||
|  | 		"default:dirt_with_grass", | ||||||
|  | 		"default:dirt_with_dry_grass", | ||||||
|  | 		"default:dirt_with_snow", | ||||||
|  | 	}, | ||||||
|  | 	interval = 8, | ||||||
|  | 	chance = 50, | ||||||
|  | 	catch_up = false, | ||||||
|  | 	action = function(pos, node) | ||||||
|  | 		local above = {x = pos.x, y = pos.y + 1, z = pos.z} | ||||||
|  | 		local name = minetest.get_node(above).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 | ||||||
|  | }) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | -- | ||||||
|  | -- Moss growth on cobble near water | ||||||
|  | -- | ||||||
|  |  | ||||||
|  | minetest.register_abm({ | ||||||
|  | 	nodenames = {"default:cobble"}, | ||||||
|  | 	neighbors = {"group:water"}, | ||||||
|  | 	interval = 16, | ||||||
|  | 	chance = 200, | ||||||
|  | 	catch_up = false, | ||||||
|  | 	action = function(pos, node) | ||||||
|  | 		minetest.set_node(pos, {name = "default:mossycobble"}) | ||||||
|  | 	end | ||||||
|  | }) | ||||||
|   | |||||||
| @@ -18,6 +18,10 @@ local function active_formspec(fuel_percent, item_percent) | |||||||
| 		"list[current_name;dst;4.75,0.96;2,2;]".. | 		"list[current_name;dst;4.75,0.96;2,2;]".. | ||||||
| 		"list[current_player;main;0,4.25;8,1;]".. | 		"list[current_player;main;0,4.25;8,1;]".. | ||||||
| 		"list[current_player;main;0,5.5;8,3;8]".. | 		"list[current_player;main;0,5.5;8,3;8]".. | ||||||
|  | 		"listring[current_name;dst]".. | ||||||
|  | 		"listring[current_player;main]".. | ||||||
|  | 		"listring[current_name;src]".. | ||||||
|  | 		"listring[current_player;main]".. | ||||||
| 		default.get_hotbar_bg(0, 4.25) | 		default.get_hotbar_bg(0, 4.25) | ||||||
| 	return formspec | 	return formspec | ||||||
| end | end | ||||||
| @@ -34,6 +38,10 @@ local inactive_formspec = | |||||||
| 	"list[current_name;dst;4.75,0.96;2,2;]".. | 	"list[current_name;dst;4.75,0.96;2,2;]".. | ||||||
| 	"list[current_player;main;0,4.25;8,1;]".. | 	"list[current_player;main;0,4.25;8,1;]".. | ||||||
| 	"list[current_player;main;0,5.5;8,3;8]".. | 	"list[current_player;main;0,5.5;8,3;8]".. | ||||||
|  | 	"listring[current_name;dst]".. | ||||||
|  | 	"listring[current_player;main]".. | ||||||
|  | 	"listring[current_name;src]".. | ||||||
|  | 	"listring[current_player;main]".. | ||||||
| 	default.get_hotbar_bg(0, 4.25) | 	default.get_hotbar_bg(0, 4.25) | ||||||
|  |  | ||||||
| -- | -- | ||||||
| @@ -82,66 +90,6 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player | |||||||
| 	return stack:get_count() | 	return stack:get_count() | ||||||
| end | end | ||||||
|  |  | ||||||
| -- |  | ||||||
| -- Node definitions |  | ||||||
| -- |  | ||||||
|  |  | ||||||
| minetest.register_node("default:furnace", { |  | ||||||
| 	description = "Furnace", |  | ||||||
| 	tiles = { |  | ||||||
| 		"default_furnace_top.png", "default_furnace_bottom.png", |  | ||||||
| 		"default_furnace_side.png", "default_furnace_side.png", |  | ||||||
| 		"default_furnace_side.png", "default_furnace_front.png" |  | ||||||
| 	}, |  | ||||||
| 	paramtype2 = "facedir", |  | ||||||
| 	groups = {cracky=2}, |  | ||||||
| 	legacy_facedir_simple = true, |  | ||||||
| 	is_ground_content = false, |  | ||||||
| 	sounds = default.node_sound_stone_defaults(), |  | ||||||
| 	 |  | ||||||
| 	can_dig = can_dig, |  | ||||||
| 	 |  | ||||||
| 	allow_metadata_inventory_put = allow_metadata_inventory_put, |  | ||||||
| 	allow_metadata_inventory_move = allow_metadata_inventory_move, |  | ||||||
| 	allow_metadata_inventory_take = allow_metadata_inventory_take, |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| minetest.register_node("default:furnace_active", { |  | ||||||
| 	description = "Furnace", |  | ||||||
| 	tiles = { |  | ||||||
| 		"default_furnace_top.png", "default_furnace_bottom.png", |  | ||||||
| 		"default_furnace_side.png", "default_furnace_side.png", |  | ||||||
| 		"default_furnace_side.png", |  | ||||||
| 		{ |  | ||||||
| 			image = "default_furnace_front_active.png", |  | ||||||
| 			backface_culling = false, |  | ||||||
| 			animation = { |  | ||||||
| 				type = "vertical_frames", |  | ||||||
| 				aspect_w = 16, |  | ||||||
| 				aspect_h = 16, |  | ||||||
| 				length = 1.5 |  | ||||||
| 			}, |  | ||||||
| 		} |  | ||||||
| 	}, |  | ||||||
| 	paramtype2 = "facedir", |  | ||||||
| 	light_source = 8, |  | ||||||
| 	drop = "default:furnace", |  | ||||||
| 	groups = {cracky=2, not_in_creative_inventory=1}, |  | ||||||
| 	legacy_facedir_simple = true, |  | ||||||
| 	is_ground_content = false, |  | ||||||
| 	sounds = default.node_sound_stone_defaults(), |  | ||||||
| 	 |  | ||||||
| 	can_dig = can_dig, |  | ||||||
| 	 |  | ||||||
| 	allow_metadata_inventory_put = allow_metadata_inventory_put, |  | ||||||
| 	allow_metadata_inventory_move = allow_metadata_inventory_move, |  | ||||||
| 	allow_metadata_inventory_take = allow_metadata_inventory_take, |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| -- |  | ||||||
| -- ABM |  | ||||||
| -- |  | ||||||
|  |  | ||||||
| local function swap_node(pos, name) | local function swap_node(pos, name) | ||||||
| 	local node = minetest.get_node(pos) | 	local node = minetest.get_node(pos) | ||||||
| 	if node.name == name then | 	if node.name == name then | ||||||
| @@ -151,11 +99,7 @@ local function swap_node(pos, name) | |||||||
| 	minetest.swap_node(pos, node) | 	minetest.swap_node(pos, node) | ||||||
| end | end | ||||||
|  |  | ||||||
| minetest.register_abm({ | local function furnace_node_timer(pos, elapsed) | ||||||
| 	nodenames = {"default:furnace", "default:furnace_active"}, |  | ||||||
| 	interval = 1.0, |  | ||||||
| 	chance = 1, |  | ||||||
| 	action = function(pos, node, active_object_count, active_object_count_wider) |  | ||||||
| 	-- | 	-- | ||||||
| 	-- Inizialize metadata | 	-- Inizialize metadata | ||||||
| 	-- | 	-- | ||||||
| @@ -164,19 +108,7 @@ minetest.register_abm({ | |||||||
| 	local src_time = meta:get_float("src_time") or 0 | 	local src_time = meta:get_float("src_time") or 0 | ||||||
| 	local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 | 	local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 | ||||||
|  |  | ||||||
| 		-- |  | ||||||
| 		-- Inizialize inventory |  | ||||||
| 		-- |  | ||||||
| 	local inv = meta:get_inventory() | 	local inv = meta:get_inventory() | ||||||
| 		for listname, size in pairs({ |  | ||||||
| 				src = 1, |  | ||||||
| 				fuel = 1, |  | ||||||
| 				dst = 4, |  | ||||||
| 		}) do |  | ||||||
| 			if inv:get_size(listname) ~= size then |  | ||||||
| 				inv:set_size(listname, size) |  | ||||||
| 			end |  | ||||||
| 		end |  | ||||||
| 	local srclist = inv:get_list("src") | 	local srclist = inv:get_list("src") | ||||||
| 	local fuellist = inv:get_list("fuel") | 	local fuellist = inv:get_list("fuel") | ||||||
| 	local dstlist = inv:get_list("dst") | 	local dstlist = inv:get_list("dst") | ||||||
| @@ -227,7 +159,6 @@ minetest.register_abm({ | |||||||
|  |  | ||||||
| 				fuel_totaltime = fuel.time | 				fuel_totaltime = fuel.time | ||||||
| 				fuel_time = 0 | 				fuel_time = 0 | ||||||
| 					 |  | ||||||
| 			end | 			end | ||||||
| 		else | 		else | ||||||
| 			-- We don't need to get new fuel since there is no cookable item | 			-- We don't need to get new fuel since there is no cookable item | ||||||
| @@ -256,17 +187,24 @@ minetest.register_abm({ | |||||||
|  |  | ||||||
| 	local fuel_state = "Empty" | 	local fuel_state = "Empty" | ||||||
| 	local active = "inactive " | 	local active = "inactive " | ||||||
|  | 	local result = false | ||||||
|  |  | ||||||
| 	if fuel_time <= fuel_totaltime and fuel_totaltime ~= 0 then | 	if fuel_time <= fuel_totaltime and fuel_totaltime ~= 0 then | ||||||
| 		active = "active " | 		active = "active " | ||||||
| 		local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) | 		local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) | ||||||
| 		fuel_state = fuel_percent .. "%" | 		fuel_state = fuel_percent .. "%" | ||||||
| 		formspec = active_formspec(fuel_percent, item_percent) | 		formspec = active_formspec(fuel_percent, item_percent) | ||||||
| 		swap_node(pos, "default:furnace_active") | 		swap_node(pos, "default:furnace_active") | ||||||
|  | 		-- make sure timer restarts automatically | ||||||
|  | 		result = true | ||||||
| 	else | 	else | ||||||
| 		if not fuellist[1]:is_empty() then | 		if not fuellist[1]:is_empty() then | ||||||
| 			fuel_state = "0%" | 			fuel_state = "0%" | ||||||
| 		end | 		end | ||||||
| 		swap_node(pos, "default:furnace") | 		swap_node(pos, "default:furnace") | ||||||
|  | 		-- stop timer on the inactive furnace | ||||||
|  | 		local timer = minetest.get_node_timer(pos) | ||||||
|  | 		timer:stop() | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")" | 	local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")" | ||||||
| @@ -279,5 +217,94 @@ minetest.register_abm({ | |||||||
| 	meta:set_float("src_time", src_time) | 	meta:set_float("src_time", src_time) | ||||||
| 	meta:set_string("formspec", formspec) | 	meta:set_string("formspec", formspec) | ||||||
| 	meta:set_string("infotext", infotext) | 	meta:set_string("infotext", infotext) | ||||||
|  |  | ||||||
|  | 	return result | ||||||
|  | end | ||||||
|  |  | ||||||
|  | -- | ||||||
|  | -- Node definitions | ||||||
|  | -- | ||||||
|  |  | ||||||
|  | minetest.register_node("default:furnace", { | ||||||
|  | 	description = "Furnace", | ||||||
|  | 	tiles = { | ||||||
|  | 		"default_furnace_top.png", "default_furnace_bottom.png", | ||||||
|  | 		"default_furnace_side.png", "default_furnace_side.png", | ||||||
|  | 		"default_furnace_side.png", "default_furnace_front.png" | ||||||
|  | 	}, | ||||||
|  | 	paramtype2 = "facedir", | ||||||
|  | 	groups = {cracky=2}, | ||||||
|  | 	legacy_facedir_simple = true, | ||||||
|  | 	is_ground_content = false, | ||||||
|  | 	sounds = default.node_sound_stone_defaults(), | ||||||
|  |  | ||||||
|  | 	can_dig = can_dig, | ||||||
|  |  | ||||||
|  | 	on_timer = furnace_node_timer, | ||||||
|  |  | ||||||
|  | 	on_construct = function(pos) | ||||||
|  | 		local meta = minetest.get_meta(pos) | ||||||
|  | 		meta:set_string("formspec", inactive_formspec) | ||||||
|  | 		local inv = meta:get_inventory() | ||||||
|  | 		inv:set_size('src', 1) | ||||||
|  | 		inv:set_size('fuel', 1) | ||||||
|  | 		inv:set_size('dst', 4) | ||||||
| 	end, | 	end, | ||||||
|  |  | ||||||
|  | 	on_metadata_inventory_move = function(pos) | ||||||
|  | 		local timer = minetest.get_node_timer(pos) | ||||||
|  | 		timer:start(1.0) | ||||||
|  | 	end, | ||||||
|  | 	on_metadata_inventory_put = function(pos) | ||||||
|  | 		-- start timer function, it will sort out whether furnace can burn or not. | ||||||
|  | 		local timer = minetest.get_node_timer(pos) | ||||||
|  | 		timer:start(1.0) | ||||||
|  | 	end, | ||||||
|  | 	on_blast = function(pos) | ||||||
|  | 		local drops = {} | ||||||
|  | 		default.get_inventory_drops(pos, "src", drops) | ||||||
|  | 		default.get_inventory_drops(pos, "fuel", drops) | ||||||
|  | 		default.get_inventory_drops(pos, "dst", drops) | ||||||
|  | 		drops[#drops+1] = "default:furnace" | ||||||
|  | 		minetest.remove_node(pos) | ||||||
|  | 		return drops | ||||||
|  | 	end, | ||||||
|  |  | ||||||
|  | 	allow_metadata_inventory_put = allow_metadata_inventory_put, | ||||||
|  | 	allow_metadata_inventory_move = allow_metadata_inventory_move, | ||||||
|  | 	allow_metadata_inventory_take = allow_metadata_inventory_take, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_node("default:furnace_active", { | ||||||
|  | 	description = "Furnace", | ||||||
|  | 	tiles = { | ||||||
|  | 		"default_furnace_top.png", "default_furnace_bottom.png", | ||||||
|  | 		"default_furnace_side.png", "default_furnace_side.png", | ||||||
|  | 		"default_furnace_side.png", | ||||||
|  | 		{ | ||||||
|  | 			image = "default_furnace_front_active.png", | ||||||
|  | 			backface_culling = false, | ||||||
|  | 			animation = { | ||||||
|  | 				type = "vertical_frames", | ||||||
|  | 				aspect_w = 16, | ||||||
|  | 				aspect_h = 16, | ||||||
|  | 				length = 1.5 | ||||||
|  | 			}, | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 	paramtype2 = "facedir", | ||||||
|  | 	light_source = 8, | ||||||
|  | 	drop = "default:furnace", | ||||||
|  | 	groups = {cracky=2, not_in_creative_inventory=1}, | ||||||
|  | 	legacy_facedir_simple = true, | ||||||
|  | 	is_ground_content = false, | ||||||
|  | 	sounds = default.node_sound_stone_defaults(), | ||||||
|  | 	on_timer = furnace_node_timer, | ||||||
|  |  | ||||||
|  | 	can_dig = can_dig, | ||||||
|  |  | ||||||
|  | 	allow_metadata_inventory_put = allow_metadata_inventory_put, | ||||||
|  | 	allow_metadata_inventory_move = allow_metadata_inventory_move, | ||||||
|  | 	allow_metadata_inventory_take = allow_metadata_inventory_take, | ||||||
|  | }) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,16 +1,13 @@ | |||||||
| -- Minetest 0.4 mod: default | -- Minetest 0.4 mod: default | ||||||
| -- See README.txt for licensing and other information. | -- See README.txt for licensing and other information. | ||||||
|  |  | ||||||
| -- The API documentation in here was moved into doc/lua_api.txt | -- The API documentation in here was moved into game_api.txt | ||||||
|  |  | ||||||
| WATER_ALPHA = 160 |  | ||||||
| WATER_VISC = 1 |  | ||||||
| LAVA_VISC = 7 |  | ||||||
| LIGHT_MAX = 14 |  | ||||||
|  |  | ||||||
| -- Definitions made by this mod that other mods can use too | -- Definitions made by this mod that other mods can use too | ||||||
| default = {} | default = {} | ||||||
|  |  | ||||||
|  | default.LIGHT_MAX = 14 | ||||||
|  |  | ||||||
| -- GUI related stuff | -- GUI related stuff | ||||||
| default.gui_bg = "bgcolor[#080808BB;true]" | default.gui_bg = "bgcolor[#080808BB;true]" | ||||||
| default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]" | default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]" | ||||||
| @@ -24,7 +21,7 @@ function default.get_hotbar_bg(x,y) | |||||||
| 	return out | 	return out | ||||||
| end | end | ||||||
|  |  | ||||||
| default.gui_suvival_form = "size[8,8.5]".. | default.gui_survival_form = "size[8,8.5]".. | ||||||
| 			default.gui_bg.. | 			default.gui_bg.. | ||||||
| 			default.gui_bg_img.. | 			default.gui_bg_img.. | ||||||
| 			default.gui_slots.. | 			default.gui_slots.. | ||||||
| @@ -33,6 +30,8 @@ default.gui_suvival_form = "size[8,8.5]".. | |||||||
| 			"list[current_player;craft;1.75,0.5;3,3;]".. | 			"list[current_player;craft;1.75,0.5;3,3;]".. | ||||||
| 			"list[current_player;craftpreview;5.75,1.5;1,1;]".. | 			"list[current_player;craftpreview;5.75,1.5;1,1;]".. | ||||||
| 			"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. | 			"image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. | ||||||
|  | 			"listring[current_player;main]".. | ||||||
|  | 			"listring[current_player;craft]".. | ||||||
| 			default.get_hotbar_bg(0,4.25) | 			default.get_hotbar_bg(0,4.25) | ||||||
|  |  | ||||||
| -- Load files | -- Load files | ||||||
| @@ -46,3 +45,4 @@ dofile(minetest.get_modpath("default").."/mapgen.lua") | |||||||
| dofile(minetest.get_modpath("default").."/player.lua") | dofile(minetest.get_modpath("default").."/player.lua") | ||||||
| dofile(minetest.get_modpath("default").."/trees.lua") | dofile(minetest.get_modpath("default").."/trees.lua") | ||||||
| dofile(minetest.get_modpath("default").."/aliases.lua") | dofile(minetest.get_modpath("default").."/aliases.lua") | ||||||
|  | dofile(minetest.get_modpath("default").."/legacy.lua") | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								mods/default/legacy.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -0,0 +1,25 @@ | |||||||
|  | -- mods/default/legacy.lua | ||||||
|  |  | ||||||
|  | -- Horrible crap to support old code registering falling nodes | ||||||
|  | -- Don't use this and never do what this does, it's completely wrong! | ||||||
|  | -- (More specifically, the client and the C++ code doesn't get the group) | ||||||
|  | function default.register_falling_node(nodename, texture) | ||||||
|  | 	minetest.log("error", debug.traceback()) | ||||||
|  | 	minetest.log('error', "WARNING: default.register_falling_node is deprecated") | ||||||
|  | 	if minetest.registered_nodes[nodename] then | ||||||
|  | 		minetest.registered_nodes[nodename].groups.falling_node = 1 | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
|  | function default.spawn_falling_node(p, nodename) | ||||||
|  | 	spawn_falling_node(p, nodename) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | -- Liquids | ||||||
|  | WATER_ALPHA = minetest.registered_nodes["default:water_source"].alpha | ||||||
|  | WATER_VISC = minetest.registered_nodes["default:water_source"].liquid_viscosity | ||||||
|  | LAVA_VISC = minetest.registered_nodes["default:lava_source"].liquid_viscosity | ||||||
|  | LIGHT_MAX = default.LIGHT_MAX | ||||||
|  |  | ||||||
|  | -- Formspecs | ||||||
|  | default.gui_suvival_form = default.gui_survival_form | ||||||
							
								
								
									
										
											BIN
										
									
								
								mods/default/models/character.b3d
									
									
									
									
									
										Normal file
									
								
							
							
						
						| @@ -15,7 +15,7 @@ function default.player_register_model(name, def) | |||||||
| end | end | ||||||
|  |  | ||||||
| -- Default player appearance | -- Default player appearance | ||||||
| default.player_register_model("character.x", { | default.player_register_model("character.b3d", { | ||||||
| 	animation_speed = 30, | 	animation_speed = 30, | ||||||
| 	textures = {"character.png", }, | 	textures = {"character.png", }, | ||||||
| 	animations = { | 	animations = { | ||||||
| @@ -93,12 +93,12 @@ end | |||||||
| -- Update appearance when the player joins | -- Update appearance when the player joins | ||||||
| minetest.register_on_joinplayer(function(player) | minetest.register_on_joinplayer(function(player) | ||||||
| 	default.player_attached[player:get_player_name()] = false | 	default.player_attached[player:get_player_name()] = false | ||||||
| 	default.player_set_model(player, "character.x") | 	default.player_set_model(player, "character.b3d") | ||||||
| 	player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) | 	player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) | ||||||
| 	 | 	 | ||||||
| 	-- set GUI | 	-- set GUI | ||||||
| 	if not minetest.setting_getbool("creative_mode") then | 	if not minetest.setting_getbool("creative_mode") then | ||||||
| 		player:set_inventory_formspec(default.gui_suvival_form) | 		player:set_inventory_formspec(default.gui_survival_form) | ||||||
| 	end | 	end | ||||||
| 	player:hud_set_hotbar_image("gui_hotbar.png") | 	player:hud_set_hotbar_image("gui_hotbar.png") | ||||||
| 	player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") | 	player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/acacia_tree.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/acacia_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/apple_tree.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/apple_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/aspen_tree.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/aspen_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/jungle_tree.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/jungle_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/large_cactus.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/papyrus.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/pine_tree.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/pine_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								mods/default/schematics/snowy_pine_tree_from_sapling.mts
									
									
									
									
									
										Normal file
									
								
							
							
						
						| Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 459 B | 
| Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 348 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_acacia_leaves.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 444 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_acacia_sapling.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 359 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_acacia_tree.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 682 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_acacia_tree_top.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 731 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_acacia_wood.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 261 B | 
| Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 251 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_aspen_leaves.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 761 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_aspen_sapling.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 320 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_aspen_tree.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 695 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_aspen_tree_top.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 656 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_aspen_wood.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 373 B | 
| Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 201 B | 
							
								
								
									
										
											BIN
										
									
								
								mods/default/textures/default_book_written.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 228 B | 
| Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 471 B | 
| Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 351 B | 
| Before Width: | Height: | Size: 568 B After Width: | Height: | Size: 356 B | 
| Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 224 B | 
| Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 314 B | 
| Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 267 B | 
| Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 423 B | 
| Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 469 B |