extend to potato

master
A. Demant 2018-09-24 17:55:45 +02:00
parent bd4145842c
commit 482d1c3f78
27 changed files with 417 additions and 113 deletions

View File

@ -6,6 +6,7 @@ Authors of source code
----------------------
Originally by PilzAdam (MIT)
webdesigner97 (MIT)
ademant (MIT)
Various Minetest developers and contributors (MIT)
Authors of media (textures)
@ -18,9 +19,6 @@ Created by PilzAdam (CC BY 3.0):
farming_string.png
Created by BlockMen (CC BY 3.0):
farming_tool_diamondhoe.png
farming_tool_mesehoe.png
farming_tool_bronzehoe.png
farming_tool_steelhoe.png
farming_tool_stonehoe.png
farming_tool_woodhoe.png
@ -38,3 +36,7 @@ Created by Gambit (CC BY 3.0):
Created by Napiophelios (CC BY-SA 3.0):
farming_cotton.png
Created by ademant (CC BY 3.0):
farming_tool_flail.png
farming_tool_coffee_grinder.png (based on art by cactus_cowboy on openclipart.org)

View File

@ -66,7 +66,7 @@ farming.register_plant = function(name, def)
def.switch_drop_count = def.steps
end
end
if not def.spawn then
if not def.spawnon then
def.spawnon = { spawnon = {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
@ -78,7 +78,7 @@ farming.register_plant = function(name, def)
def.spawnon.spawn_min = def.spawnon.spawn_min or 0
def.spawnon.spawn_max = def.spawnon.spawn_max or 42
def.spawnon.spawnby = def.spawnon.spawn_by or nil
def.spawnon.scale = def.spawnon.scale or 0.006
def.spawnon.scale = def.spawnon.scale or farming.rarety
def.spawnon.spawn_num = def.spawnon.spawn_num or -1
end
@ -157,19 +157,27 @@ farming.register_plant = function(name, def)
if def.steps ~= 1 then
base_rarity = 8 - (i - 1) * 7 / (def.steps - 1)
end
-- create drop table
local drop = {
items = {
{items = {harvest_name}},
}
}
-- if seeds are not crafted out of harvest, drop additional seeds
if def.groups.drop_seed ~= nil then
table.insert(drop.items,1,{items={seed_name}})
end
-- with higher grow levels you harvest more
if (i >= def.switch_drop_count ) then
table.insert(drop.items,1,{items={harvest_name},rarity=base_rarity})
-- drop.items=table_insert(drop.items,{items={harvest_name},rarity=base_rarity})
if def.groups.drop_seed ~= nil then
table.insert(drop.items,1,{items={seed_name},rarity=base_rarity})
end
end
-- at the end stage you can harvest by change a cultured seed (if defined)
if (i == def.steps and def.next_plant ~= nil) then
def.next_plant_rarity = def.next_plant_rarity or base_rarity*2
table.insert(drop.items,1,{items={def.next_plant},rarity=def.next_plant_rarity})
-- drop.items = table_insert(drop.items,{items=def.next_plant,rarity=def.next_plant_rarity})
end
local nodegroups = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1}
@ -205,10 +213,6 @@ farming.register_plant = function(name, def)
})
end
-- replacement LBM for pre-nodetimer plants
minetest.register_lbm({
name = ":" .. mname .. ":start_nodetimer_" .. pname,
@ -219,26 +223,32 @@ farming.register_plant = function(name, def)
})
-- register mapgen
print("spawn on "..def.spawnon.spawnon[1])
minetest.register_decoration({
deco_type = "simple",
place_on = def.spawnon.spawnon,
sidelen = 16,
noise_params = {
offset = 0,
scale = def.spawnon.scale, -- 0.006,
spread = {x = 100, y = 100, z = 100},
seed = 329,
octaves = 3,
persist = 0.6
},
y_min = def.spawnon.spawn_min,
y_max = def.spawnon.spawn_max,
decoration = harvest_name.."_1",
spawn_by = def.spawnon.spawnby,
num_spawn_by = def.spawnon.spawn_num,
})
print("spawn "..dump(def.spawnon))
print("scale "..def.spawnon.scale)
local mapgen_level = def.switch_drop_count - 1
print(mapgen_level)
for i = 1,math.max(mapgen_level,1) do
for j,onpl in ipairs(def.spawnon.spawnon) do
minetest.register_decoration({
deco_type = "simple",
place_on = onpl,
sidelen = 16,
noise_params = {
offset = 0.12 - 0.08*i,
scale = def.spawnon.scale, -- 0.006,
spread = {x = 200, y = 200, z = 200},
seed = 329,
octaves = 3,
persist = 0.6
},
y_min = def.spawnon.spawn_min,
y_max = def.spawnon.spawn_max,
decoration = harvest_name.."_"..i,
spawn_by = def.spawnon.spawnby,
num_spawn_by = def.spawnon.spawn_num,
})
end
end
-- Return
local r = {
seed = mname .. ":seed_" .. pname,

39
config.lua Normal file
View File

@ -0,0 +1,39 @@
--[[
Farming settings can be changed here and kept inside mod folder
even after the mod has been updated, or you can place inside
world folder for map specific settings.
--]]
-- true to enable crop/food in-game and on mapgen
farming.carrot = true
farming.potato = true
farming.tomato = true
farming.cucumber = true
farming.corn = true
farming.coffee = true
farming.melon = true
farming.pumpkin = true
farming.cocoa = true
farming.raspberry = true
farming.blueberry = true
farming.rhubarb = true
farming.beans = true
farming.grapes = true
farming.barley = true
farming.chili = true
farming.hemp = true
farming.onion = true
farming.garlic = true
farming.pepper = true
farming.pineapple = true
farming.peas = true
farming.beetroot = true
-- rarety of crops on map, default is 0.001 (higher number = more crops)
farming.rarety = 0.002
-- node type, where grain can be randomly found
farming.change_soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_rainforest_litter",
"default:dirt_with_coniferous_litter","default:permafrost_with_moss"}
farming.change_soil_desert = {"default:desert_sand"}

