diff --git a/Mineral Trees Mod.luaproj b/Mineral Trees Mod.luaproj new file mode 100644 index 0000000..4422fcf --- /dev/null +++ b/Mineral Trees Mod.luaproj @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..113ab0e --- /dev/null +++ b/README.txt @@ -0,0 +1,34 @@ +=====================Mineral Trees mod for Minetest 0.4.12!========================= +Mineral Trees is a mod designed to make all ores in default Minetest renewable, by making them literally grow on trees! +Around the world you will find rare clusters of mineral trees, trees that grow by absorbing one of the six minerals in Minetest into their trunks, +strengthening them and allowing them to grow to huge proportions. These minerals, found mostly in the bark, can be smelted out of the +tree leaving blooms, 9 of which can be crafted together to make the lump or crystal of the specific mineral. This applies to all trees +except the coal tree, the bark of which can instead be used as an effective fuel. + +This mod depends on both the Default mod included with Minetest, and the plants_lib library by VanessaE. Both these mods must be installed in +order for this mod to not crash on startup. + +I hope this mod helps! +-GravelPunch + +Copyright (C) 2010-2013 GravelPunch + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +License for Textures, Models and Sounds +--------------------------------------- + +CC-BY-SA 3.0 UNPORTED. Created by GravelPunch, with contributions by SandSlap + diff --git a/config.txt b/config.txt new file mode 100644 index 0000000..16fb148 --- /dev/null +++ b/config.txt @@ -0,0 +1,30 @@ +--config options +mineraltrees.tree_angle = 45 --how 'bent' the limbs and branches of all mineraltrees are. Warning: changes may be unpredictable +mineraltrees.dist_apart = 20--how far apart two mineraltrees can be, at a minimum. +mineraltrees.seed_dif = 675 --The difference between the world's seed and the mineraltree's seed. Good for maintaining compatibility IMPORTANT: changes as trees are registered +mineraltrees.base_rarity = 95--How rare, out of 100, a mineraltree is. Calculated using this < math.random(1, 100) +mineraltrees.rel_rarity = 1 --Deprecated +mineraltrees.biome_max_count = 1 --How many mineraltrees can be in one area + +--tree-specific rareness options +--These options decide how many times out of the total a given tree will spawn. For example, if they were 3:3:3:2:2:1, a coal tree would spawn 3 of 14 times. +mineraltrees.coal_rarity = 3 +mineraltrees.iron_rarity = 3 +mineraltrees.copper_rarity = 3 +mineraltrees.gold_rarity = 2 +mineraltrees.mese_rarity = 2 +mineraltrees.diamond_rarity = 1 + +--tree-specific enabling +mineraltrees.enable_coal_tree = true +mineraltrees.enable_iron_tree = true +mineraltrees.enable_copper_tree = true +mineraltrees.enable_gold_tree = true +mineraltrees.enable_mese_tree = true +mineraltrees.enable_diamond_tree = true + +--biome config options. Dictate in how many circumstances a mineraltree can spawn. More specific values make for rarer trees. +mineraltrees.min_elevation = 20 +mineraltrees.max_elevation = 40 +mineraltrees.temp_min = 1 +mineraltrees.tem_max = .25 diff --git a/crafting.lua b/crafting.lua new file mode 100644 index 0000000..b48f2ce --- /dev/null +++ b/crafting.lua @@ -0,0 +1,51 @@ +--All mod recipes +minetest.register_craft({ + output = "default:copper_lump", + recipe = { + {"mineraltrees:copper_bloom", "mineraltrees:copper_bloom", "mineraltrees:copper_bloom"}, + {"mineraltrees:copper_bloom", "mineraltrees:copper_bloom", "mineraltrees:copper_bloom"}, + {"mineraltrees:copper_bloom", "mineraltrees:copper_bloom", "mineraltrees:copper_bloom"} + } +}) + +minetest.register_craft({ + output = "default:iron_lump", + recipe = { + {"mineraltrees:iron_bloom", "mineraltrees:iron_bloom", "mineraltrees:iron_bloom"}, + {"mineraltrees:iron_bloom", "mineraltrees:iron_bloom", "mineraltrees:iron_bloom"}, + {"mineraltrees:iron_bloom", "mineraltrees:iron_bloom", "mineraltrees:iron_bloom"} + } +}) + +minetest.register_craft({ + output = "default:mese_crystal", + recipe = { + {"mineraltrees:mese_bloom", "mineraltrees:mese_bloom", "mineraltrees:mese_bloom"}, + {"mineraltrees:mese_bloom", "mineraltrees:mese_bloom", "mineraltrees:mese_bloom"}, + {"mineraltrees:mese_bloom", "mineraltrees:mese_bloom", "mineraltrees:mese_bloom"} + } +}) + +minetest.register_craft({ + output = "default:diamond", + recipe = { + {"mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom"}, + {"mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom"}, + {"mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom", "mineraltrees:diamond_bloom"} + } +}) + +minetest.register_craft({ + output = "default:gold_lump", + recipe = { + {"mineraltrees:gold_bloom", "mineraltrees:gold_bloom", "mineraltrees:gold_bloom"}, + {"mineraltrees:gold_bloom", "mineraltrees:gold_bloom", "mineraltrees:gold_bloom"}, + {"mineraltrees:gold_bloom", "mineraltrees:gold_bloom", "mineraltrees:gold_bloom"} + } +}) + +minetest.register_craft({ + output = "mineraltrees:splitter", + type = "shapeless", + recipe = {"default:axe_steel"} +}) \ No newline at end of file diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..bde0bdf --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +plants_lib \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..4c98032 --- /dev/null +++ b/init.lua @@ -0,0 +1,125 @@ +--============Mineral Trees Mod for Minetest 0.4.12!=============-- +--Notice: All material shown here is property of Gravelpunch , (C) 2015, licensed under GLPGL and the art under CC-BY-SA 3.0 unported. See readme.txt for more details. + +mineraltrees = {} + +function table.contains(table, element) + for key, value in pairs(table) do + if value == element then + return key + end + end + return +end + +--sets up tables for mineral trees-- +mineraltrees.bloom_array = {} +mineraltrees.bark_array = {} +mineraltrees.tree_array = {} + +modpath = minetest.get_modpath("mineraltrees") +--loads config options +dofile(modpath.."/config.txt") +--loads mineraltrees.register_mineral_tree +dofile(modpath.."/tree.lua") + +mineraltrees.mineraltree_defs = { + coaltree = { + name = "coal", + has_bloom = false, + rarity = mineraltrees.coal_rarity, + enabled = mineraltrees.enable_coal_tree + }, + irontree = { + name = "iron", + has_bloom = true, + rarity = mineraltrees.iron_rarity, + enabled = mineraltrees.enable_iron_tree + }, + coppertree = { + name = "copper", + has_bloom = true, + rarity = mineraltrees.copper_rarity, + enabled = mineraltrees.enable_copper_tree + }, + goldtree = { + name = "gold", + has_bloom = true, + rarity = mineraltrees.gold_rarity, + enabled = mineraltrees.enable_gold_tree + }, + mesetree = { + name = "mese", + has_bloom = true, + rarity = mineraltrees.mese_rarity, + enabled = mineraltrees.enable_mese_tree + }, + diamondtree = { + name = "diamond", + has_bloom = true, + rarity = mineraltrees.diamond_rarity, + enabled = mineraltrees.enable_diamond_tree + } +} + +mineraltrees.sapling_rarity_array = {} + +--registers all mineraltrees +for _, mineraltree_def in pairs(mineraltrees.mineraltree_defs) do + mineraltrees.register_mineral_tree(mineraltree_def.name, mineraltree_def.has_bloom, mineraltree_def.rarity, mineraltree_def.enabled) +end + +mineraltrees.biome_def = { + surface = "default:dirt_with_grass", + avoid_nodes = mineraltrees.tree_array, + avoid_radius = mineraltrees.dist_apart, + seed_dif = mineraltrees.seed_dif, + rarity = mineraltrees.base_rarity, + max_count = mineraltrees.biome_max_count, + min_elevation = mineraltrees.min_elevation, + max_elevation = mineraltrees.max_elevation, + temp_min = mineraltrees.temp_min, + temp_max = mineraltrees.temp_max + } + + --registers tree spawning with plants_lib + plantslib:register_generate_plant(mineraltrees.biome_def, mineraltrees.sapling_rarity_array) + +--Bark Splitter definition-- +minetest.register_craftitem("mineraltrees:splitter", { + description = "Bark Splitter", + inventory_image = "mineraltrees_splitter.png", + weild_image = "mineraltrees_splitter.png", + weild_scale = 1.7, + stack_max = 1, + liquids_pointable = false, + + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "node" then + pointed_pos = pointed_thing.under + pointed_node = minetest.get_node(pointed_pos) + print(pointed_node.name) + + node_index = table.contains(mineraltrees.tree_array, pointed_node.name) + + if (mineraltrees.tree_array[node_index] ~= nil) and (mineraltrees.bark_array[node_index] ~= nil) then + user:get_inventory():add_item("main", mineraltrees.bark_array[node_index]) + minetest.set_node(pointed_pos, {name="mineraltrees:barelog"}) + end + end + return itemstack + end +}) + +--Bare Log definition +minetest.register_node("mineraltrees:barelog", { + description = "Bare Log", + tiles = {"mineraltrees_barelog.png", "mineraltrees_barelog.png", "mineraltrees_barelogside.png"}, + paramtype2 = "facedir", + is_ground_content = false, + groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + on_place = minetest.rotate_node +}) + +--loads crafting. All the way down here so all the ingredients are loaded already. +dofile(modpath.."/crafting.lua") \ No newline at end of file diff --git a/textures/mineraltrees_barelog.png b/textures/mineraltrees_barelog.png new file mode 100644 index 0000000..f2c577a Binary files /dev/null and b/textures/mineraltrees_barelog.png differ diff --git a/textures/mineraltrees_barelogside.png b/textures/mineraltrees_barelogside.png new file mode 100644 index 0000000..4f332ef Binary files /dev/null and b/textures/mineraltrees_barelogside.png differ diff --git a/textures/mineraltrees_coalleaves.png b/textures/mineraltrees_coalleaves.png new file mode 100644 index 0000000..6a46452 Binary files /dev/null and b/textures/mineraltrees_coalleaves.png differ diff --git a/textures/mineraltrees_coalsapling.png b/textures/mineraltrees_coalsapling.png new file mode 100644 index 0000000..951d6fd Binary files /dev/null and b/textures/mineraltrees_coalsapling.png differ diff --git a/textures/mineraltrees_coaltree.png b/textures/mineraltrees_coaltree.png new file mode 100644 index 0000000..4afdd41 Binary files /dev/null and b/textures/mineraltrees_coaltree.png differ diff --git a/textures/mineraltrees_copper_bloom.png b/textures/mineraltrees_copper_bloom.png new file mode 100644 index 0000000..8203240 Binary files /dev/null and b/textures/mineraltrees_copper_bloom.png differ diff --git a/textures/mineraltrees_copperleaves.png b/textures/mineraltrees_copperleaves.png new file mode 100644 index 0000000..656016e Binary files /dev/null and b/textures/mineraltrees_copperleaves.png differ diff --git a/textures/mineraltrees_coppersapling.png b/textures/mineraltrees_coppersapling.png new file mode 100644 index 0000000..6c2d780 Binary files /dev/null and b/textures/mineraltrees_coppersapling.png differ diff --git a/textures/mineraltrees_coppertree.png b/textures/mineraltrees_coppertree.png new file mode 100644 index 0000000..e8a0e23 Binary files /dev/null and b/textures/mineraltrees_coppertree.png differ diff --git a/textures/mineraltrees_diamond_bloom.png b/textures/mineraltrees_diamond_bloom.png new file mode 100644 index 0000000..cb37eb4 Binary files /dev/null and b/textures/mineraltrees_diamond_bloom.png differ diff --git a/textures/mineraltrees_diamondleaves.png b/textures/mineraltrees_diamondleaves.png new file mode 100644 index 0000000..4165413 Binary files /dev/null and b/textures/mineraltrees_diamondleaves.png differ diff --git a/textures/mineraltrees_diamondsapling.png b/textures/mineraltrees_diamondsapling.png new file mode 100644 index 0000000..0070ddb Binary files /dev/null and b/textures/mineraltrees_diamondsapling.png differ diff --git a/textures/mineraltrees_diamondtree.png b/textures/mineraltrees_diamondtree.png new file mode 100644 index 0000000..c0f12b9 Binary files /dev/null and b/textures/mineraltrees_diamondtree.png differ diff --git a/textures/mineraltrees_gold_bloom.png b/textures/mineraltrees_gold_bloom.png new file mode 100644 index 0000000..aa7ac56 Binary files /dev/null and b/textures/mineraltrees_gold_bloom.png differ diff --git a/textures/mineraltrees_goldleaves.png b/textures/mineraltrees_goldleaves.png new file mode 100644 index 0000000..e4e8b60 Binary files /dev/null and b/textures/mineraltrees_goldleaves.png differ diff --git a/textures/mineraltrees_goldsapling.png b/textures/mineraltrees_goldsapling.png new file mode 100644 index 0000000..f4474a0 Binary files /dev/null and b/textures/mineraltrees_goldsapling.png differ diff --git a/textures/mineraltrees_goldtree.png b/textures/mineraltrees_goldtree.png new file mode 100644 index 0000000..2d93a84 Binary files /dev/null and b/textures/mineraltrees_goldtree.png differ diff --git a/textures/mineraltrees_iron_bloom.png b/textures/mineraltrees_iron_bloom.png new file mode 100644 index 0000000..96adae0 Binary files /dev/null and b/textures/mineraltrees_iron_bloom.png differ diff --git a/textures/mineraltrees_ironleaves.png b/textures/mineraltrees_ironleaves.png new file mode 100644 index 0000000..44de010 Binary files /dev/null and b/textures/mineraltrees_ironleaves.png differ diff --git a/textures/mineraltrees_ironsapling.png b/textures/mineraltrees_ironsapling.png new file mode 100644 index 0000000..213bf29 Binary files /dev/null and b/textures/mineraltrees_ironsapling.png differ diff --git a/textures/mineraltrees_irontree.png b/textures/mineraltrees_irontree.png new file mode 100644 index 0000000..e93e876 Binary files /dev/null and b/textures/mineraltrees_irontree.png differ diff --git a/textures/mineraltrees_mese_bloom.png b/textures/mineraltrees_mese_bloom.png new file mode 100644 index 0000000..b7b9a4d Binary files /dev/null and b/textures/mineraltrees_mese_bloom.png differ diff --git a/textures/mineraltrees_meseleaves.png b/textures/mineraltrees_meseleaves.png new file mode 100644 index 0000000..1a1b11d Binary files /dev/null and b/textures/mineraltrees_meseleaves.png differ diff --git a/textures/mineraltrees_mesesapling.png b/textures/mineraltrees_mesesapling.png new file mode 100644 index 0000000..144d252 Binary files /dev/null and b/textures/mineraltrees_mesesapling.png differ diff --git a/textures/mineraltrees_mesetree.png b/textures/mineraltrees_mesetree.png new file mode 100644 index 0000000..5bbb978 Binary files /dev/null and b/textures/mineraltrees_mesetree.png differ diff --git a/textures/mineraltrees_splitter.png b/textures/mineraltrees_splitter.png new file mode 100644 index 0000000..de9d2ca Binary files /dev/null and b/textures/mineraltrees_splitter.png differ diff --git a/textures/minetest_ironleaves.png b/textures/minetest_ironleaves.png new file mode 100644 index 0000000..a91d6a8 Binary files /dev/null and b/textures/minetest_ironleaves.png differ diff --git a/tree.lua b/tree.lua new file mode 100644 index 0000000..0f55ca2 --- /dev/null +++ b/tree.lua @@ -0,0 +1,138 @@ +--function for registering mineral trees-- +function mineraltrees.register_mineral_tree(mineral, has_bloom, tree_rarity, enabled) + if not enabled then + return + end + + --registers the log of the respective tree-- + minetest.register_node("mineraltrees:"..mineral.."tree", { + description = mineral.."wood Tree", + tiles = {"default_tree_top.png", "default_tree_top.png", "mineraltrees_"..mineral.."tree.png"}, + paramtype2 = "facedir", + is_ground_content = false, + groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + on_place = minetest.rotate_node, + sounds = default.node_sound_wood_defaults() + }) + + --registers the leaves of the respective tree-- + minetest.register_node("mineraltrees:"..mineral.."leaves", { + description = mineral.."wood Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles ={"mineraltrees_"..mineral.."leaves.png"}, + paramtype = "light", + is_ground_content = false, + groups = {snappy=3, leafdecay=7, flammable=1}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/200 chance + items = {"mineraltrees:"..mineral.."sapling"}, + rarity = 200, + }, + { + -- player will get leaves only if he get no saplings, + -- this is because max_items is 1 + items = {"mineraltrees:"..mineral.."leaves"}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), + }) + + --registers the sapling of the respective tree + minetest.register_node("mineraltrees:"..mineral.."sapling", { + description = mineral.."wood Sapling", + drawtype = "plantlike", + visual_scale = 1.0, + tiles ={"mineraltrees_"..mineral.."sapling.png"}, + inventory_image = "mineraltrees_"..mineral.."sapling.png", + wield_image = "mineraltrees_"..mineral.."sapling.png", + paramtype = "light", + walkable = false, + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} + }, + sounds = default.node_sound_leaves_defaults(), + groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1} + }) + + local tree_def = { + axiom ="FFFFFFFAFFFFF/A", + rules_a = "[&&[F^TFDFFDFFDFF][--F^TFDFFDFFDFF][----F^TFDFFDFFDFF][++F^TFDFFDFFDFF]]", + rules_b = "", + rules_c = "F", + rules_d = "&", + trunk="mineraltrees:"..mineral.."tree", + leaves="mineraltrees:"..mineral.."leaves", + angle=mineraltrees.tree_angle, + iterations=2, + random_level=0, + trunk_type="crossed", + thin_branches=true, + fruit_chance=0, + fruit="default:apple" + } + + local function grow_tree(pos) + minetest.remove_node(pos) + minetest.spawn_tree(pos, tree_def) + end + + --registers plant growing with plants_lib + plantslib:grow_plants({ + grow_delay = 10, + grow_chance = 1, + grow_plant = "mineraltrees:"..mineral.."sapling", + grow_nodes = "default:dirt_with_grass", + grow_function = tree_def + }) + + --registers bark + minetest.register_craftitem("mineraltrees:"..mineral.."bark", { + description = mineral.."wood Bark", + inventory_image = "mineraltrees_"..mineral.."tree.png", + weild_image = "mineraltrees_"..mineral.."tree.png", + weild_scale = 1, + stack_max = 99, + liquids_pointable = false + }) + + --registers bloom if applicable + if (has_bloom)then + minetest.register_craftitem("mineraltrees:"..mineral.."_bloom", { + description = mineral.." Bloom", + inventory_image = "mineraltrees_"..mineral.."_bloom.png", + weild_image = "mineraltrees_"..mineral.."bloom.png", + weild_scale = 1, + stack_max = 99, + liguids_pointable = false + }) + + minetest.register_craft({ + type = "cooking", + output = "mineraltrees:"..mineral.."_bloom", + recipe = "mineraltrees:"..mineral.."bark" + }) + else + minetest.register_craft({ + type = "fuel", + recipe = "mineraltrees:"..mineral.."bark", + burntime = 5 + }) + end + + table.insert(mineraltrees.bark_array, "mineraltrees:"..mineral.."bark 4") + table.insert(mineraltrees.bloom_array, "mineraltrees:"..mineral.."_bloom") + table.insert(mineraltrees.tree_array, "mineraltrees:"..mineral.."tree") + mineraltrees.seed_dif = mineraltrees.seed_dif+1 + + --adds sapling to sapling array according to rarity + for i = 0, tree_rarity do + table.insert(mineraltrees.sapling_rarity_array, "mineraltrees:"..mineral.."sapling") + end +end \ No newline at end of file