Xanthin
2014-04-16 39c41a06f4993dc17507fb480fcabbca319ceff7
commit | author | age
ee0765 1 -- Code of rubber tree by PilzAdam
S 2
39c41a 3 local S = technic.worldgen.gettext
X 4
ee0765 5 minetest.register_node(":moretrees:rubber_tree_sapling", {
39c41a 6     description = S("Rubber Tree Sapling"),
ee0765 7     drawtype = "plantlike",
S 8     tiles = {"technic_rubber_sapling.png"},
9     inventory_image = "technic_rubber_sapling.png",
10     wield_image = "technic_rubber_sapling.png",
11     paramtype = "light",
12     walkable = false,
13     groups = {dig_immediate=3, flammable=2},
14     sounds = default.node_sound_defaults(),
15 })
16
17 minetest.register_craft({
18     type = "fuel",
19     recipe = "moretrees:rubber_tree_sapling",
20     burntime = 10
21 })
22
23 minetest.register_node(":moretrees:rubber_tree_trunk", {
39c41a 24     description = S("Rubber Tree"),
ee0765 25     tiles = {"default_tree_top.png", "default_tree_top.png",
S 26         "technic_rubber_tree_full.png"},
27     groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
28         flammable=2},
29     sounds = default.node_sound_wood_defaults(),
163457 30     after_place_node = function(pos, placer, itemstack)
S 31         local meta = minetest.get_meta(pos)
32         meta:set_int("placed", 1)
33     end,
ee0765 34 })
S 35
36 minetest.register_node(":moretrees:rubber_tree_trunk_empty", {
39c41a 37     description = S("Rubber Tree"),
ee0765 38     tiles = {"default_tree_top.png", "default_tree_top.png",
S 39         "technic_rubber_tree_empty.png"},
40     groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
41             flammable=2, not_in_creative_inventory=1},
42     sounds = default.node_sound_wood_defaults(),
05b28f 43     after_place_node = function(pos, placer, itemstack)
S 44         local meta = minetest.get_meta(pos)
45         meta:set_int("placed", 1)
46     end,
ee0765 47 })
S 48
49 minetest.register_node(":moretrees:rubber_tree_leaves", {
50     drawtype = "allfaces_optional",
51     tiles = {"technic_rubber_leaves.png"},
52     paramtype = "light",
53     groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
54     drop = {
55         max_items = 1,
56         items = {{
57             items = {"moretrees:rubber_tree_sapling"},
58             rarity = 20,
59         }}
60     },
61     sounds = default.node_sound_leaves_defaults(),
62 })
63
64 technic.rubber_tree_model={
65     axiom = "FFFFA",
66     rules_a = "[&FFBFA]////[&BFFFA]////[&FBFFA]",
67     rules_b = "[&FFA]////[&FFA]////[&FFA]",
68     trunk = "moretrees:rubber_tree_trunk",
69     leaves = "moretrees:rubber_tree_leaves",
70     angle = 35,
71     iterations = 3,
72     random_level = 1,
73     trunk_type = "double",
74     thin_branches = true
75 }
76
77 minetest.register_abm({
78     nodenames = {"moretrees:rubber_tree_sapling"},
79     interval = 60,
80     chance = 20,
81     action = function(pos, node)
82         minetest.remove_node(pos)
83         minetest.spawn_tree(pos, technic.rubber_tree_model)
84     end
85 })
86
87 if technic.config:get_bool("enable_rubber_tree_generation") then
88     minetest.register_on_generated(function(minp, maxp, blockseed)
89         if math.random(1, 100) > 5 then
90             return
91         end
92         local tmp = {
93                 x = (maxp.x - minp.x) / 2 + minp.x,
94                 y = (maxp.y - minp.y) / 2 + minp.y,
95                 z = (maxp.z - minp.z) / 2 + minp.z}
96         local pos = minetest.find_node_near(tmp, maxp.x - minp.x,
97                 {"default:dirt_with_grass"})
98         if pos ~= nil then
99             minetest.spawn_tree({x=pos.x, y=pos.y+1, z=pos.z}, technic.rubber_tree_model)
100         end
101     end)
102 end
103