104
craft.lua Normal file
View File

@ -0,0 +1,104 @@
local S = farming.intllib
local modname=minetest.get_current_modname()
-- define seed crafting
local function seed_craft(grain_name)
local mname = grain_name:split(":")[1]
local pname = grain_name:split(":")[2]
minetest.register_craft({
type = "shapeless",
output = mname..":seed_"..pname.." 8",
recipe = {
grain_name,grain_name,grain_name,grain_name, modname..":flail",grain_name,grain_name,grain_name,grain_name
},
replacements = {{"group:food_flail", modname..":flail"},
{"group:food_wheat","farming:straw"}},
})
minetest.register_craft({
type = "shapeless",
output = mname..":seed_"..pname.." 1",
recipe = {
grain_name, modname..":flail"
},
replacements = {{"group:food_flail", modname..":flail"},
{"group:food_wheat","farming:straw"}},
})
minetest.register_craft({
type = "shapeless",
output = mname..":seed_"..pname.." 1",
recipe = {
modname..":flail",grain_name
},
replacements = {{"group:food_flail", modname..":flail"},
{"group:food_wheat","farming:straw"}},
})
end
-- defining template for roasting
local function roast_seed(seed_name,roast_name,cooktime)
minetest.register_craft({
type = "cooking",
cooktime = cooktime or 3,
output = roast_name,
recipe = seed_name
})
end
-- craft flour with mortar
-- minetest.clear_craft({output="farming:flour"})
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {
"group:seed", "group:seed", "group:seed",
"group:seed", modname..":mortar_pestle"
},
replacements = {{"group:food_mortar_pestle", modname..":mortar_pestle"}},
})
seed_craft("farming:wheat")
seed_craft("farming:barley")
roast_seed("farming:seed_barley","farming:seed_barley_roasted")
roast_seed("farming:seed_wheat","farming_grain:seed_wheat_roasted")
minetest.register_craft({
type = "shapeless",
output = modname..":grain_powder",
recipe = {
"group:food_grain_roasted", modname..":coffee_grinder"
},
replacements = {{"group:food_coffee_grinder", modname..":coffee_grinder"}},
})
minetest.register_craft( {
output = modname..":grain_coffee_cup",
type = "shapeless",
recipe = {"vessels:drinking_glass", "group:food_grain_powder",
"bucket:bucket_water"},
replacements = {
{"bucket:bucket_water", "bucket:bucket_empty"},
}
})
minetest.register_craftitem("farming:bread", {
description = "Bread",
inventory_image = "farming_bread.png",
on_use = minetest.item_eat(5),
groups = {food_bread = 1, flammable = 2},
})
minetest.register_craft({
type = "cooking",
cooktime = 15,
output = "farming:bread",
recipe = "farming:flour"
})
minetest.register_craftitem("farming:flour", {
description = "Flour",
inventory_image = "farming_flour.png",
groups = {food_flour = 1, flammable = 1},
})

