123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- -- farming/nodes.lua
- -- support for MT game translation.
- local S = farming.get_translator
- minetest.override_item("default:dirt", {
- soil = {
- base = "default:dirt",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.override_item("default:dirt_with_grass", {
- soil = {
- base = "default:dirt_with_grass",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.override_item("default:dirt_with_dry_grass", {
- soil = {
- base = "default:dirt_with_dry_grass",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.override_item("default:dirt_with_rainforest_litter", {
- soil = {
- base = "default:dirt_with_rainforest_litter",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.override_item("default:dirt_with_coniferous_litter", {
- soil = {
- base = "default:dirt_with_coniferous_litter",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.override_item("default:dry_dirt", {
- soil = {
- base = "default:dry_dirt",
- dry = "farming:dry_soil",
- wet = "farming:dry_soil_wet"
- }
- })
- minetest.override_item("default:dry_dirt_with_dry_grass", {
- soil = {
- base = "default:dry_dirt_with_dry_grass",
- dry = "farming:dry_soil",
- wet = "farming:dry_soil_wet"
- }
- })
- minetest.register_node("farming:soil", {
- description = S("Soil"),
- tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
- drop = "default:dirt",
- groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
- sounds = default.node_sound_dirt_defaults(),
- soil = {
- base = "default:dirt",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.register_node("farming:soil_wet", {
- description = S("Wet Soil"),
- tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
- drop = "default:dirt",
- groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
- sounds = default.node_sound_dirt_defaults(),
- soil = {
- base = "default:dirt",
- dry = "farming:soil",
- wet = "farming:soil_wet"
- }
- })
- minetest.register_node("farming:dry_soil", {
- description = "Dry Soil",
- tiles = {"default_dry_dirt.png^farming_soil.png", "default_dry_dirt.png"},
- drop = "default:dry_dirt",
- groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
- sounds = default.node_sound_dirt_defaults(),
- soil = {
- base = "default:dry_dirt",
- dry = "farming:dry_soil",
- wet = "farming:dry_soil_wet"
- }
- })
- minetest.register_node("farming:dry_soil_wet", {
- description = "Wet Dry Soil",
- tiles = {"default_dry_dirt.png^farming_soil_wet.png", "default_dry_dirt.png^farming_soil_wet_side.png"},
- drop = "default:dry_dirt",
- groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
- sounds = default.node_sound_dirt_defaults(),
- soil = {
- base = "default:dry_dirt",
- dry = "farming:dry_soil",
- wet = "farming:dry_soil_wet"
- }
- })
- minetest.override_item("default:desert_sand", {
- groups = {crumbly=3, falling_node=1, sand=1, soil = 1},
- soil = {
- base = "default:desert_sand",
- dry = "farming:desert_sand_soil",
- wet = "farming:desert_sand_soil_wet"
- }
- })
- minetest.register_node("farming:desert_sand_soil", {
- description = S("Desert Sand Soil"),
- drop = "default:desert_sand",
- tiles = {"farming_desert_sand_soil.png", "default_desert_sand.png"},
- groups = {crumbly=3, not_in_creative_inventory = 1, falling_node=1, sand=1, soil = 2, desert = 1, field = 1},
- sounds = default.node_sound_sand_defaults(),
- soil = {
- base = "default:desert_sand",
- dry = "farming:desert_sand_soil",
- wet = "farming:desert_sand_soil_wet"
- }
- })
- minetest.register_node("farming:desert_sand_soil_wet", {
- description = S("Wet Desert Sand Soil"),
- drop = "default:desert_sand",
- tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"},
- groups = {crumbly=3, falling_node=1, sand=1, not_in_creative_inventory=1, soil=3, wet = 1, desert = 1, field = 1},
- sounds = default.node_sound_sand_defaults(),
- soil = {
- base = "default:desert_sand",
- dry = "farming:desert_sand_soil",
- wet = "farming:desert_sand_soil_wet"
- }
- })
- minetest.register_node("farming:straw", {
- description = S("Straw"),
- tiles = {"farming_straw.png"},
- is_ground_content = false,
- groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
- sounds = default.node_sound_leaves_defaults(),
- })
- stairs.register_stair_and_slab(
- "straw",
- "farming:straw",
- {snappy = 3, flammable = 4},
- {"farming_straw.png"},
- S("Straw Stair"),
- S("Straw Slab"),
- default.node_sound_leaves_defaults(),
- true
- )
- minetest.register_abm({
- label = "Farming soil",
- nodenames = {"group:field"},
- interval = 15,
- chance = 4,
- action = function(pos, node)
- local n_def = minetest.registered_nodes[node.name] or nil
- local wet = n_def.soil.wet or nil
- local base = n_def.soil.base or nil
- local dry = n_def.soil.dry or nil
- if not n_def or not n_def.soil or not wet or not base or not dry then
- return
- end
- pos.y = pos.y + 1
- local nn = minetest.get_node_or_nil(pos)
- if not nn or not nn.name then
- return
- end
- local nn_def = minetest.registered_nodes[nn.name] or nil
- pos.y = pos.y - 1
- if nn_def and nn_def.walkable and minetest.get_item_group(nn.name, "plant") == 0 then
- minetest.set_node(pos, {name = base})
- return
- end
- -- check if there is water nearby
- local wet_lvl = minetest.get_item_group(node.name, "wet")
- if minetest.find_node_near(pos, 3, {"group:water"}) then
- -- if it is dry soil and not base node, turn it into wet soil
- if wet_lvl == 0 then
- minetest.set_node(pos, {name = wet})
- end
- else
- -- only turn back if there are no unloaded blocks (and therefore
- -- possible water sources) nearby
- if not minetest.find_node_near(pos, 3, {"ignore"}) then
- -- turn it back into base if it is already dry
- if wet_lvl == 0 then
- -- only turn it back if there is no plant/seed on top of it
- if minetest.get_item_group(nn.name, "plant") == 0 and minetest.get_item_group(nn.name, "seed") == 0 then
- minetest.set_node(pos, {name = base})
- end
- -- if its wet turn it back into dry soil
- elseif wet_lvl == 1 then
- minetest.set_node(pos, {name = dry})
- end
- end
- end
- end,
- })
- for i = 1, 5 do
- minetest.override_item("default:grass_"..i, {drop = {
- max_items = 1,
- items = {
- {items = {"farming:seed_wheat"},rarity = 5},
- {items = {"default:grass_1"}},
- }
- }})
- end
- minetest.override_item("default:junglegrass", {drop = {
- max_items = 1,
- items = {
- {items = {"farming:seed_cotton"},rarity = 8},
- {items = {"default:junglegrass"}},
- }
- }})
|