Compare commits
27 Commits
0.4.dev-20
...
0.4.dev-20
Author | SHA1 | Date | |
---|---|---|---|
3aac1adb15 | |||
2302e55dbb | |||
279eff9a7f | |||
df2037b886 | |||
ccf3b71c28 | |||
5296dc1518 | |||
51fce37fc1 | |||
9207e9af46 | |||
befc604af3 | |||
5f6039bc3c | |||
4abfcda81f | |||
95f4ccab51 | |||
dee4b328a3 | |||
60c16eb57b | |||
68504124d7 | |||
fe315ac1eb | |||
ab84afd071 | |||
48a76211a8 | |||
de13e8f1fa | |||
5bd33df1a3 | |||
1d4ae73e0d | |||
492e86050c | |||
0b157335d1 | |||
8fece11cc7 | |||
fa06d11909 | |||
b4d659d8ae | |||
ad58e41580 |
23
README.txt
@ -8,11 +8,23 @@ in the Minetest Engine.
|
||||
The Minetest Engine can be found in:
|
||||
https://github.com/celeron55/minetest/
|
||||
|
||||
This has been tested to work with the version tagged 0.4.dev-20120326.
|
||||
Compatibility
|
||||
--------------
|
||||
The minetest_game github master HEAD is generally compatible with the github
|
||||
master HEAD of minetest.
|
||||
|
||||
Additionally, when the minetest engine is tagged to be a certain version (eg.
|
||||
0.4.dev-20120326), minetest_game is tagged with the version too.
|
||||
|
||||
When stable releases are made, minetest_game is packaged and made available in
|
||||
https://github.com/celeron55/minetest_game/downloads
|
||||
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!)
|
||||
|
||||
License of source code
|
||||
----------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -31,13 +43,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not mentioned in here - Perttu Ahola <celeron55@gmail.com>
|
||||
default_grass_footstep.{1,2,3}.ogg - Modified versions of sounds by kddekadenz/Dogers
|
||||
default_dig_crumbly.{1,2}.ogg - Modified versions of sounds by kddekadenz/Dogers
|
||||
|
||||
|
||||
|
26
mods/bucket/README.txt
Normal file
@ -0,0 +1,26 @@
|
||||
Minetest 0.4 mod: bucket
|
||||
=========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- bucket (Minetest 0.4 mod)
|
||||
-- A bucket, which can pick up water and lava
|
||||
-- Minetest 0.4 mod: bucket
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||
|
64
mods/default/README.txt
Normal file
@ -0,0 +1,64 @@
|
||||
Minetest 0.4 mod: default
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
Originating from work by kddekadenz/Dogers:
|
||||
default_grass_footstep.{1,2,3}.ogg
|
||||
default_dig_crumbly.{1,2}.ogg
|
||||
|
||||
Cisoun's WTFPL texture pack:
|
||||
default_chest_front.png
|
||||
default_chest_lock.png
|
||||
default_chest_side.png
|
||||
default_chest_top.png
|
||||
default_cobble.png
|
||||
default_dirt.png
|
||||
default_grass.png
|
||||
default_grass_side.png
|
||||
default_jungletree.png
|
||||
default_jungletree_top.png
|
||||
default_lava.png
|
||||
default_leaves.png
|
||||
default_mossycobble.png
|
||||
default_sand.png
|
||||
default_sapling.png
|
||||
default_sign_wall.png
|
||||
default_stone.png
|
||||
default_tool_mesepick.png
|
||||
default_tool_steelpick.png
|
||||
default_tool_steelshovel.png
|
||||
default_tool_steelsword.png
|
||||
default_tool_stonepick.png
|
||||
default_tool_stoneshovel.png
|
||||
default_tool_woodpick.png
|
||||
default_tool_woodshovel.png
|
||||
default_tree.png
|
||||
default_tree_top.png
|
||||
default_water.png
|
||||
|
||||
Originating from G4JC's Almost MC Texture Pack:
|
||||
default_wood.png
|
||||
default_torch.png
|
||||
default_torch_on_ceiling.png
|
||||
default_torch_on_floor.png
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- default (Minetest 0.4 mod)
|
||||
-- Most default stuff
|
||||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- The API documentation in here was moved into doc/lua_api.txt
|
||||
|
||||
@ -11,6 +11,10 @@ LIGHT_MAX = 14
|
||||
-- Definitions made by this mod that other mods can use too
|
||||
default = {}
|
||||
|
||||
-- Load other files
|
||||
dofile(minetest.get_modpath("default").."/mapgen.lua")
|
||||
dofile(minetest.get_modpath("default").."/leafdecay.lua")
|
||||
|
||||
--
|
||||
-- Tool definition
|
||||
--
|
||||
@ -24,10 +28,10 @@ minetest.register_item(":", {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
fleshy = {times={[2]=2.00, [3]=1.00}, maxwear=0, maxlevel=1},
|
||||
crumbly = {times={[3]=0.70}, maxwear=0, maxlevel=1},
|
||||
snappy = {times={[3]=0.40}, maxwear=0, maxlevel=1},
|
||||
oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, maxwear=0, maxlevel=3},
|
||||
fleshy = {times={[2]=2.00, [3]=1.00}, uses=0, maxlevel=1},
|
||||
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
|
||||
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
|
||||
oddly_breakable_by_hand = {times={[1]=7.00,[2]=4.00,[3]=1.40}, uses=0, maxlevel=3},
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -38,7 +42,7 @@ minetest.register_tool("default:pick_wood", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
cracky={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
|
||||
cracky={times={[2]=2.00, [3]=1.20}, uses=10, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -48,7 +52,7 @@ minetest.register_tool("default:pick_stone", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
cracky={times={[1]=1.50, [2]=0.80, [3]=0.60}, maxwear=0.05, maxlevel=1}
|
||||
cracky={times={[1]=3.00, [2]=1.20, [3]=0.80}, uses=20, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -58,7 +62,7 @@ minetest.register_tool("default:pick_steel", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
cracky={times={[1]=1.00, [2]=0.60, [3]=0.40}, maxwear=0.1, maxlevel=2}
|
||||
cracky={times={[1]=4.00, [2]=1.60, [3]=1.00}, uses=10, maxlevel=2}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -69,9 +73,9 @@ minetest.register_tool("default:pick_mese", {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=3,
|
||||
groupcaps={
|
||||
cracky={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
|
||||
crumbly={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
|
||||
snappy={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3}
|
||||
cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3},
|
||||
crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3},
|
||||
snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -81,7 +85,7 @@ minetest.register_tool("default:shovel_wood", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
crumbly={times={[1]=1.50, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=1}
|
||||
crumbly={times={[1]=3.00, [2]=0.80, [3]=0.50}, uses=10, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -91,7 +95,7 @@ minetest.register_tool("default:shovel_stone", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
crumbly={times={[1]=0.80, [2]=0.50, [3]=0.30}, maxwear=0.05, maxlevel=1}
|
||||
crumbly={times={[1]=1.50, [2]=0.50, [3]=0.30}, uses=20, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -101,7 +105,7 @@ minetest.register_tool("default:shovel_steel", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
crumbly={times={[1]=0.50, [2]=0.35, [3]=0.30}, maxwear=0.1, maxlevel=2}
|
||||
crumbly={times={[1]=1.50, [2]=0.70, [3]=0.60}, uses=10, maxlevel=2}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -111,8 +115,8 @@ minetest.register_tool("default:axe_wood", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
choppy={times={[2]=1.40, [3]=0.80}, maxwear=0.1, maxlevel=1},
|
||||
fleshy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
|
||||
choppy={times={[2]=1.40, [3]=0.80}, uses=10, maxlevel=1},
|
||||
fleshy={times={[2]=1.50, [3]=0.80}, uses=10, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -122,8 +126,8 @@ minetest.register_tool("default:axe_stone", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
choppy={times={[1]=1.50, [2]=1.00, [3]=0.60}, maxwear=0.05, maxlevel=1},
|
||||
fleshy={times={[2]=1.30, [3]=0.70}, maxwear=0.05, maxlevel=1}
|
||||
choppy={times={[1]=3.00, [2]=1.00, [3]=0.60}, uses=20, maxlevel=1},
|
||||
fleshy={times={[2]=1.30, [3]=0.70}, uses=20, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -133,8 +137,8 @@ minetest.register_tool("default:axe_steel", {
|
||||
tool_capabilities = {
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
choppy={times={[1]=1.00, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=2},
|
||||
fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.03, maxlevel=1}
|
||||
choppy={times={[1]=3.00, [2]=1.60, [3]=1.00}, uses=10, maxlevel=2},
|
||||
fleshy={times={[2]=1.10, [3]=0.60}, uses=40, maxlevel=1}
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -145,9 +149,9 @@ minetest.register_tool("default:sword_wood", {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.1, maxlevel=1},
|
||||
snappy={times={[2]=1.00, [3]=0.50}, maxwear=0.1, maxlevel=1},
|
||||
choppy={times={[3]=1.00}, maxwear=0.05, maxlevel=0}
|
||||
fleshy={times={[2]=1.10, [3]=0.60}, uses=10, maxlevel=1},
|
||||
snappy={times={[2]=1.00, [3]=0.50}, uses=10, maxlevel=1},
|
||||
choppy={times={[3]=1.00}, uses=20, maxlevel=0}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -158,9 +162,9 @@ minetest.register_tool("default:sword_stone", {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
|
||||
fleshy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1},
|
||||
snappy={times={[2]=0.80, [3]=0.40}, uses=20, maxlevel=1},
|
||||
choppy={times={[3]=0.90}, uses=20, maxlevel=0}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -171,9 +175,9 @@ minetest.register_tool("default:sword_steel", {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
fleshy={times={[1]=1.00, [2]=0.40, [3]=0.20}, maxwear=0.1, maxlevel=2},
|
||||
snappy={times={[2]=0.70, [3]=0.30}, maxwear=0.03, maxlevel=1},
|
||||
choppy={times={[3]=0.70}, maxwear=0.03, maxlevel=0}
|
||||
fleshy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=10, maxlevel=2},
|
||||
snappy={times={[2]=0.70, [3]=0.30}, uses=40, maxlevel=1},
|
||||
choppy={times={[3]=0.70}, uses=40, maxlevel=0}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -461,14 +465,8 @@ minetest.register_craft({
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:coal_lump",
|
||||
recipe = "default:tree",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:coal_lump",
|
||||
recipe = "default:jungletree",
|
||||
output = "default:glass",
|
||||
recipe = "default:desert_sand",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -706,6 +704,16 @@ minetest.register_node("default:stone", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:desert_stone", {
|
||||
description = "Desert stone",
|
||||
tile_images = {"default_desert_stone.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
drop = 'default:desert_stone',
|
||||
legacy_mineral = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:stone_with_coal", {
|
||||
description = "Stone with coal",
|
||||
tile_images = {"default_stone.png^default_mineral_coal.png"},
|
||||
@ -758,7 +766,15 @@ minetest.register_node("default:sand", {
|
||||
description = "Sand",
|
||||
tile_images = {"default_sand.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
groups = {crumbly=3, falling_node=1},
|
||||
sounds = default.node_sound_sand_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:desert_sand", {
|
||||
description = "Desert sand",
|
||||
tile_images = {"default_desert_sand.png"},
|
||||
is_ground_content = true,
|
||||
groups = {sand=1, crumbly=3, falling_node=1},
|
||||
sounds = default.node_sound_sand_defaults(),
|
||||
})
|
||||
|
||||
@ -766,7 +782,7 @@ minetest.register_node("default:gravel", {
|
||||
description = "Gravel",
|
||||
tile_images = {"default_gravel.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2},
|
||||
groups = {crumbly=2, falling_node=1},
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_gravel_footstep", gain=0.45},
|
||||
}),
|
||||
@ -805,7 +821,7 @@ minetest.register_node("default:tree", {
|
||||
description = "Tree",
|
||||
tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1},
|
||||
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -813,7 +829,7 @@ minetest.register_node("default:jungletree", {
|
||||
description = "Jungle Tree",
|
||||
tile_images = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1},
|
||||
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -826,7 +842,7 @@ minetest.register_node("default:junglegrass", {
|
||||
wield_image = "default_junglegrass.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=3},
|
||||
groups = {snappy=3,flammable=2},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
@ -836,7 +852,7 @@ minetest.register_node("default:leaves", {
|
||||
visual_scale = 1.3,
|
||||
tile_images = {"default_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3},
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
@ -859,7 +875,7 @@ minetest.register_node("default:cactus", {
|
||||
description = "Cactus",
|
||||
tile_images = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3},
|
||||
groups = {snappy=2,choppy=3,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -872,7 +888,7 @@ minetest.register_node("default:papyrus", {
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
walkable = false,
|
||||
groups = {snappy=3},
|
||||
groups = {snappy=3,flammable=2},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
@ -880,7 +896,7 @@ minetest.register_node("default:bookshelf", {
|
||||
description = "Bookshelf",
|
||||
tile_images = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2},
|
||||
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -908,7 +924,7 @@ minetest.register_node("default:fence_wood", {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -945,7 +961,7 @@ minetest.register_node("default:ladder", {
|
||||
--wall_bottom = = <default>
|
||||
--wall_side = = <default>
|
||||
},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=2},
|
||||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
@ -954,7 +970,7 @@ minetest.register_node("default:wood", {
|
||||
description = "Wood",
|
||||
tile_images = {"default_wood.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -993,7 +1009,7 @@ minetest.register_node("default:water_flowing", {
|
||||
{image="default_water.png", backface_culling=false},
|
||||
{image="default_water.png", backface_culling=true},
|
||||
},
|
||||
groups = {water=3, liquid=3},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1},
|
||||
})
|
||||
|
||||
minetest.register_node("default:water_source", {
|
||||
@ -1016,7 +1032,7 @@ minetest.register_node("default:water_source", {
|
||||
-- New-style water source material (mostly unused)
|
||||
{image="default_water.png", backface_culling=false},
|
||||
},
|
||||
groups = {water=3, liquid=3},
|
||||
groups = {water=3, liquid=3, puts_out_fire=1},
|
||||
})
|
||||
|
||||
minetest.register_node("default:lava_flowing", {
|
||||
@ -1040,7 +1056,7 @@ minetest.register_node("default:lava_flowing", {
|
||||
{image="default_lava.png", backface_culling=false},
|
||||
{image="default_lava.png", backface_culling=true},
|
||||
},
|
||||
groups = {lava=3, liquid=2, hot=3},
|
||||
groups = {lava=3, liquid=2, hot=3, igniter=2},
|
||||
})
|
||||
|
||||
minetest.register_node("default:lava_source", {
|
||||
@ -1064,7 +1080,7 @@ minetest.register_node("default:lava_source", {
|
||||
-- New-style lava source material (mostly unused)
|
||||
{image="default_lava.png", backface_culling=false},
|
||||
},
|
||||
groups = {lava=3, liquid=2, hot=3},
|
||||
groups = {lava=3, liquid=2, hot=3, igniter=2},
|
||||
})
|
||||
|
||||
minetest.register_node("default:torch", {
|
||||
@ -1084,7 +1100,7 @@ minetest.register_node("default:torch", {
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
|
||||
},
|
||||
groups = {choppy=2,dig_immediate=3},
|
||||
groups = {choppy=2,dig_immediate=3,flammable=1},
|
||||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
@ -1106,7 +1122,7 @@ minetest.register_node("default:sign_wall", {
|
||||
--wall_bottom = <default>
|
||||
--wall_side = <default>
|
||||
},
|
||||
groups = {choppy=2,dig_immediate=2},
|
||||
groups = {choppy=2,dig_immediate=2,flammable=2},
|
||||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
@ -1164,7 +1180,7 @@ minetest.register_node("default:steelblock", {
|
||||
description = "Steel Block",
|
||||
tile_images = {"default_steel_block.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=1,bendy=2},
|
||||
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
@ -1196,7 +1212,7 @@ minetest.register_node("default:sapling", {
|
||||
wield_image = "default_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=2,dig_immediate=3},
|
||||
groups = {snappy=2,dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
@ -1209,11 +1225,28 @@ minetest.register_node("default:apple", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
groups = {fleshy=3,dig_immediate=3},
|
||||
groups = {fleshy=3,dig_immediate=3,flammable=2},
|
||||
on_use = minetest.item_eat(4),
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:dry_shrub", {
|
||||
description = "Dry Shrub",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tile_images = {"default_dry_shrub.png"},
|
||||
inventory_image = "default_dry_shrub.png",
|
||||
wield_image = "default_dry_shrub.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=3,flammable=3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3},
|
||||
},
|
||||
})
|
||||
|
||||
--
|
||||
-- Crafting items
|
||||
--
|
||||
@ -1298,20 +1331,122 @@ minetest.add_to_creative_inventory('default:water_source')
|
||||
minetest.add_to_creative_inventory('default:lava_source')
|
||||
minetest.add_to_creative_inventory('default:ladder')
|
||||
|
||||
--
|
||||
-- Falling stuff
|
||||
--
|
||||
|
||||
minetest.register_entity("default:falling_node", {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "wielditem",
|
||||
textures = {},
|
||||
visual_size = {x=0.667, y=0.667},
|
||||
},
|
||||
|
||||
nodename = "",
|
||||
|
||||
set_node = function(self, nodename)
|
||||
self.nodename = nodename
|
||||
local stack = ItemStack(nodename)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
textures = {nodename},
|
||||
}
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return self.nodename
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.nodename = staticdata
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
--self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self:set_node(self.nodename)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
-- Set gravity
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
-- Turn to actual sand when collides to ground or just move
|
||||
local pos = self.object:getpos()
|
||||
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
|
||||
local bcn = minetest.env:get_node(bcp)
|
||||
-- Note: walkable is in the node definition, not in item groups
|
||||
if minetest.registered_nodes[bcn.name] and
|
||||
minetest.registered_nodes[bcn.name].walkable then
|
||||
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
|
||||
-- Check what's here
|
||||
local n2 = minetest.env:get_node(np)
|
||||
-- If it's not air or liquid, remove node and replace it with
|
||||
-- it's drops
|
||||
if n2.name ~= "air" and (not minetest.registered_nodes[n2.name] or
|
||||
minetest.registered_nodes[n2.name].liquidtype == "none") then
|
||||
local drops = minetest.get_node_drops(n2.name, "")
|
||||
minetest.env:remove_node(np)
|
||||
-- Add dropped items
|
||||
local _, dropped_item
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
minetest.env:add_item(np, dropped_item)
|
||||
end
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
callback(np, n2, nil)
|
||||
end
|
||||
end
|
||||
-- Create node and remove entity
|
||||
minetest.env:add_node(np, {name=self.nodename})
|
||||
self.object:remove()
|
||||
else
|
||||
-- Do nothing
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function default.spawn_falling_node(p, nodename)
|
||||
obj = minetest.env:add_entity(p, "default:falling_node")
|
||||
obj:get_luaentity():set_node(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
|
||||
|
||||
--
|
||||
-- Some common functions
|
||||
--
|
||||
|
||||
default.falling_node_names = {}
|
||||
|
||||
function nodeupdate_single(p)
|
||||
n = minetest.env:get_node(p)
|
||||
if default.falling_node_names[n.name] ~= nil then
|
||||
if minetest.get_node_group(n.name, "falling_node") ~= 0 then
|
||||
p_bottom = {x=p.x, y=p.y-1, z=p.z}
|
||||
n_bottom = minetest.env:get_node(p_bottom)
|
||||
if n_bottom.name == "air" then
|
||||
-- Note: walkable is in the node definition, not in item groups
|
||||
if minetest.registered_nodes[n_bottom.name] and
|
||||
not minetest.registered_nodes[n_bottom.name].walkable then
|
||||
minetest.env:remove_node(p)
|
||||
minetest.env:add_entity(p, "default:falling_"..n.name)
|
||||
default.spawn_falling_node(p, n.name)
|
||||
nodeupdate(p)
|
||||
end
|
||||
end
|
||||
@ -1328,43 +1463,6 @@ function nodeupdate(p)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Falling stuff
|
||||
--
|
||||
|
||||
function default.register_falling_node(nodename, texture)
|
||||
default.falling_node_names[nodename] = true
|
||||
-- Override naming conventions for stuff like :default:falling_default:sand
|
||||
minetest.register_entity(":default:falling_"..nodename, {
|
||||
-- Static definition
|
||||
physical = true,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
textures = {texture,texture,texture,texture,texture,texture},
|
||||
-- State
|
||||
-- Methods
|
||||
on_step = function(self, dtime)
|
||||
-- Set gravity
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
-- Turn to actual sand when collides to ground or just move
|
||||
local pos = self.object:getpos()
|
||||
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
|
||||
local bcn = minetest.env:get_node(bcp)
|
||||
if bcn.name ~= "air" then
|
||||
-- Turn to a sand node
|
||||
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
|
||||
minetest.env:add_node(np, {name=nodename})
|
||||
self.object:remove()
|
||||
else
|
||||
-- Do nothing
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
default.register_falling_node("default:sand", "default_sand.png")
|
||||
default.register_falling_node("default:gravel", "default_gravel.png")
|
||||
|
||||
--
|
||||
-- Global callbacks
|
||||
--
|
||||
@ -1500,11 +1598,4 @@ minetest.register_on_chat_message(function(name, message)
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- Done, print some random stuff
|
||||
--
|
||||
|
||||
--print("minetest.registered_entities:")
|
||||
--dump2(minetest.registered_entities)
|
||||
|
||||
-- END
|
||||
|
92
mods/default/leafdecay.lua
Normal file
@ -0,0 +1,92 @@
|
||||
-- minetest/default/leafdecay.lua
|
||||
|
||||
-- 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.
|
||||
--
|
||||
-- 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.
|
||||
|
||||
default.leafdecay_trunk_cache = {}
|
||||
default.leafdecay_enable_cache = true
|
||||
-- Spread the load of finding trunks
|
||||
default.leafdecay_trunk_find_allow_accumulator = 0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local finds_per_second = 5000
|
||||
default.leafdecay_trunk_find_allow_accumulator =
|
||||
math.floor(dtime * finds_per_second)
|
||||
end)
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:leafdecay"},
|
||||
neighbors = {"air", "group:liquid"},
|
||||
-- A low interval and a high inverse chance spreads the load
|
||||
interval = 2,
|
||||
chance = 5,
|
||||
|
||||
action = function(p0, node, _, _)
|
||||
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
||||
local do_preserve = false
|
||||
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
||||
if not d or d == 0 then
|
||||
--print("not groups.leafdecay")
|
||||
return
|
||||
end
|
||||
local n0 = minetest.env:get_node(p0)
|
||||
if n0.param2 ~= 0 then
|
||||
--print("param2 ~= 0")
|
||||
return
|
||||
end
|
||||
local p0_hash = nil
|
||||
if default.leafdecay_enable_cache then
|
||||
p0_hash = minetest.hash_node_position(p0)
|
||||
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
||||
if trunkp then
|
||||
local n = minetest.env:get_node(trunkp)
|
||||
local reg = minetest.registered_nodes[n.name]
|
||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||
if n.name == "ignore" or (reg.groups.tree and reg.groups.tree ~= 0) then
|
||||
--print("cached trunk still exists")
|
||||
return
|
||||
end
|
||||
--print("cached trunk is invalid")
|
||||
-- Cache is invalid
|
||||
table.remove(default.leafdecay_trunk_cache, p0_hash)
|
||||
end
|
||||
end
|
||||
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
|
||||
return
|
||||
end
|
||||
default.leafdecay_trunk_find_allow_accumulator =
|
||||
default.leafdecay_trunk_find_allow_accumulator - 1
|
||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
|
||||
if p1 then
|
||||
do_preserve = true
|
||||
if default.leafdecay_enable_cache then
|
||||
--print("caching trunk")
|
||||
-- Cache the trunk
|
||||
default.leafdecay_trunk_cache[p0_hash] = p1
|
||||
end
|
||||
end
|
||||
if not do_preserve then
|
||||
-- Drop stuff other than the node itself
|
||||
itemstacks = minetest.get_node_drops(n0.name)
|
||||
for _, itemname in ipairs(itemstacks) do
|
||||
if itemname ~= n0.name then
|
||||
local p_drop = {
|
||||
x = p0.x - 0.5 + math.random(),
|
||||
y = p0.y - 0.5 + math.random(),
|
||||
z = p0.z - 0.5 + math.random(),
|
||||
}
|
||||
minetest.env:add_item(p_drop, itemname)
|
||||
end
|
||||
end
|
||||
-- Remove node
|
||||
minetest.env:remove_node(p0)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
221
mods/default/mapgen.lua
Normal file
@ -0,0 +1,221 @@
|
||||
-- minetest/default/mapgen.lua
|
||||
|
||||
--
|
||||
-- Aliases for map generator outputs
|
||||
--
|
||||
|
||||
minetest.register_alias("mapgen_air", "air")
|
||||
minetest.register_alias("mapgen_stone", "default:stone")
|
||||
minetest.register_alias("mapgen_tree", "default:tree")
|
||||
minetest.register_alias("mapgen_leaves", "default:leaves")
|
||||
minetest.register_alias("mapgen_apple", "default:apple")
|
||||
minetest.register_alias("mapgen_water_source", "default:water_source")
|
||||
minetest.register_alias("mapgen_dirt", "default:dirt")
|
||||
minetest.register_alias("mapgen_sand", "default:sand")
|
||||
minetest.register_alias("mapgen_gravel", "default:gravel")
|
||||
minetest.register_alias("mapgen_clay", "default:clay")
|
||||
minetest.register_alias("mapgen_lava_source", "default:lava_source")
|
||||
minetest.register_alias("mapgen_cobble", "default:cobble")
|
||||
minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
|
||||
minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
|
||||
minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
|
||||
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
|
||||
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
||||
minetest.register_alias("mapgen_mese", "default:mese")
|
||||
minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
|
||||
minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
|
||||
|
||||
--
|
||||
-- Ore generation
|
||||
--
|
||||
|
||||
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local chunk_size = 3
|
||||
if ore_per_chunk <= 4 then
|
||||
chunk_size = 2
|
||||
end
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print("generate_ore done")
|
||||
end
|
||||
|
||||
function default.make_papyrus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:papyrus"})
|
||||
end
|
||||
end
|
||||
|
||||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:cactus"})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17)
|
||||
if maxp.y >= 2 and minp.y <= 0 then
|
||||
-- Generate clay
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 4
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0+1,divs-1-1 do
|
||||
for divz=0+1,divs-1-1 do
|
||||
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
||||
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
||||
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||
local is_shallow = true
|
||||
local num_water_around = 0
|
||||
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if num_water_around >= 2 then
|
||||
is_shallow = false
|
||||
end
|
||||
if is_shallow then
|
||||
for x1=-divlen,divlen do
|
||||
for z1=-divlen,divlen do
|
||||
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" then
|
||||
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate papyrus
|
||||
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 8
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine papyrus amount from perlin noise
|
||||
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
|
||||
-- Find random positions for papyrus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,papyrus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate cactuses
|
||||
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate dry shrubs
|
||||
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 763 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 682 B |
BIN
mods/default/textures/default_chest_front.png
Normal file → Executable file
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 769 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 871 B |
BIN
mods/default/textures/default_chest_side.png
Normal file → Executable file
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 714 B |
BIN
mods/default/textures/default_chest_top.png
Normal file → Executable file
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 628 B |
BIN
mods/default/textures/default_cobble.png
Normal file → Executable file
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 744 B |
BIN
mods/default/textures/default_desert_sand.png
Normal file
After Width: | Height: | Size: 627 B |
BIN
mods/default/textures/default_desert_stone.png
Normal file
After Width: | Height: | Size: 517 B |
BIN
mods/default/textures/default_dirt.png
Normal file → Executable file
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 888 B |
BIN
mods/default/textures/default_dry_shrub.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
mods/default/textures/default_grass.png
Normal file → Executable file
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 794 B |
BIN
mods/default/textures/default_grass_side.png
Normal file → Executable file
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 925 B |
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 751 B |
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 772 B |
BIN
mods/default/textures/default_leaves.png
Normal file → Executable file
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 299 B |
BIN
mods/default/textures/default_mossycobble.png
Normal file → Executable file
Before Width: | Height: | Size: 965 B After Width: | Height: | Size: 988 B |
BIN
mods/default/textures/default_sand.png
Normal file → Executable file
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 732 B |
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 358 B |
BIN
mods/default/textures/default_sign_wall.png
Normal file → Executable file
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 617 B |
BIN
mods/default/textures/default_stone.png
Normal file → Executable file
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 558 B |
BIN
mods/default/textures/default_tool_mesepick.png
Normal file → Executable file
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 341 B |
BIN
mods/default/textures/default_tool_steelpick.png
Normal file → Executable file
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 322 B |
0
mods/default/textures/default_tool_steelshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
BIN
mods/default/textures/default_tool_steelsword.png
Normal file → Executable file
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 306 B |
BIN
mods/default/textures/default_tool_stonepick.png
Normal file → Executable file
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 365 B |
0
mods/default/textures/default_tool_stoneshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
BIN
mods/default/textures/default_tool_woodpick.png
Normal file → Executable file
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 307 B |
0
mods/default/textures/default_tool_woodshovel.png
Normal file → Executable file
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 925 B After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 913 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 232 B |
BIN
mods/default/textures/default_tree.png
Normal file → Executable file
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 706 B |
BIN
mods/default/textures/default_tree_top.png
Normal file → Executable file
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 843 B |
BIN
mods/default/textures/default_water.png
Normal file → Executable file
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 387 B |
43
mods/doors/README.txt
Normal file
@ -0,0 +1,43 @@
|
||||
Minetest 0.4 mod: doors
|
||||
========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Original license text:
|
||||
-- (c) 2011 Fernando Zapata
|
||||
-- Code licensed under GNU GPLv3
|
||||
-- Content licensed under CC BY-SA 3.0
|
||||
-- 2012-01-08 11:03:57
|
||||
|
||||
There has been unsuccesful attempts to contact the original author. Thus,
|
||||
based on the intentions of the author, it is assumed that this code is
|
||||
distributable and modifiable under GPLv2+later, under which Minetest is
|
||||
distributed.
|
||||
|
||||
Modifications:
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
From the original zlpdoors mod by Fernando Zapata:
|
||||
door_wood_a.png
|
||||
door_wood_a_r.png
|
||||
door_wood_b.png
|
||||
door_wood_b_r.png
|
||||
door_wood.png
|
||||
|
@ -1,2 +1 @@
|
||||
default
|
||||
|
205
mods/doors/init.lua
Normal file
@ -0,0 +1,205 @@
|
||||
-- Minetest 0.4 mod: doors
|
||||
-- See README.txt for licensing and other information.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local WALLMX = 3
|
||||
local WALLMZ = 5
|
||||
local WALLPX = 2
|
||||
local WALLPZ = 4
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_alias('door', 'doors:door_wood')
|
||||
minetest.register_alias('door_wood', 'doors:door_wood')
|
||||
|
||||
minetest.register_node( 'doors:door_wood', {
|
||||
description = 'Wooden Door',
|
||||
drawtype = 'signlike',
|
||||
tile_images = { 'door_wood.png' },
|
||||
inventory_image = 'door_wood.png',
|
||||
wield_image = 'door_wood.png',
|
||||
paramtype2 = 'wallmounted',
|
||||
selection_box = { type = 'wallmounted' },
|
||||
groups = { choppy=2, dig_immediate=2 },
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = 'doors:door_wood',
|
||||
recipe = {
|
||||
{ 'default:wood', 'default:wood' },
|
||||
{ 'default:wood', 'default:wood' },
|
||||
{ 'default:wood', 'default:wood' },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'fuel',
|
||||
recipe = 'doors:door_wood',
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_node( 'doors:door_wood_a_c', {
|
||||
Description = 'Top Closed Door',
|
||||
drawtype = 'signlike',
|
||||
tile_images = { 'door_wood_a.png' },
|
||||
inventory_image = 'door_wood_a.png',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'wallmounted',
|
||||
walkable = true,
|
||||
selection_box = { type = "wallmounted", },
|
||||
groups = { choppy=2, dig_immediate=2 },
|
||||
legacy_wallmounted = true,
|
||||
drop = 'doors:door_wood',
|
||||
})
|
||||
|
||||
minetest.register_node( 'doors:door_wood_b_c', {
|
||||
Description = 'Bottom Closed Door',
|
||||
drawtype = 'signlike',
|
||||
tile_images = { 'door_wood_b.png' },
|
||||
inventory_image = 'door_wood_b.png',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'wallmounted',
|
||||
walkable = true,
|
||||
selection_box = { type = "wallmounted", },
|
||||
groups = { choppy=2, dig_immediate=2 },
|
||||
legacy_wallmounted = true,
|
||||
drop = 'doors:door_wood',
|
||||
})
|
||||
|
||||
minetest.register_node( 'doors:door_wood_a_o', {
|
||||
Description = 'Top Open Door',
|
||||
drawtype = 'signlike',
|
||||
tile_images = { 'door_wood_a_r.png' },
|
||||
inventory_image = 'door_wood_a_r.png',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'wallmounted',
|
||||
walkable = false,
|
||||
selection_box = { type = "wallmounted", },
|
||||
groups = { choppy=2, dig_immediate=2 },
|
||||
legacy_wallmounted = true,
|
||||
drop = 'doors:door_wood',
|
||||
})
|
||||
|
||||
minetest.register_node( 'doors:door_wood_b_o', {
|
||||
Description = 'Bottom Open Door',
|
||||
drawtype = 'signlike',
|
||||
tile_images = { 'door_wood_b_r.png' },
|
||||
inventory_image = 'door_wood_b_r.png',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'wallmounted',
|
||||
walkable = false,
|
||||
selection_box = { type = "wallmounted", },
|
||||
groups = { choppy=2, dig_immediate=2 },
|
||||
legacy_wallmounted = true,
|
||||
drop = 'doors:door_wood',
|
||||
})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local round = function( n )
|
||||
if n >= 0 then
|
||||
return math.floor( n + 0.5 )
|
||||
else
|
||||
return math.ceil( n - 0.5 )
|
||||
end
|
||||
end
|
||||
|
||||
local on_door_placed = function( pos, node, placer )
|
||||
if node.name ~= 'doors:door_wood' then return end
|
||||
|
||||
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||
und = minetest.env:get_node( upos )
|
||||
abv = minetest.env:get_node( apos )
|
||||
|
||||
dir = placer:get_look_dir()
|
||||
|
||||
if round( dir.x ) == 1 then
|
||||
newparam = WALLMX
|
||||
elseif round( dir.x ) == -1 then
|
||||
newparam = WALLPX
|
||||
elseif round( dir.z ) == 1 then
|
||||
newparam = WALLMZ
|
||||
elseif round( dir.z ) == -1 then
|
||||
newparam = WALLPZ
|
||||
end
|
||||
|
||||
if und.name == 'air' then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||
minetest.env:add_node( upos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||
elseif abv.name == 'air' then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||
minetest.env:add_node( apos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||
else
|
||||
minetest.env:remove_node( pos )
|
||||
placer:get_inventory():add_item( "main", 'doors:door_wood' )
|
||||
minetest.chat_send_player( placer:get_player_name(), 'not enough space' )
|
||||
end
|
||||
end
|
||||
|
||||
local on_door_punched = function( pos, node, puncher )
|
||||
if string.find( node.name, 'doors:door_wood' ) == nil then return end
|
||||
|
||||
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||
|
||||
if string.find( node.name, '_c', -2 ) ~= nil then
|
||||
if node.param2 == WALLPX then
|
||||
newparam = WALLMZ
|
||||
elseif node.param2 == WALLMZ then
|
||||
newparam = WALLMX
|
||||
elseif node.param2 == WALLMX then
|
||||
newparam = WALLPZ
|
||||
elseif node.param2 == WALLPZ then
|
||||
newparam = WALLPX
|
||||
end
|
||||
elseif string.find( node.name, '_o', -2 ) ~= nil then
|
||||
if node.param2 == WALLMZ then
|
||||
newparam = WALLPX
|
||||
elseif node.param2 == WALLMX then
|
||||
newparam = WALLMZ
|
||||
elseif node.param2 == WALLPZ then
|
||||
newparam = WALLMX
|
||||
elseif node.param2 == WALLPX then
|
||||
newparam = WALLPZ
|
||||
end
|
||||
end
|
||||
|
||||
if ( node.name == 'doors:door_wood_a_c' ) then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_a_o', param2 = newparam } )
|
||||
minetest.env:add_node( upos, { name = 'doors:door_wood_b_o', param2 = newparam } )
|
||||
|
||||
elseif ( node.name == 'doors:door_wood_b_c' ) then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_b_o', param2 = newparam } )
|
||||
minetest.env:add_node( apos, { name = 'doors:door_wood_a_o', param2 = newparam } )
|
||||
|
||||
elseif ( node.name == 'doors:door_wood_a_o' ) then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||
minetest.env:add_node( upos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||
|
||||
elseif ( node.name == 'doors:door_wood_b_o' ) then
|
||||
minetest.env:add_node( pos, { name = 'doors:door_wood_b_c', param2 = newparam } )
|
||||
minetest.env:add_node( apos, { name = 'doors:door_wood_a_c', param2 = newparam } )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local on_door_digged = function( pos, node, digger )
|
||||
upos = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||
apos = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||
|
||||
if ( node.name == 'doors:door_wood_a_c' ) or ( node.name == 'doors:door_wood_a_o' ) then
|
||||
minetest.env:remove_node( upos )
|
||||
elseif ( node.name == 'doors:door_wood_b_c' ) or ( node.name == 'doors:door_wood_b_o' ) then
|
||||
minetest.env:remove_node( apos )
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_on_placenode( on_door_placed )
|
||||
minetest.register_on_punchnode( on_door_punched )
|
||||
minetest.register_on_dignode( on_door_digged )
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
BIN
mods/doors/textures/door_wood.png
Normal file
After Width: | Height: | Size: 166 B |
BIN
mods/doors/textures/door_wood_a.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
mods/doors/textures/door_wood_a_r.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
mods/doors/textures/door_wood_b.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
mods/doors/textures/door_wood_b_r.png
Normal file
After Width: | Height: | Size: 216 B |
@ -1,652 +0,0 @@
|
||||
--
|
||||
-- Experimental things
|
||||
--
|
||||
|
||||
-- For testing random stuff
|
||||
|
||||
experimental = {}
|
||||
|
||||
timers_to_add = {}
|
||||
timers = {}
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for indes, timer in ipairs(timers_to_add) do
|
||||
table.insert(timers, timer)
|
||||
end
|
||||
timers_to_add = {}
|
||||
for index, timer in ipairs(timers) do
|
||||
timer.time = timer.time - dtime
|
||||
if timer.time <= 0 then
|
||||
timer.func()
|
||||
timers[index] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
after = function(time, func)
|
||||
table.insert(timers_to_add, {time=time, func=func})
|
||||
end
|
||||
|
||||
--[[
|
||||
stepsound = -1
|
||||
function test_sound()
|
||||
print("test_sound")
|
||||
stepsound = minetest.sound_play("default_grass_footstep", {gain=1.0})
|
||||
after(2.0, test_sound)
|
||||
--after(0.1, test_sound_stop)
|
||||
end
|
||||
function test_sound_stop()
|
||||
print("test_sound_stop")
|
||||
minetest.sound_stop(stepsound)
|
||||
after(2.0, test_sound)
|
||||
end
|
||||
test_sound()
|
||||
--]]
|
||||
|
||||
function on_step(dtime)
|
||||
-- print("experimental on_step")
|
||||
--[[
|
||||
objs = minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 10)
|
||||
for k, obj in pairs(objs) do
|
||||
name = obj:get_player_name()
|
||||
if name then
|
||||
print(name.." at "..dump(obj:getpos()))
|
||||
print(name.." dir: "..dump(obj:get_look_dir()))
|
||||
print(name.." pitch: "..dump(obj:get_look_pitch()))
|
||||
print(name.." yaw: "..dump(obj:get_look_yaw()))
|
||||
else
|
||||
print("Some object at "..dump(obj:getpos()))
|
||||
end
|
||||
end
|
||||
--]]
|
||||
--[[
|
||||
if experimental.t1 == nil then
|
||||
experimental.t1 = 0
|
||||
end
|
||||
experimental.t1 = experimental.t1 + dtime
|
||||
if experimental.t1 >= 2 then
|
||||
experimental.t1 = experimental.t1 - 2
|
||||
minetest.log("time of day is "..minetest.env:get_timeofday())
|
||||
if experimental.day then
|
||||
minetest.log("forcing day->night")
|
||||
experimental.day = false
|
||||
minetest.env:set_timeofday(0.0)
|
||||
else
|
||||
minetest.log("forcing night->day")
|
||||
experimental.day = true
|
||||
minetest.env:set_timeofday(0.5)
|
||||
end
|
||||
minetest.log("time of day is "..minetest.env:get_timeofday())
|
||||
end
|
||||
--]]
|
||||
end
|
||||
minetest.register_globalstep(on_step)
|
||||
|
||||
-- An example furnace-thing implemented in Lua
|
||||
|
||||
--[[
|
||||
minetest.register_node("experimental:luafurnace", {
|
||||
tile_images = {"default_lava.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_front.png"},
|
||||
--inventory_image = "furnace_front.png",
|
||||
inventory_image = minetest.inventorycube("default_furnace_front.png"),
|
||||
paramtype = "facedir_simple",
|
||||
metadata_name = "generic",
|
||||
material = minetest.digprop_stonelike(3.0),
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
if newnode.name == "experimental:luafurnace" then
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:inventory_set_list("fuel", {""})
|
||||
meta:inventory_set_list("src", {""})
|
||||
meta:inventory_set_list("dst", {"","","",""})
|
||||
meta:set_inventory_draw_spec(
|
||||
"invsize[8,9;]"
|
||||
.."list[current_name;fuel;2,3;1,1;]"
|
||||
.."list[current_name;src;2,1;1,1;]"
|
||||
.."list[current_name;dst;5,1;2,2;]"
|
||||
.."list[current_player;main;0,5;8,4;]"
|
||||
)
|
||||
|
||||
local total_cooked = 0;
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
for i, name in ipairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"
|
||||
}) do
|
||||
if not meta:get_string(name) then
|
||||
meta:set_string(name, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
--print("fuelitem="..dump(fuelitem))
|
||||
--print("srcitem="..dump(srcitem))
|
||||
|
||||
local was_active = false
|
||||
|
||||
local src_cooktime = -1
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
print("src_cooktime="..dump(src_cooktime))
|
||||
print("result_stackstring="..dump(result_stackstring))
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
was_active = true
|
||||
meta:set_string("fuel_time", tonumber(meta:get_string("fuel_time")) + 1)
|
||||
meta:set_string("src_time", tonumber(meta:get_string("src_time")) + 1)
|
||||
--print("result_stackstring="..dump(result_stackstring))
|
||||
--print('tonumber(meta:get_string("src_time"))='..dump(tonumber(meta:get_string("src_time"))))
|
||||
--print("src_cooktime="..dump(src_cooktime))
|
||||
if result_stackstring and tonumber(meta:get_string("src_time")) >= src_cooktime and src_cooktime >= 0 then
|
||||
-- Put result in "dst" list
|
||||
success = inv:autoinsert_stackstring("dst", result_stackstring)
|
||||
if not success then
|
||||
print("Could not autoinsert '"..result_stackstring.."'")
|
||||
end
|
||||
-- If succeeded, take stuff from "src" list
|
||||
if success then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
meta:set_infotext("Furnace active: "..(tonumber(meta:get_string("fuel_time"))/tonumber(meta:get_string("fuel_totaltime"))*100).."%")
|
||||
return
|
||||
end
|
||||
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
|
||||
local src_cooktime = 0
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
|
||||
if not result_stackstring or not fuelitem then
|
||||
if was_active then
|
||||
meta:set_infotext("Furnace is empty")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local burntime = -1
|
||||
if fuelitem then
|
||||
local prop = get_item_definition(fuelitem)
|
||||
if prop then
|
||||
burntime = prop.furnace_burntime or -1
|
||||
end
|
||||
end
|
||||
|
||||
if burntime <= 0 then
|
||||
meta:set_infotext("Furnace out of fuel")
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", burntime)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local fuellist = meta:inventory_get_list("fuel")
|
||||
local srclist = meta:inventory_get_list("src")
|
||||
local dstlist = meta:inventory_get_list("dst")
|
||||
if fuellist == nil or srclist == nil or dstlist == nil then
|
||||
return
|
||||
end
|
||||
_, srcitem = stackstring_take_item(srclist[1])
|
||||
_, fuelitem = stackstring_take_item(fuellist[1])
|
||||
if not srcitem or not fuelitem then return end
|
||||
if fuelitem.type == "node" then
|
||||
local prop = minetest.registered_nodes[fuelitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.furnace_burntime < 0 then return end
|
||||
else
|
||||
return
|
||||
end
|
||||
local resultstack = nil
|
||||
if srcitem.type == "node" then
|
||||
local prop = minetest.registered_nodes[srcitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.cookresult_item == "" then return end
|
||||
resultstack = prop.cookresult_item
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if resultstack == nil then
|
||||
return
|
||||
end
|
||||
|
||||
dstlist[1], success = stackstring_put_stackstring(dstlist[1], resultstack)
|
||||
if not success then
|
||||
return
|
||||
end
|
||||
|
||||
fuellist[1], _ = stackstring_take_item(fuellist[1])
|
||||
srclist[1], _ = stackstring_take_item(srclist[1])
|
||||
|
||||
meta:inventory_set_list("fuel", fuellist)
|
||||
meta:inventory_set_list("src", srclist)
|
||||
meta:inventory_set_list("dst", dstlist)
|
||||
|
||||
local total_cooked = meta:get_string("total_cooked")
|
||||
total_cooked = tonumber(total_cooked) + 1
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = 'node "experimental:luafurnace" 1',
|
||||
recipe = {
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:steel_ingot"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
}
|
||||
})
|
||||
--]]
|
||||
|
||||
--
|
||||
-- Random stuff
|
||||
--
|
||||
|
||||
--[[
|
||||
minetest.register_tool("experimental:horribletool", {
|
||||
image = "default_lava.png",
|
||||
basetime = 2.0
|
||||
dt_weight = 0.2
|
||||
dt_crackiness = 0.2
|
||||
dt_crumbliness = 0.2
|
||||
dt_cuttability = 0.2
|
||||
basedurability = 50
|
||||
dd_weight = -5
|
||||
dd_crackiness = -5
|
||||
dd_crumbliness = -5
|
||||
dd_cuttability = -5
|
||||
})
|
||||
--]]
|
||||
|
||||
--
|
||||
-- TNT (not functional)
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'experimental:tnt',
|
||||
recipe = {
|
||||
{'default:wood'},
|
||||
{'default:coal_lump'},
|
||||
{'default:wood'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("experimental:tnt", {
|
||||
tile_images = {"default_tnt_top.png", "default_tnt_bottom.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"},
|
||||
inventory_image = minetest.inventorycube("default_tnt_top.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"),
|
||||
drop = '', -- Get nothing
|
||||
material = {
|
||||
diggability = "not",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_on_punchnode(function(p, node)
|
||||
if node.name == "experimental:tnt" then
|
||||
minetest.env:remove_node(p)
|
||||
minetest.env:add_entity(p, "experimental:tnt")
|
||||
nodeupdate(p)
|
||||
end
|
||||
end)
|
||||
|
||||
local TNT = {
|
||||
-- Static definition
|
||||
physical = true, -- Collides with things
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
textures = {"default_tnt_top.png", "default_tnt_bottom.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"},
|
||||
-- Initial value for our timer
|
||||
timer = 0,
|
||||
-- Number of punches required to defuse
|
||||
health = 1,
|
||||
blinktimer = 0,
|
||||
blinkstatus = true,
|
||||
}
|
||||
|
||||
-- Called when a TNT object is created
|
||||
function TNT:on_activate(staticdata)
|
||||
print("TNT:on_activate()")
|
||||
self.object:setvelocity({x=0, y=4, z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.object:settexturemod("^[brighten")
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
end
|
||||
|
||||
-- Called periodically
|
||||
function TNT:on_step(dtime)
|
||||
--print("TNT:on_step()")
|
||||
self.timer = self.timer + dtime
|
||||
self.blinktimer = self.blinktimer + dtime
|
||||
if self.blinktimer > 0.5 then
|
||||
self.blinktimer = self.blinktimer - 0.5
|
||||
if self.blinkstatus then
|
||||
self.object:settexturemod("")
|
||||
else
|
||||
self.object:settexturemod("^[brighten")
|
||||
end
|
||||
self.blinkstatus = not self.blinkstatus
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when object is punched
|
||||
function TNT:on_punch(hitter)
|
||||
print("TNT:on_punch()")
|
||||
self.health = self.health - 1
|
||||
if self.health <= 0 then
|
||||
self.object:remove()
|
||||
hitter:get_inventory():add_item("main", "experimental:tnt")
|
||||
--hitter:set_hp(hitter:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when object is right-clicked
|
||||
function TNT:on_rightclick(clicker)
|
||||
--pos = self.object:getpos()
|
||||
--pos = {x=pos.x, y=pos.y+0.1, z=pos.z}
|
||||
--self.object:moveto(pos, false)
|
||||
end
|
||||
|
||||
--print("TNT dump: "..dump(TNT))
|
||||
--print("Registering TNT");
|
||||
minetest.register_entity("experimental:tnt", TNT)
|
||||
|
||||
-- Add TNT's old name also
|
||||
minetest.register_alias("TNT", "experimental:tnt")
|
||||
|
||||
--
|
||||
-- The dummyball!
|
||||
--
|
||||
|
||||
minetest.register_entity("experimental:dummyball", {
|
||||
-- Static definition
|
||||
hp_max = 20,
|
||||
physical = false,
|
||||
collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
|
||||
visual = "sprite",
|
||||
visual_size = {x=1, y=1},
|
||||
textures = {"experimental_dummyball.png"},
|
||||
spritediv = {x=1, y=3},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
-- Dynamic variables
|
||||
phase = 0,
|
||||
phasetimer = 0,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
minetest.log("Dummyball activated!")
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.phasetimer = self.phasetimer + dtime
|
||||
if self.phasetimer > 2.0 then
|
||||
self.phasetimer = self.phasetimer - 2.0
|
||||
self.phase = self.phase + 1
|
||||
if self.phase >= 3 then
|
||||
self.phase = 0
|
||||
end
|
||||
self.object:setsprite({x=0, y=self.phase})
|
||||
phasearmor = {
|
||||
[0]={cracky=3},
|
||||
[1]={crumbly=3},
|
||||
[2]={fleshy=3}
|
||||
}
|
||||
self.object:set_armor_groups(phasearmor[self.phase])
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
local cmd = "/dummyball"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
if not minetest.get_player_privs(name)["give"] then
|
||||
minetest.chat_send_player(name, "you don't have permission to spawn (give)")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
if not minetest.get_player_privs(name)["interact"] then
|
||||
minetest.chat_send_player(name, "you don't have permission to interact")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
if player == nil then
|
||||
print("Unable to spawn entity, player is nil")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local entityname = "experimental:dummyball"
|
||||
local p = player:getpos()
|
||||
p.y = p.y + 1
|
||||
minetest.env:add_entity(p, entityname)
|
||||
minetest.chat_send_player(name, '"'..entityname
|
||||
..'" spawned.');
|
||||
return true -- Handled chat message
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- A test entity for testing animated and yaw-modulated sprites
|
||||
--
|
||||
|
||||
minetest.register_entity("experimental:testentity", {
|
||||
-- Static definition
|
||||
physical = true, -- Collides with things
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7},
|
||||
--collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "sprite",
|
||||
visual_size = {x=2, y=3},
|
||||
textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
|
||||
spritediv = {x=6, y=5},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
print("testentity.on_activate")
|
||||
self.object:setsprite({x=0,y=0}, 1, 0, true)
|
||||
--self.object:setsprite({x=0,y=0}, 4, 0.3, true)
|
||||
|
||||
-- Set gravity
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
-- Jump a bit upwards
|
||||
self.object:setvelocity({x=0, y=10, z=0})
|
||||
end,
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
hitter:add_to_inventory('craft testobject1 1')
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- More random stuff
|
||||
--
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
print("on_respawnplayer")
|
||||
-- player:setpos({x=0, y=30, z=0})
|
||||
-- return true
|
||||
end)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp)
|
||||
--print("on_generated: minp="..dump(minp).." maxp="..dump(maxp))
|
||||
--cp = {x=(minp.x+maxp.x)/2, y=(minp.y+maxp.y)/2, z=(minp.z+maxp.z)/2}
|
||||
--minetest.env:add_node(cp, {name="sand"})
|
||||
end)
|
||||
|
||||
-- Example setting get
|
||||
--print("setting max_users = " .. dump(minetest.setting_get("max_users")))
|
||||
--print("setting asdf = " .. dump(minetest.setting_get("asdf")))
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
--[[print("on_chat_message: name="..dump(name).." message="..dump(message))
|
||||
local cmd = "/testcommand"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
print(cmd.." invoked")
|
||||
return true
|
||||
end
|
||||
local cmd = "/help"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
print("script-overridden help command")
|
||||
minetest.chat_send_all("script-overridden help command")
|
||||
return true
|
||||
end]]
|
||||
end)
|
||||
|
||||
-- Grow papyrus on TNT every 10 seconds
|
||||
--[[minetest.register_abm({
|
||||
nodenames = {"TNT"},
|
||||
interval = 10.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
print("TNT ABM action")
|
||||
pos.y = pos.y + 1
|
||||
minetest.env:add_node(pos, {name="papyrus"})
|
||||
end,
|
||||
})]]
|
||||
|
||||
-- Replace texts of alls signs with "foo" every 10 seconds
|
||||
--[[minetest.register_abm({
|
||||
nodenames = {"sign_wall"},
|
||||
interval = 10.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
print("ABM: Sign text changed")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_text("foo")
|
||||
end,
|
||||
})]]
|
||||
|
||||
--[[local ncpos = nil
|
||||
local ncq = 1
|
||||
local ncstuff = {
|
||||
{2, 1, 0, 3}, {3, 0, 1, 2}, {4, -1, 0, 1}, {5, -1, 0, 1}, {6, 0, -1, 0},
|
||||
{7, 0, -1, 0}, {8, 1, 0, 3}, {9, 1, 0, 3}, {10, 1, 0, 3}, {11, 0, 1, 2},
|
||||
{12, 0, 1, 2}, {13, 0, 1, 2}, {14, -1, 0, 1}, {15, -1, 0, 1}, {16, -1, 0, 1},
|
||||
{17, -1, 0, 1}, {18, 0, -1, 0}, {19, 0, -1, 0}, {20, 0, -1, 0}, {21, 0, -1, 0},
|
||||
{22, 1, 0, 3}, {23, 1, 0, 3}, {24, 1, 0, 3}, {25, 1, 0, 3}, {10, 0, 1, 2}
|
||||
}
|
||||
local ncold = {}
|
||||
local nctime = nil
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"dirt_with_grass"},
|
||||
interval = 100000.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if ncpos ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
if pos.x % 16 ~= 8 or pos.z % 16 ~= 8 then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 1
|
||||
n = minetest.env:get_node(pos)
|
||||
print(dump(n))
|
||||
if n.name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 2
|
||||
ncpos = pos
|
||||
nctime = os.clock()
|
||||
minetest.env:add_node(ncpos, {name="nyancat"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"nyancat"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if ncpos == nil then
|
||||
return
|
||||
end
|
||||
if pos.x == ncpos.x and pos.y == ncpos.y and pos.z == ncpos.z then
|
||||
clock = os.clock()
|
||||
if clock - nctime < 0.1 then
|
||||
return
|
||||
end
|
||||
nctime = clock
|
||||
|
||||
s0 = ncstuff[ncq]
|
||||
ncq = s0[1]
|
||||
s1 = ncstuff[ncq]
|
||||
p0 = pos
|
||||
p1 = {x = p0.x + s0[2], y = p0.y, z = p0.z + s0[3]}
|
||||
p2 = {x = p1.x + s1[2], y = p1.y, z = p1.z + s1[3]}
|
||||
table.insert(ncold, 1, p0)
|
||||
while #ncold >= 10 do
|
||||
minetest.env:add_node(ncold[#ncold], {name="air"})
|
||||
table.remove(ncold, #ncold)
|
||||
end
|
||||
minetest.env:add_node(p0, {name="nyancat_rainbow"})
|
||||
minetest.env:add_node(p1, {name="nyancat", param1=s0[4]})
|
||||
minetest.env:add_node(p2, {name="air"})
|
||||
ncpos = p1
|
||||
end
|
||||
end,
|
||||
})--]]
|
||||
|
||||
minetest.log("experimental modname="..dump(minetest.get_current_modname()))
|
||||
minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
||||
minetest.log("experimental worldpath="..dump(minetest.get_worldpath()))
|
||||
|
||||
-- END
|
Before Width: | Height: | Size: 838 B |
30
mods/fire/README.txt
Normal file
@ -0,0 +1,30 @@
|
||||
Minetest 0.4 mod: fire
|
||||
======================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
|
||||
fire_small.ogg sampled from:
|
||||
http://www.freesound.org/people/dobroide/sounds/4211/
|
||||
|
||||
fire_large.ogg sampled from:
|
||||
http://www.freesound.org/people/Dynamicell/sounds/17548/
|
||||
|
188
mods/fire/init.lua
Normal file
@ -0,0 +1,188 @@
|
||||
-- minetest/fire/init.lua
|
||||
|
||||
minetest.register_node("fire:basic_flame", {
|
||||
description = "Fire",
|
||||
drawtype = "glasslike",
|
||||
tile_images = {"fire_basic_flame.png"},
|
||||
light_source = 14,
|
||||
groups = {igniter=3,dig_immediate=3},
|
||||
drop = '',
|
||||
walkable = false,
|
||||
})
|
||||
|
||||
local fire = {}
|
||||
fire.D = 6
|
||||
-- key: position hash of low corner of area
|
||||
-- value: {handle=sound handle, name=sound name}
|
||||
fire.sounds = {}
|
||||
|
||||
function fire.get_area_p0p1(pos)
|
||||
local p0 = {
|
||||
x=math.floor(pos.x/fire.D)*fire.D,
|
||||
y=math.floor(pos.y/fire.D)*fire.D,
|
||||
z=math.floor(pos.z/fire.D)*fire.D,
|
||||
}
|
||||
local p1 = {
|
||||
x=p0.x+fire.D-1,
|
||||
y=p0.y+fire.D-1,
|
||||
z=p0.z+fire.D-1
|
||||
}
|
||||
return p0, p1
|
||||
end
|
||||
|
||||
function fire.update_sounds_around(pos)
|
||||
local p0, p1 = fire.get_area_p0p1(pos)
|
||||
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
||||
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||
local should_have_sound = (#flames_p > 0)
|
||||
local wanted_sound = nil
|
||||
if #flames_p >= 9 then
|
||||
wanted_sound = {name="fire_large", gain=1.5}
|
||||
elseif #flames_p > 0 then
|
||||
wanted_sound = {name="fire_small", gain=1.5}
|
||||
end
|
||||
local p0_hash = minetest.hash_node_position(p0)
|
||||
local sound = fire.sounds[p0_hash]
|
||||
if not sound then
|
||||
if should_have_sound then
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
else
|
||||
if not wanted_sound then
|
||||
minetest.sound_stop(sound.handle)
|
||||
fire.sounds[p0_hash] = nil
|
||||
elseif sound.name ~= wanted_sound.name then
|
||||
minetest.sound_stop(sound.handle)
|
||||
fire.sounds[p0_hash] = {
|
||||
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
|
||||
name = wanted_sound.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function fire.on_flame_add_at(pos)
|
||||
--print("flame added at "..minetest.pos_to_string(pos))
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
function fire.on_flame_remove_at(pos)
|
||||
--print("flame removed at "..minetest.pos_to_string(pos))
|
||||
fire.update_sounds_around(pos)
|
||||
end
|
||||
|
||||
function fire.find_pos_for_flame_around(pos)
|
||||
return minetest.env:find_node_near(pos, 1, {"air"})
|
||||
end
|
||||
|
||||
function fire.flame_should_extinguish(pos)
|
||||
--return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
||||
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||
local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
||||
return (#ps ~= 0)
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
if newnode.name == "fire:basic_flame" then
|
||||
fire.on_flame_add_at(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if oldnode.name == "fire:basic_flame" then
|
||||
fire.on_flame_remove_at(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Ignite neighboring nodes
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flammable"},
|
||||
neighbors = {"group:igniter"},
|
||||
interval = 1,
|
||||
chance = 2,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around flame, don't ignite
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
local p = fire.find_pos_for_flame_around(p0)
|
||||
if p then
|
||||
minetest.env:set_node(p, {name="fire:basic_flame"})
|
||||
fire.on_flame_add_at(p)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Rarely ignite things from far
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:igniter"},
|
||||
neighbors = {"air"},
|
||||
interval = 2,
|
||||
chance = 10,
|
||||
action = function(p0, node, _, _)
|
||||
local reg = minetest.registered_nodes[node.name]
|
||||
if not reg or not reg.groups.igniter or reg.groups.igniter < 2 then
|
||||
return
|
||||
end
|
||||
local d = reg.groups.igniter
|
||||
local p = minetest.env:find_node_near(p0, d, {"group:flammable"})
|
||||
if p then
|
||||
-- If there is water or stuff like that around flame, don't ignite
|
||||
if fire.flame_should_extinguish(p) then
|
||||
return
|
||||
end
|
||||
local p2 = fire.find_pos_for_flame_around(p)
|
||||
if p2 then
|
||||
minetest.env:set_node(p2, {name="fire:basic_flame"})
|
||||
fire.on_flame_add_at(p2)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Remove flammable nodes and flame
|
||||
minetest.register_abm({
|
||||
nodenames = {"fire:basic_flame"},
|
||||
interval = 1,
|
||||
chance = 2,
|
||||
action = function(p0, node, _, _)
|
||||
-- If there is water or stuff like that around flame, remove flame
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
minetest.env:remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
return
|
||||
end
|
||||
-- Make the following things rarer
|
||||
if math.random(1,3) == 1 then
|
||||
return
|
||||
end
|
||||
-- If there are no flammable nodes around flame, remove flame
|
||||
if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then
|
||||
minetest.env:remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
return
|
||||
end
|
||||
if math.random(1,4) == 1 then
|
||||
-- remove a flammable node around flame
|
||||
local p = minetest.env:find_node_near(p0, 1, {"group:flammable"})
|
||||
if p then
|
||||
-- If there is water or stuff like that around flame, don't remove
|
||||
if fire.flame_should_extinguish(p0) then
|
||||
return
|
||||
end
|
||||
minetest.env:remove_node(p)
|
||||
end
|
||||
else
|
||||
-- remove flame
|
||||
minetest.env:remove_node(p0)
|
||||
fire.on_flame_remove_at(p0)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
BIN
mods/fire/sounds/fire_large.ogg
Normal file
BIN
mods/fire/sounds/fire_small.ogg
Normal file
BIN
mods/fire/textures/fire_basic_flame.png
Normal file
After Width: | Height: | Size: 847 B |