22
crops/barley.lua Normal file
View File

@ -0,0 +1,22 @@
-- Barley
farming.register_plant("farming:barley", {
description = "Barley Seed",
paramtype2 = "meshoptions",
inventory_image = "farming_barley_seed.png",
steps = 8,
switch_drop_count = 6, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})

39
crops/cotton.lua Normal file
View File

@ -0,0 +1,39 @@
-- Cotton
farming.register_plant("farming:cotton", {
description = "Cotton Seed",
inventory_image = "farming_cotton_seed.png",
steps = 8,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland", "desert"},
groups = {flammable = 4,drop_seed=1},
spawnon = { spawnon = farming.change_soil_desert or {"default:desert_sand"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})
minetest.register_craftitem("farming:string", {
description = "String",
inventory_image = "farming_string.png",
groups = {flammable = 2},
})
minetest.register_craft({
output = "wool:white",
recipe = {
{"farming:cotton", "farming:cotton"},
{"farming:cotton", "farming:cotton"},
}
})
minetest.register_craft({
output = "farming:string 2",
recipe = {
{"farming:cotton"},
{"farming:cotton"},
}
})

22
crops/potato.lua Normal file
View File

@ -0,0 +1,22 @@
-- Potato
farming.register_plant("farming:potato", {
description = "Potato",
paramtype2 = "meshoptions",
inventory_image = "farming_potato.png",
steps = 4,
switch_drop_count = 3, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4,no_seed=1},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})

22
crops/wheat.lua Normal file
View File

@ -0,0 +1,22 @@
-- WHEAT
farming.register_plant("farming:wheat", {
description = "Wheat Seed",
paramtype2 = "meshoptions",
inventory_image = "farming_wheat_seed.png",
steps = 8,
switch_drop_count = 6, -- at which stage more harvest
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
place_param2 = 3,
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
spawn_min = 0,
spawn_max = 42,
spawnby = nil,
scale = 0.006, -- 0.006
spawn_num = -1}
})

View File

@ -1,3 +1,4 @@
default
30biomes?
intllib?
wool?
stairs?

View File

