From 823a210462c4dcfbddf5b734b723422b5fbc15e5 Mon Sep 17 00:00:00 2001 From: thunderdog1138 Date: Fri, 17 Jul 2020 12:38:29 +0000 Subject: [PATCH] Upload files to 'mods/farming' --- mods/farming/intllib.lua | 45 ++++++++++ mods/farming/license.txt | 144 +++++++++++++++++++++++++++++ mods/farming/lucky_block.lua | 77 ++++++++++++++++ mods/farming/mapgen.lua | 169 +++++++++++++++++++++++++++++++++++ mods/farming/mod.conf | 1 + 5 files changed, 436 insertions(+) create mode 100644 mods/farming/intllib.lua create mode 100644 mods/farming/license.txt create mode 100644 mods/farming/lucky_block.lua create mode 100644 mods/farming/mapgen.lua create mode 100644 mods/farming/mod.conf diff --git a/mods/farming/intllib.lua b/mods/farming/intllib.lua new file mode 100644 index 00000000..6669d720 --- /dev/null +++ b/mods/farming/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- Get the latest version of this file at: +-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua + +local function format(str, ...) + local args = { ... } + local function repl(escape, open, num, close) + if escape == "" then + local replacement = tostring(args[tonumber(num)]) + if open == "" then + replacement = replacement..close + end + return replacement + else + return "@"..open..num..close + end + end + return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) +end + +local gettext, ngettext +if minetest.get_modpath("intllib") then + if intllib.make_gettext_pair then + -- New method using gettext. + gettext, ngettext = intllib.make_gettext_pair() + else + -- Old method using text files. + gettext = intllib.Getter() + end +end + +-- Fill in missing functions. + +gettext = gettext or function(msgid, ...) + return format(msgid, ...) +end + +ngettext = ngettext or function(msgid, msgid_plural, n, ...) + return format(n==1 and msgid or msgid_plural, ...) +end + +return gettext, ngettext diff --git a/mods/farming/license.txt b/mods/farming/license.txt new file mode 100644 index 00000000..85848717 --- /dev/null +++ b/mods/farming/license.txt @@ -0,0 +1,144 @@ +The MIT License (MIT) + +Copyright (c) 2016 TenPlus1 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +License of media (textures): +---------------------------- +Created by PilzAdam (License: CC BY 3.0): + farming_bread.png + farming_soil.png + farming_soil_wet.png + farming_soil_wet_side.png + farming_string.png + +Created by Napiophelios (CC BY-SA 3.0): + farming_cotton.png + +Created by Calinou (License: CC BY-SA): + farming_tool_bronzehoe.png + farming_tool_steelhoe.png + farming_tool_stonehoe.png + farming_tool_woodhoe.png + farming_tool_mesehoe.png + farming_tool_diamondhoe.png + +Created by VanessaE (License: CC BY 3.0): + farming_cotton_seed.png + farming_wheat_seed.png + farming_flour.png + farming_wheat.png + farming_wheat_1.png + farming_wheat_2.png + farming_wheat_3.png + farming_wheat_4.png + farming_wheat_5.png + farming_wheat_5.png + farming_wheat_7.png + farming_wheat_8.png + farming_cotton_1.png + farming_cotton_2.png + farming_cotton_3.png + farming_cotton_4.png + farming_cotton_5.png + farming_cotton_6.png + farming_cotton_7.png + farming_cotton_8.png + +Created by Doc (License: CC BY 3.0): + farming_cucumber.png + farming_cucumber_1.png + farming_cucumber_2.png + farming_cucumber_3.png + farming_cucumber_4.png + farming_potato.png + farming_potato_1.png + farming_potato_2.png + farming_potato_3.png + farming_potato_4.png + farming_raspberries.png + farming_raspberry_1.png + farming_raspberry_2.png + farming_raspberry_3.png + farming_raspberry_4.png + +Created by Gambit (License: CC BY 3.0): + default_junglegrass.png + farming_carrot.png + farming_carrot_1.png + farming_carrot_2.png + farming_carrot_3.png + farming_carrot_4.png + farming_carrot_5.png + farming_carrot_6.png + farming_carrot_7.png + farming_carrot_8.png + +Created by JoseTheCrafter and edited by TenPlus1 (CC BY 3.0): + farming_tomato.png + farming_tomato_1.png + farming_tomato_2.png + farming_tomato_3.png + farming_tomato_4.png + farming_tomato_5.png + farming_tomato_6.png + farming_tomato_7.png + farming_tomato_8.png + +Created by GeMinecraft and edited by TenPlus1 (CC BY 3.0): + farming_corn.png + farming_corn_cob.png + farming_corn_1.png + farming_corn_2.png + farming_corn_3.png + farming_corn_4.png + farming_corn_5.png + farming_corn_6.png + farming_corn_7.png + farming_corn_8.png + +Created by TenPlus1 (CC BY 3.0) + farming_cocoa_1.png + farming_cocoa_2.png + farming_cocoa_3.png + farming_cocoa_beans.png + farming_cookie.png + farming_raspberry_smoothie.png + farming_rhubarb_1.png + farming_rhubarb_2.png + farming_rhubarb_3.png + farming_rhubarb.png + farming_rhubarb_pie.png + farming_hemp*.png + +Created by ademant (CC-BY-3.0) + farming_rye*.png + farming_oat*.png + farming_rice*.png + +Created by PilzAdam and edited by SpaghettiToastBook (CC0): + farming_bread_multigrain.png + +Created by VanessaE and edited by SpaghettiToastBook (CC0): + farming_flour_multigrain.png + +Created by mDiyo (Natura), modified by TenPlus1 (License: CC BY-SA 3.0): + farming_barley.png diff --git a/mods/farming/lucky_block.lua b/mods/farming/lucky_block.lua new file mode 100644 index 00000000..5a69a683 --- /dev/null +++ b/mods/farming/lucky_block.lua @@ -0,0 +1,77 @@ + +-- add lucky blocks + +if minetest.get_modpath("lucky_block") then + + lucky_block:add_blocks({ + {"dro", {"farming:corn"}, 5}, + {"dro", {"farming:coffee_cup_hot"}, 1}, + {"dro", {"farming:bread"}, 5}, + {"nod", "farming:jackolantern", 0}, + {"tro", "farming:jackolantern_on"}, + {"nod", "default:river_water_source", 1}, + {"tel"}, + {"dro", {"farming:trellis", "farming:grapes"}, 5}, + {"dro", {"farming:bottle_ethanol"}, 1}, + {"nod", "farming:melon", 0}, + {"dro", {"farming:donut", "farming:donut_chocolate", "farming:donut_apple"}, 5}, + {"dro", {"farming:hemp_leaf", "farming:hemp_fibre", "farming:seed_hemp"}, 10}, + {"nod", "fire:permanent_flame", 1}, + {"dro", {"farming:chili_pepper", "farming:chili_bowl"}, 5}, + {"dro", {"farming:bowl"}, 3}, + {"dro", {"farming:saucepan"}, 1}, + {"dro", {"farming:pot"}, 1}, + {"dro", {"farming:baking_tray"}, 1}, + {"dro", {"farming:skillet"}, 1}, + {"exp", 4}, + {"dro", {"farming:mortar_pestle"}, 1}, + {"dro", {"farming:cutting_board"}, 1}, + {"dro", {"farming:juicer"}, 1}, + {"dro", {"farming:mixing_bowl"}, 1}, + {"dro", {"farming:hoe_bronze"}, 1}, + {"dro", {"farming:hoe_mese"}, 1}, + {"dro", {"farming:hoe_diamond"}, 1}, + {"dro", {"farming:hoe_bomb"}, 10}, + {"dro", {"farming:turkish_delight"}, 5}, + {"lig"}, + {"dro", {"farming:scythe_mithril"}, 1}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:carrot_8"}, + {"farming:cotton_8", "farming:rhubarb_3"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:pepper_5"}, + {"farming:cotton_8", "farming:onion_5"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:beetroot_5"}, + {"farming:cotton_8", "farming:barley_7"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:corn_8"}, + {"farming:cotton_8", "farming:grapes_8"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:pea_5"}, + {"farming:cotton_8", "farming:coffee_5"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:raspberry_4"}, + {"farming:cotton_8", "farming:tomato_8"}, + }}, + {"sch", "instafarm", 0, true, { + {"farming:wheat_8", "farming:chili_8"}, + {"farming:cotton_8", "farming:cucumber_4"}, + }}, + {"nod", "default:chest", 0, { + {name = "farming:seed_wheat", max = 15}, + {name = "farming:seed_barley", max = 15}, + {name = "farming:seed_barley", max = 15}, + {name = "farming:seed_hemp", max = 15}, + {name = "farming:seed_rye", max = 15}, + {name = "farming:seed_rice", max = 15}, + {name = "farming:seed_oat", max = 15}, + {name = "farming:soil_wet", max = 10}, + }}, + }) +end diff --git a/mods/farming/mapgen.lua b/mods/farming/mapgen.lua new file mode 100644 index 00000000..ca7048df --- /dev/null +++ b/mods/farming/mapgen.lua @@ -0,0 +1,169 @@ + +-- decoration function +local function register_plant(name, min, max, spawnon, spawnby, num, rarety) + + -- do not place on mapgen if no value given (or not true) + if not rarety then + return + end + + -- set rarety value or default to farming.rarety if not a number + rarety = tonumber(rarety) or farming.rarety + + minetest.register_decoration({ + deco_type = "simple", + place_on = spawnon or {"default:dirt_with_grass"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = rarety, + spread = {x = 100, y = 100, z = 100}, + seed = 329, + octaves = 3, + persist = 0.6 + }, + y_min = min, + y_max = max, + decoration = "farming:" .. name, + spawn_by = spawnby, + num_spawn_by = num + }) +end + + +-- add crops to mapgen +register_plant("potato_3", 15, 40, nil, "", -1, farming.potato) +register_plant("tomato_7", 5, 20, nil, "", -1, farming.tomato) +register_plant("corn_7", 12, 22, nil, "", -1, farming.corn) +register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass", + "default:dirt_with_rainforest_litter", + "default:dry_dirt_with_dry_grass"}, "", -1, farming.coffee) +register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry) +register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb) +register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry) +register_plant("beanbush", 18, 35, nil, "", -1, farming.beans) +register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes) +register_plant("onion_5", 5, 22, nil, "", -1, farming.onion) +register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic) +register_plant("pea_5", 25, 50, nil, "", -1, farming.peas) +register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot) +register_plant("mint_4", 1, 75, {"default:dirt_with_grass", +"default:dirt_with_coniferous_litter"}, "group:water", 1, farming.mint) +register_plant("cabbage_6", 2, 10, nil, "", -1, farming.cabbage) + + +if minetest.get_mapgen_setting("mg_name") == "v6" then + + register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot) + register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber) + register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon) + register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin) +else + -- v7 maps have a beach so plants growing near water is limited to 6 high + register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot) + register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber) + register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass", + "default:dirt_with_rainforest_litter"}, "", -1, farming.melon) + register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin) +end + +if farming.hemp then +minetest.register_decoration({ + deco_type = "simple", + place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = tonumber(farming.hemp) or farming.rarety, + spread = {x = 100, y = 100, z = 100}, + seed = 420, + octaves = 3, + persist = 0.6 + }, + y_min = 3, + y_max = 45, + decoration = "farming:hemp_7", + spawn_by = "group:tree", + num_spawn_by = 1 +}) +end + +if farming.chili then +minetest.register_decoration({ + deco_type = "simple", + place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = tonumber(farming.chili) or farming.rarety, + spread = {x = 100, y = 100, z = 100}, + seed = 760, + octaves = 3, + persist = 0.6 + }, + y_min = 5, + y_max = 35, + decoration = {"farming:chili_8"}, + spawn_by = "group:tree", + num_spawn_by = 1 +}) +end + +if farming.pepper then +minetest.register_decoration({ + deco_type = "simple", + place_on = {"default:dirt_with_rainforest_litter"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = tonumber(farming.pepper) or farming.rarety, + spread = {x = 100, y = 100, z = 100}, + seed = 933, + octaves = 3, + persist = 0.6 + }, + y_min = 5, + y_max = 35, + decoration = {"farming:pepper_5"}, + spawn_by = "group:tree", + num_spawn_by = 1 +}) +end + +if farming.pineapple then +minetest.register_decoration({ + deco_type = "simple", + place_on = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = tonumber(farming.pineapple) or farming.rarety, + spread = {x = 100, y = 100, z = 100}, + seed = 917, + octaves = 3, + persist = 0.6 + }, + y_min = 18, + y_max = 30, + decoration = {"farming:pineapple_8"} +}) +end + +minetest.register_decoration({ + name = "farming:cotton_wild", + deco_type = "simple", + place_on = {"default:dry_dirt_with_dry_grass"}, + sidelen = 16, + noise_params = { + offset = -0.1, + scale = 0.1, + spread = {x = 50, y = 50, z = 50}, + seed = 4242, + octaves = 3, + persist = 0.7 + }, + biomes = {"savanna"}, + y_max = 31000, + y_min = 1, + decoration = "farming:cotton_wild" +}) diff --git a/mods/farming/mod.conf b/mods/farming/mod.conf new file mode 100644 index 00000000..80ab8b0b --- /dev/null +++ b/mods/farming/mod.conf @@ -0,0 +1 @@ +name = farming \ No newline at end of file