summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorh-v-smacker <hans-von-smacker+github@gmail.com>2018-04-29 23:14:13 +0300
committerh-v-smacker <hans-von-smacker+github@gmail.com>2018-04-29 23:14:13 +0300
commitfe0984b698e6465a0ecf2454d04bba629aeaaca0 (patch)
tree567411b517d291b62a91c55774e3c5d5b5a78dec
parent570960e24b217711979d5d29d08a9eb075de9950 (diff)
initial commit
-rw-r--r--README.md2
-rw-r--r--depends.txt1
-rw-r--r--init.lua149
-rw-r--r--schematics/maple_tree.mtsbin0 -> 237 bytes
-rw-r--r--textures/maple_fence.pngbin0 -> 325 bytes
-rw-r--r--textures/maple_leaves.pngbin0 -> 415 bytes
-rw-r--r--textures/maple_leaves_simple.pngbin0 -> 450 bytes
-rw-r--r--textures/maple_sapling.pngbin0 -> 298 bytes
-rw-r--r--textures/maple_tree.pngbin0 -> 401 bytes
-rw-r--r--textures/maple_tree_top.pngbin0 -> 731 bytes
-rw-r--r--textures/maple_wood.pngbin0 -> 313 bytes
-rw-r--r--trees.lua52
12 files changed, 204 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9811373..413ab6e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,4 @@
# maple
Maple Tree for Minetest by ExeterDad
+
+This mod adds a maple tree to the minetest game. Originally written for the Hometown server (http://hometownserver.com/) by ExeterDad (https://forum.minetest.net/memberlist.php?mode=viewprofile&u=10544) \ No newline at end of file
diff --git a/depends.txt b/depends.txt
new file mode 100644
index 0000000..4ad96d5
--- /dev/null
+++ b/depends.txt
@@ -0,0 +1 @@
+default
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..76c814c
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,149 @@
+minetest.log("Loading maple")
+maple = {}
+dofile(minetest.get_modpath("maple").."/trees.lua")
+
+minetest.register_node("maple:maple_tree", {
+ description = "Maple Tree",
+ tiles = {"maple_tree_top.png", "maple_tree_top.png", "maple_tree.png"},
+ paramtype2 = "facedir",
+ is_ground_content = false,
+ groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
+ sounds = default.node_sound_wood_defaults(),
+
+ on_place = minetest.rotate_node
+})
+
+minetest.register_node("maple:maple_wood", {
+ description = "Maple Wood Planks",
+ paramtype2 = "facedir",
+ place_param2 = 0,
+ tiles = {"maple_wood.png"},
+ is_ground_content = false,
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
+ sounds = default.node_sound_wood_defaults(),
+})
+
+minetest.register_node("maple:maple_leaves", {
+ description = "Maple Leaves",
+ drawtype = "allfaces_optional",
+ waving = 1,
+ tiles = {"maple_leaves.png"},
+ special_tiles = {"maple_leaves_simple.png"},
+ paramtype = "light",
+ is_ground_content = false,
+ groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
+ drop = {
+ max_items = 1,
+ items = {
+ {
+ -- player will get sapling with 1/20 chance
+ items = {'maple:maple_sapling'},
+ rarity = 20,
+ },
+ {
+ -- player will get leaves only if he get no saplings,
+ -- this is because max_items is 1
+ items = {'maple:maple_leaves'},
+ }
+ }
+ },
+ sounds = default.node_sound_leaves_defaults(),
+
+ after_place_node = default.after_place_leaves,
+})
+
+
+
+minetest.register_node("maple:maple_sapling", {
+ description = "Maple Sapling",
+ drawtype = "plantlike",
+ visual_scale = 1.0,
+ tiles = {"maple_sapling.png"},
+ inventory_image = "maple_sapling.png",
+ wield_image = "maple_sapling.png",
+ paramtype = "light",
+ sunlight_propagates = true,
+ walkable = false,
+ on_timer = maple.grow_sapling,
+ selection_box = {
+ type = "fixed",
+ fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
+ },
+ groups = {snappy = 2, dig_immediate = 3, flammable = 2,
+ attached_node = 1, sapling = 1},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_construct = function(pos)
+ minetest.get_node_timer(pos):start(math.random(2400,4800))
+ end,
+
+ on_place = function(itemstack, placer, pointed_thing)
+ print("Maple sapling placed.")
+ itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
+ "maple:maple_sapling",
+ -- minp, maxp to be checked, relative to sapling pos
+ -- minp_relative.y = 1 because sapling pos has been checked
+ {x = -2, y = 1, z = -2},
+ {x = 2, y = 13, z = 2},
+ -- maximum interval of interior volume check
+ 4)
+
+ return itemstack
+ end,
+})
+
+
+minetest.register_decoration({
+ deco_type = "schematic",
+ place_on = {"default:dirt_with_grass"},
+ sidelen = 16,
+ noise_params = {
+ offset = 0.0,
+ --scale = -0.015,
+ scale = 0.0007,
+ spread = {x = 250, y = 250, z = 250},
+ seed = 2,
+ octaves = 3,
+ persist = 0.66
+ },
+ biomes = {"deciduous_forest"},
+ y_min = 1,
+ y_max = 31000,
+ schematic = minetest.get_modpath("maple").."/schematics/maple_tree.mts",
+ flags = "place_center_x, place_center_z",
+})
+
+default.register_leafdecay({
+ trunks = {"maple:maple_tree"},
+ leaves = {"maple:maple_leaves"},
+ radius = 3,
+})
+
+default.register_fence("maple:fence_maple_wood", {
+ description = "Maple Fence",
+ texture = "maple_fence.png",
+ inventory_image = "default_fence_overlay.png^maple_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+ wield_image = "default_fence_overlay.png^maple_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+ material = "maple:maple_wood",
+ groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
+ sounds = default.node_sound_wood_defaults()
+})
+
+minetest.register_craft({
+ output = 'maple:maple_wood 4',
+ recipe = {
+ {'maple:maple_tree'},
+ }
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "maple:maple_sapling",
+ burntime = 12,
+})
+
+minetest.register_craft({
+ type = "fuel",
+ recipe = "maple:fence_maple_wood",
+ burntime = 8,
+})
diff --git a/schematics/maple_tree.mts b/schematics/maple_tree.mts
new file mode 100644
index 0000000..0f22cbc
--- /dev/null
+++ b/schematics/maple_tree.mts
Binary files differ
diff --git a/textures/maple_fence.png b/textures/maple_fence.png
new file mode 100644
index 0000000..58092fd
--- /dev/null
+++ b/textures/maple_fence.png
Binary files differ
diff --git a/textures/maple_leaves.png b/textures/maple_leaves.png
new file mode 100644
index 0000000..738b1b6
--- /dev/null
+++ b/textures/maple_leaves.png
Binary files differ
diff --git a/textures/maple_leaves_simple.png b/textures/maple_leaves_simple.png
new file mode 100644
index 0000000..8b78725
--- /dev/null
+++ b/textures/maple_leaves_simple.png
Binary files differ
diff --git a/textures/maple_sapling.png b/textures/maple_sapling.png
new file mode 100644
index 0000000..40b19ac
--- /dev/null
+++ b/textures/maple_sapling.png
Binary files differ
diff --git a/textures/maple_tree.png b/textures/maple_tree.png
new file mode 100644
index 0000000..7774751
--- /dev/null
+++ b/textures/maple_tree.png
Binary files differ
diff --git a/textures/maple_tree_top.png b/textures/maple_tree_top.png
new file mode 100644
index 0000000..50be435
--- /dev/null
+++ b/textures/maple_tree_top.png
Binary files differ
diff --git a/textures/maple_wood.png b/textures/maple_wood.png
new file mode 100644
index 0000000..55d5100
--- /dev/null
+++ b/textures/maple_wood.png
Binary files differ
diff --git a/trees.lua b/trees.lua
new file mode 100644
index 0000000..b308bc1
--- /dev/null
+++ b/trees.lua
@@ -0,0 +1,52 @@
+local random = math.random
+
+-- I don't remember if snow function is needed.
+local function is_snow_nearby(pos)
+ return minetest.find_node_near(pos, 1,
+ {"default:snow", "default:snowblock", "default:dirt_with_snow"})
+end
+
+
+-- Sapling ABM
+
+function maple.grow_sapling(pos)
+ if not default.can_grow(pos) then
+ -- Can't grow yet, try later.
+ minetest.get_node_timer(pos):start(math.random(240, 600))
+ return
+ end
+
+ local mg_name = minetest.get_mapgen_setting("mg_name")
+ local node = minetest.get_node(pos)
+
+ if node.name == "maple:maple_sapling" then
+ minetest.log("action", "An maple sapling grows into a tree at "..
+ minetest.pos_to_string(pos))
+ minetest.remove_node(pos)
+ maple.grow_new_maple_tree(pos)
+ end
+end
+
+minetest.register_lbm({
+ name = "maple:convert_saplings_to_node_timer",
+ nodenames = {"maple:maple_sapling"},
+ action = function(pos)
+ minetest.get_node_timer(pos):start(math.random(1200, 2400))
+ end
+})
+
+--
+-- Tree generation
+--
+
+-- New maple tree
+
+function maple.grow_new_maple_tree(pos)
+ local path = minetest.get_modpath("maple") ..
+ "/schematics/maple_tree.mts"
+ minetest.place_schematic({x = pos.x - 3, y = pos.y, z = pos.z - 3},
+ path, "0", nil, false)
+end
+
+
+