@ -3,91 +3,43 @@
farming = {}
farming.path = minetest.get_modpath("farming")
local S = dofile(farming.path .. "/intllib.lua")
farming.intllib = S
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- start loading from "..minetest.get_modpath(minetest.get_current_modname()))
-- Load files
farming.rarety = 0.002 -- 0.006
farming.potato = minetest.settings:get("farming.potato") or true
farming.wheat = minetest.settings:get("farming.wheat") or true
farming.cotton = minetest.settings:get("farming.cotton") or true
dofile(farming.path .. "/config.lua")
--[[
for i,inp in ipairs({farming.path,minetest.get_worldpath}) do
print(inp.."/farming.conf")
local inconf = io.open(inp.."/farming.conf", "r")
if inconf then
dofile(inp .. "/farming.conf")
inp:close()
inp = nil
end
end
]]
dofile(farming.path .. "/api.lua")
dofile(farming.path .. "/api_ng.lua")
dofile(farming.path .. "/nodes.lua")
dofile(farming.path .. "/hoes.lua")
dofile(farming.path .. "/utensils.lua")
dofile(farming.path .. "/craft.lua")
-- WHEAT
dofile(farming.path .. "/crops/wheat.lua")
dofile(farming.path .. "/crops/potato.lua")
dofile(farming.path .. "/crops/barley.lua")
dofile(farming.path .. "/crops/cotton.lua")
farming.register_plant("farming:wheat", {
description = "Wheat Seed",
paramtype2 = "meshoptions",
inventory_image = "farming_wheat_seed.png",
steps = 8,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {food_wheat = 1, flammable = 4},
place_param2 = 3,
})
minetest.register_craftitem("farming:flour", {
description = "Flour",
inventory_image = "farming_flour.png",
groups = {food_flour = 1, flammable = 1},
})
minetest.register_craftitem("farming:bread", {
description = "Bread",
inventory_image = "farming_bread.png",
on_use = minetest.item_eat(5),
groups = {food_bread = 1, flammable = 2},
})
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
})
minetest.register_craft({
type = "cooking",
cooktime = 15,
output = "farming:bread",
recipe = "farming:flour"
})
-- Cotton
farming.register_plant("farming:cotton", {
description = "Cotton Seed",
inventory_image = "farming_cotton_seed.png",
steps = 8,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland", "desert"},
groups = {flammable = 4},
})
minetest.register_craftitem("farming:string", {
description = "String",
inventory_image = "farming_string.png",
groups = {flammable = 2},
})
minetest.register_craft({
output = "wool:white",
recipe = {
{"farming:cotton", "farming:cotton"},
{"farming:cotton", "farming:cotton"},
}
})
minetest.register_craft({
output = "farming:string 2",
recipe = {
{"farming:cotton"},
{"farming:cotton"},
}
})
-- Straw

45
intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- 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

39
locale/de.po Normal file
View File

@ -0,0 +1,39 @@
# German Translation for farming mod.
# Copyright (C) 2017
# This file is distributed under the same license as the farming package.
# Xanthin.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 1.27\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-31 HO:MI+ZONE\n"
"PO-Revision-Date: 2016-03-31 HO:MI+ZONE\n"
"Last-Translator: Xanthin\n"
"Language-Team: \n"
"Language: German \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: spelt.lua
msgid "Spelt"
msgstr "Dinkel"
#: spelt.lua
msgid "Spelt Seed"
msgstr "Dinkelkörner"
#: spelt.lua
msgid "Roasted Spelt"
msgstr "Gerösteter Dinkel"
#: spelt.lua
msgid "Spelt Coffee"
msgstr "Dinkelkaffee"
#: spelt.lua
msgid "Cup of Spelt Coffee"
msgstr "Tasse Dinkelkaffee"

View File

@ -8,12 +8,24 @@ local add_soil = function(item,soil)
})
end
local change_soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_rainforest_litter",
"default:dirt_with_coniferous_litter"}
for i,v in ipairs(change_soil) do
-- override grass items
if (farming.change_soil == nil) then
farming.change_soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_rainforest_litter",
"default:dirt_with_coniferous_litter","default:permafrost_with_moss"}
end
for i,v in ipairs(farming.change_soil) do
add_soil(v,"farming:soil")
end
-- override desert items
if (farming.change_soil_desert == nil) then
farming.change_soil_desert = {"default:desert_sand"}
end
for i,v in ipairs(farming.change_soil_desert) do
add_soil(v,"farming:desert_sand_soil")
end
-- register nodes
minetest.register_node("farming:soil", {
description = "Soil",
tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
@ -40,11 +52,6 @@ minetest.register_node("farming:soil_wet", {
}
})
local change_soil_desert = {"default:desert_sand"}
for i,v in ipairs(change_soil_desert) do
add_soil(v,"farming:desert_sand_soil")
end
minetest.register_node("farming:desert_sand_soil", {
description = "Desert Sand Soil",
drop = "default:desert_sand",

BIN
textures/farming_barley.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
textures/farming_potato.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B