123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- -----------------------------------------------------------------------------------------------
- -- Dry Plants - Reed 0.0.5
- -----------------------------------------------------------------------------------------------
- -- by Mossmanikin
- -- Looked at code from: darkage, default, stairs
- -- Dependencies: default
- -----------------------------------------------------------------------------------------------
- -- support for i18n
- local S = minetest.get_translator("dryplants")
- minetest.register_alias("stairs:stair_wetreed", "dryplants:wetreed_roof")
- minetest.register_alias("stairs:slab_wetreed", "dryplants:wetreed_slab")
- minetest.register_alias("stairs:stair_reed", "dryplants:reed_roof")
- minetest.register_alias("stairs:slab_reed", "dryplants:reed_slab")
- -----------------------------------------------------------------------------------------------
- -- Wet Reed
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:wetreed", {
- description = S("Wet Reed"),
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed_wet.png"},
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Wet Reed Slab
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:wetreed_slab", {
- description = S("Wet Reed Slab"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed_wet.png"},
- node_box = {
- type = "fixed",
- fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
- },
- selection_box = {
- type = "fixed",
- fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Wet Reed Roof
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:wetreed_roof", {
- description = S("Wet Reed Roof"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed_wet.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, -1/2, -1/2, 1/2, 0, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, -1/2, -1/2, 1/2, 0, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- if AUTO_ROOF_CORNER == true then
- local CoRNeR = {
- -- MaTeRiaL
- {"wetreed"},
- {"reed"}
- }
- for i in pairs(CoRNeR) do
- local MaTeRiaL = CoRNeR[i][1]
- local roof = "dryplants:"..MaTeRiaL.."_roof"
- local corner = "dryplants:"..MaTeRiaL.."_roof_corner"
- local corner_2 = "dryplants:"..MaTeRiaL.."_roof_corner_2"
- minetest.register_abm({
- nodenames = {roof},
- interval = 1,
- chance = 1,
- action = function(pos)
- local node_east = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z })
- local node_west = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z })
- local node_north = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
- local node_south = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
- -- corner 1
- if ((node_west.name == roof and node_west.param2 == 0)
- or (node_west.name == corner and node_west.param2 == 1))
- and ((node_north.name == roof and node_north.param2 == 3)
- or (node_north.name == corner and node_north.param2 == 3))
- then
- minetest.swap_node(pos, {name=corner, param2=0})
- end
- if ((node_north.name == roof and node_north.param2 == 1)
- or (node_north.name == corner and node_north.param2 == 2))
- and ((node_east.name == roof and node_east.param2 == 0)
- or (node_east.name == corner and node_east.param2 == 0))
- then
- minetest.swap_node(pos, {name=corner, param2=1})
- end
- if ((node_east.name == roof and node_east.param2 == 2)
- or (node_east.name == corner and node_east.param2 == 3))
- and ((node_south.name == roof and node_south.param2 == 1)
- or (node_south.name == corner and node_south.param2 == 1))
- then
- minetest.swap_node(pos, {name=corner, param2=2})
- end
- if ((node_south.name == roof and node_south.param2 == 3)
- or (node_south.name == corner and node_south.param2 == 0))
- and ((node_west.name == roof and node_west.param2 == 2)
- or (node_west.name == corner and node_west.param2 == 2))
- then
- minetest.swap_node(pos, {name=corner, param2=3})
- end
- -- corner 2
- if ((node_west.name == roof and node_west.param2 == 2)
- or (node_west.name == corner_2 and node_west.param2 == 1))
- and ((node_north.name == roof and node_north.param2 == 1)
- or (node_north.name == corner_2 and node_north.param2 == 3))
- then
- minetest.swap_node(pos, {name=corner_2, param2=0})
- end
- if ((node_north.name == roof and node_north.param2 == 3)
- or (node_north.name == corner_2 and node_north.param2 == 2))
- and ((node_east.name == roof and node_east.param2 == 2)
- or (node_east.name == corner_2 and node_east.param2 == 0))
- then
- minetest.swap_node(pos, {name=corner_2, param2=1})
- end
- if ((node_east.name == roof and node_east.param2 == 0)
- or (node_east.name == corner_2 and node_east.param2 == 3))
- and ((node_south.name == roof and node_south.param2 == 3)
- or (node_south.name == corner_2 and node_south.param2 == 1))
- then
- minetest.swap_node(pos, {name=corner_2, param2=2})
- end
- if ((node_south.name == roof and node_south.param2 == 1)
- or (node_south.name == corner_2 and node_south.param2 == 0))
- and ((node_west.name == roof and node_west.param2 == 0)
- or (node_west.name == corner_2 and node_west.param2 == 2))
- then
- minetest.swap_node(pos, {name=corner_2, param2=3})
- end
- end,
- })
- end
- end
- -----------------------------------------------------------------------------------------------
- -- Wet Reed Roof Corner
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:wetreed_roof_corner", {
- description = S("Wet Reed Roof Corner"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed_wet.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, 0, 0, 0, 1/2, 1/2},
- {0, -1/2, 0, 1/2, 0, 1/2},
- {-1/2, -1/2, -1/2, 0, 0, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, 0, 0, 0, 1/2, 1/2},
- {0, -1/2, 0, 1/2, 0, 1/2},
- {-1/2, -1/2, -1/2, 0, 0, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Wet Reed Roof Corner 2
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:wetreed_roof_corner_2", {
- description = S("Wet Reed Roof Corner 2"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed_wet.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, -1/2, 0, 0, 0, 1/2},
- {0, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, 0, -1/2, 0, 1/2, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, -1/2, 0, 0, 0, 1/2},
- {0, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, 0, -1/2, 0, 1/2, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Wet Reed becomes (dry) Reed over time
- -----------------------------------------------------------------------------------------------
- if REED_WILL_DRY == true then
- local DRyiNG = {
- -- WeT DRy
- {"dryplants:wetreed", "dryplants:reed"},
- {"dryplants:wetreed_slab", "dryplants:reed_slab"},
- {"dryplants:wetreed_roof", "dryplants:reed_roof"},
- {"dryplants:wetreed_roof_corner", "dryplants:reed_roof_corner"},
- {"dryplants:wetreed_roof_corner_2", "dryplants:reed_roof_corner_2"}
- }
- for i in pairs(DRyiNG) do
- local WeT = DRyiNG[i][1]
- local DRy = DRyiNG[i][2]
- minetest.register_abm({
- nodenames = {WeT},
- interval = REED_DRYING_TIME, --1200, -- 20 minutes: a minetest-day/night-cycle
- chance = 1,
- action = function(pos)
- local direction = minetest.get_node(pos).param2
- minetest.swap_node(pos, {name=DRy, param2=direction})
- end,
- })
- end
- end
- -----------------------------------------------------------------------------------------------
- -- Reed
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:reed", {
- description = S("Reed"),
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed.png"},
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Reed Slab
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:reed_slab", {
- description = S("Reed Slab"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed.png"},
- node_box = {
- type = "fixed",
- fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
- },
- selection_box = {
- type = "fixed",
- fixed = {-1/2, -1/2, -1/2, 1/2, 0, 1/2},
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Reed Roof
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:reed_roof", {
- description = S("Reed Roof"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, -1/2, -1/2, 1/2, 0, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, -1/2, -1/2, 1/2, 0, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Reed Roof Corner
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:reed_roof_corner", {
- description = S("Reed Roof Corner"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, 0, 0, 0, 1/2, 1/2},
- {0, -1/2, 0, 1/2, 0, 1/2},
- {-1/2, -1/2, -1/2, 0, 0, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, 0, 0, 0, 1/2, 1/2},
- {0, -1/2, 0, 1/2, 0, 1/2},
- {-1/2, -1/2, -1/2, 0, 0, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
- -----------------------------------------------------------------------------------------------
- -- Reed Roof Corner 2
- -----------------------------------------------------------------------------------------------
- minetest.register_node("dryplants:reed_roof_corner_2", {
- description = S("Reed Roof Corner 2"),
- drawtype = "nodebox",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"dryplants_reed.png"},
- node_box = {
- type = "fixed",
- -- { left , bottom , front , right , top , back }
- fixed = {
- {-1/2, -1/2, 0, 0, 0, 1/2},
- {0, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, 0, -1/2, 0, 1/2, 0},
- }
- },
- selection_box = {
- type = "fixed",
- fixed = {
- {-1/2, -1/2, 0, 0, 0, 1/2},
- {0, 0, 0, 1/2, 1/2, 1/2},
- {-1/2, 0, -1/2, 0, 1/2, 0},
- }
- },
- groups = {snappy=3, flammable=2},
- sounds = default.node_sound_leaves_defaults(),
- })
|