created register functions for grinding and roasting #8

master
ademant 2018-10-17 09:41:36 +02:00
parent d078708013
commit 94926b754f
5 changed files with 139 additions and 111 deletions

View File

@ -1,44 +1,6 @@
local S = farming.intllib
local modname=minetest.get_current_modname()
-- generate "seed" out of harvest and trellis
farming.trellis_seed = function(grain_name,seed_name)
local mname = grain_name:split(":")[1]
local pname = grain_name:split(":")[2]
minetest.register_craft({
type = "shapeless",
output = mname..":seed_"..pname.." 1",
recipe = {
modname..":trellis",seed_name
},
})
end
-- define seed crafting
function farming.seed_craft(grain_name,straw_name)
local mname = grain_name:split(":")[1]
local pname = grain_name:split(":")[2]
if straw_name == nil then
local straw_name = "farming:straw"
end
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:farming_flail", modname..":flail"},
{grain_name,straw_name}},
})
minetest.register_craft({
type = "shapeless",
output = mname..":seed_"..pname.." 1",
recipe = {
modname..":flail",grain_name
},
replacements = {{"group:farming_flail", modname..":flail"},
{grain_name,straw_name}},
})
end
-- defining template for roasting
local function roast_seed(seed_name,roast_name,cooktime)

View File

@ -42,6 +42,11 @@ Actual columns:
You get the trellis back by digging the plant at any stage.
for_coffee void
any value extension to define crafting recipes to brew coffee out of seed
seed_roastable
any value seed can be roasted in a oven, needs "crop_roasted.png"
value is used as roast time
seed_grindable
any value seed can be grinded, e.g. in a coffee grinder, needs "crop_grind.png" or value in grind
temperature_min/_max Range of temperature inside the crop can grow.
humidity_min/_max Range of humidity
elevation_min/_max Height range the crop can be found
@ -58,64 +63,31 @@ Actual columns:
seed_drop name of seed you get from plant: grapes drops seed which normally lead to wild wine.
Only with a trellis you get cultured whine with higher harvest.
With normal grapes and a trellis you get the "seed" for cultured wine.
grind name of item for grinded seed
]]
local S = farming.intllib
farming.path = minetest.get_modpath("farming")
local has_value = farming.has_value
local crop_definition = {}
local crop_numeric_values = {"rarety","steps","harvest_max","eat_hp",
local crop_cols={
col_num={"rarety","steps","harvest_max","eat_hp",
"temperature_min","temperature_max","humidity_min","humidity_max",
"elevation_min","elevation_max","light_min","light_max",
"infect_rate_base","infect_rate_monoculture","spread_rate","grow_time_mean"}
local crop_groups =
{"to_culture","to_dig","has_harvest","on_soil","punchable","infectable",
"seed_extractable","use_flail","use_trellis","snappy","infection_defence"}
local crop_definition = farming.import_csv(farming.path.."/crops.txt",{
col_num=crop_numeric_values,
groups_num=crop_groups})
"infect_rate_base","infect_rate_monoculture","spread_rate","grow_time_mean","roast_time"},
groups_num={"to_culture","to_dig","has_harvest","on_soil","punchable","infectable",
"seed_extractable","use_flail","use_trellis","snappy","infection_defence","seed_roastable","seed_grindable"}}
local crop_definition = farming.import_csv(farming.path.."/crops.txt",crop_cols)
print(dump(crop_definition))
--[[
-- import configurations from crops.csv
local file = io.open(farming.path .. "/crops.txt", "r")
-- reading header with column names
local header = file:read():split(",",true)
-- read each line, split in separat fields and stores in array
-- by header the value is stored as numeric, in the group environment or as text
for line in file:lines() do
local attribs = line:split(",",true)
local nrow={groups={}}
for i,d in ipairs(attribs) do
if d ~= "" then
local th=header[i]
if has_value(crop_numeric_values,th) then
nrow[th] = tonumber(d)
else
if has_value(crop_groups,th) then
nrow.groups[th]=tonumber(d)
else
nrow[header[i] ]=d
end
end
end
end
if nrow.enabled then
crop_definition[nrow.name]=nrow
end
end
file:close()
]]
-- for the default entry is checked, which numeric values are filled
-- this values are copied into void fields of the crops
if crop_definition["default"] ~= nil then
default_crop = crop_definition["default"]
local test_values = {}
for i,d in pairs(crop_numeric_values) do
-- check, which numeric columns exist in default entry
for i,d in pairs(crop_cols.col_num) do
if default_crop[d] ~= nil then
table.insert(test_values,1,d)
end
@ -143,3 +115,4 @@ for i,tdef in pairs(crop_definition) do
end
end
end

View File

@ -1,30 +1,30 @@
name,enabled,next_plant,rarety,steps,harvest_max,eat_hp,to_culture,to_dig,has_harvest,on_soil,punchable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,snappy,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,straw,culture_rate,seed_drop
default,1,,10,8,2,1,,,,,,,,,,,,,3,15,80,10,80,0,200,11,14,1E-05,0.001,0.001,12,,,
barley,1,,10,7,2,,,,1,1,,1,,,,1,,1,3,25,,30,,,,,,,,,,farming:straw,,
beetroot,1,,10,5,2,2,,1,,1,,,,,,,,,3,35,,30,,,,9,,,,,,,,
blackberry,1,,10,4,2,1,,,,,1,,,,,,,,3,,90,20,,,,9,,,,,,,,
blueberry,1,,10,4,2,1,,,,,1,,,,,,,,3,45,90,40,90,,,9,,,,,,,,
carrot,1,,10,8,2,2,,1,,1,,,,,,,,,3,45,,30,90,,,8,,,,,,,,
chili,1,,20,8,2,1,,,,,1,,,,,,,,3,45,90,,,50,1000,,,,,,,,,
coffee,1,,20,5,2,1,,,,,1,,,,,,,1,3,50,120,50,150,50,1000,12,,,,,,,,
corn,1,,10,8,2,2,,,,1,,1,,,,,,,3,35,90,30,,,,,,,,,,,,
cotton,1,,10,8,2,,,,1,1,,1,,,,1,,,3,45,90,20,,,,12,,,,,,,,
culturewheat,1,,100,4,3,,1,,1,1,,1,,,,1,,1,3,25,,40,,,,10,,,,,100,farming:straw,,
flax,,,10,7,2,,,,1,1,,1,,,,1,,,3,25,,30,,,,,,,,,,farming:flaw,,
garlic,,,10,5,2,1,,1,,1,,,,,,,,,3,,,,,,,,,,,,,,,
grapes,1,,10,8,3,2,1,,,1,1,1,,,,,1,,3,,,,,,,,,,,,,,,wildgrapes
hemp,1,,10,8,2,,,,1,,,,,,,1,,,3,,120,,,,,6,,,,1E-05,9,farming:hemp_fibre,,
hop,1,,10,7,3,1,1,,,1,1,1,,,,,1,,3,,,,,,,,,,,,,,,wildhop
mustard,1,,10,5,2,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,,
potato,1,,10,4,2,2,,,,1,,1,,,,,,,3,,,,,,,,,,,,,,,
raspberry,1,,10,4,2,1,,,,,1,,,,,,,,3,,,,,,,9,,,,,,,,
rhubarb,1,,10,3,2,2,,1,,1,,,,,,,,,3,,,,,,,9,,,,,,,,
spelt,1,,10,7,2,,,,1,1,,1,,,,1,,,3,,,,,,,,,,,,,farming:straw,,
strawberry,1,,10,4,2,1,,,,,1,,,,,,,,3,,,,,,,9,,,,,,,,
tea,,,20,5,2,1,,,,,1,,,1,,,,,3,30,70,30,70,50,,,,,,,,,,
tobaco,1,,10,8,2,,,,1,1,1,,2,,,,,,3,,,,,,,,,,,,,,,
tomato,,,10,8,2,1,,,1,1,1,1,,,,,1,,3,,,,,,,,,,,,,,,
nettle,1,,10,5,2,1,,,1,,,,1,,,1,,,3,5,150,,100,,2000,6,,,,,8,farming:urtica_fibre,,
wheat,1,culturewheat,10,8,2,,,,1,1,,1,,,,1,,1,3,,,,,,,,,,,,,farming:straw,10,
wildhop,1,hop,10,6,2,,,,,,,,,,1,,,,3,,,,,,,,,,,,,,5,
wildgrapes,1,grapes,10,4,2,1,,,,,,,,,1,,,,3,,,,,,,,,,,,,,5,
name,enabled,next_plant,rarety,steps,harvest_max,eat_hp,to_culture,to_dig,has_harvest,on_soil,punchable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,seed_roastable,seed_grindable,flour,snappy,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,straw,culture_rate,seed_drop,grind
default,1,,10,8,2,1,,,,,,,,,,,,,,,,3,15,80,10,80,0,200,11,14,1E-05,0.001,0.001,12,,,,
barley,1,,10,7,2,,,,1,1,,1,,,,1,,1,3,,1,3,25,,30,,,,,,,,,,farming:straw,,,farming:flour
beetroot,1,,10,5,2,2,,1,,1,,,,,,,,,,,,3,35,,30,,,,9,,,,,,,,,
blackberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,,90,20,,,,9,,,,,,,,,
blueberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,45,90,40,90,,,9,,,,,,,,,
carrot,1,,10,8,2,2,,1,,1,,,,,,,,,2,,,3,45,,30,90,,,8,,,,,,,,,
chili,1,,20,8,2,1,,,,,1,,,,,,,,,,,3,45,90,,,50,1000,,,,,,,,,,
coffee,1,,20,5,2,1,,,,,1,,,,,,,1,4,,,3,50,120,50,150,50,1000,12,,,,,,,,,
corn,1,,10,8,2,2,,,,1,,1,,,,,,,4,1,,3,35,90,30,,,,,,,,,,,,,
cotton,1,,10,8,2,,,,1,1,,1,,,,1,,,,,,3,45,90,20,,,,12,,,,,,,,,
culturewheat,1,,100,4,3,,1,,1,1,,1,,,,1,,1,3,,1,3,25,,40,,,,10,,,,,100,farming:straw,,,farming:flour
flax,,,10,7,2,,,,1,1,,1,,,,1,,,,,,3,25,,30,,,,,,,,,,farming:flaw,,,
garlic,,,10,5,2,1,,1,,1,,,,,,,,,3,,,3,,,,,,,,,,,,,,,,
grapes,1,,10,8,3,2,1,,,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,wildgrapes,
hemp,1,,10,8,2,,,,1,,,,,,,1,,,,,,3,,120,,,,,6,,,,1E-05,9,farming:hemp_fibre,,,
hop,1,,10,7,3,1,1,,,1,1,1,,,,,1,,4,,,3,,,,,,,,,,,,,,,wildhop,
mustard,1,,10,5,2,,,,,,,1,,,,,,,,1,,3,,,,,,,,,,,,,,,,
potato,1,,10,4,2,2,,,,1,,1,,,,,,,4,1,,3,,,,,,,,,,,,,,,,
raspberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,,,,,,,9,,,,,,,,,
rhubarb,1,,10,3,2,2,,1,,1,,,,,,,,,,,,3,,,,,,,9,,,,,,,,,
spelt,1,,10,7,2,,,,1,1,,1,,,,1,,,3,,1,3,,,,,,,,,,,,,farming:straw,,,farming:flour
strawberry,1,,10,4,2,1,,,,,1,,,,,,,,,,,3,,,,,,,9,,,,,,,,,
tea,,,20,5,2,1,,,,,1,,,1,,,,,4,,,3,30,70,30,70,50,,,,,,,,,,,
tobaco,1,,10,8,2,,,,1,1,1,,2,,,,,,4,,,3,,,,,,,,,,,,,,,,
tomato,,,10,8,2,1,,,1,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,,
nettle,1,,10,5,2,1,,,1,,,,1,,,1,,,2,,,3,5,150,,100,,2000,6,,,,,8,farming:nettle_fibre,,,
wheat,1,culturewheat,10,8,2,,,,1,1,,1,,,,1,,1,3,,1,3,,,,,,,,,,,,,farming:straw,10,,farming:flour
wildhop,1,hop,10,6,2,,,,,,,,,,1,,,,4,,,3,,,,,,,,,,,,,,5,,
wildgrapes,1,grapes,10,4,2,1,,,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,5,,

View File

@ -3,6 +3,7 @@
farming = {}
farming.path = minetest.get_modpath("farming")
farming.config = minetest.get_mod_storage()
farming.modname=minetest.get_current_modname()
local S = dofile(farming.path .. "/intllib.lua")
farming.intllib = S

View File

@ -18,6 +18,9 @@ local register_plant_check_def = function(def)
end
if not def.description then
def.description = "Seed"
if def.name then
def.description = def.name
end
end
if not def.fertility then
def.fertility = {"grassland"}
@ -38,13 +41,15 @@ farming.register_plant = function(def)
-- local definitions
def.step_name=def.mod_name..":"..def.name
def.seed_name=def.mod_name..":seed_"..def.name
-- check if seed to drop exist
if def.seed_drop ~= nil then
def.drop_seed_name = def.mod_name..":seed_"..def.seed_drop
def.seed_name = def.mod_name..":seed_"..def.seed_drop
end
def.plant_name = def.name
-- if plant has harvest then registering
if def.groups["has_harvest"] ~= nil then
-- def.harvest_png=def.mod_name.."_"..def.name..".png"
def.harvest_name = def.step_name
farming.register_harvest(def)
else
def.harvest_name=def.seed_name
@ -829,3 +834,90 @@ farming.tool_on_dig = function(itemstack, user, pointed_thing, uses)
end
return itemstack
end
-- generate "seed" out of harvest and trellis
farming.trellis_seed = function(gdef)
if gdef.seed_name == nil then
return
end
minetest.register_craft({
type = "shapeless",
output = gdef.seed_name.." 1",
recipe = {
farming.modname..":trellis",seed_name
},
})
end
-- define seed crafting
function farming.seed_craft(gdef)
if gdef.seed_name == nil then
return
end
if gdef.harvest_name == nil then
return
end
local straw_name = "farming:straw"
if gdef.straw_name ~= nil then
straw_name = gdef.straw_name
end
minetest.register_craft({
type = "shapeless",
output = gdef.seed_name.." 1",
recipe = {
farming.modname..":flail",gdef.harvest_name
},
replacements = {{"group:farming_flail", farming.modname..":flail"},
{gdef.harvest_name,straw_name}},
})
end
function farming.register_roast(rdef)
if rdef.seed_name == nil then
return
end
if rdef.step_name == nil then
return
end
local roastitem = rdef.step_name.."_roasted"
if rdef.roast_name then
roastitem = rdef.roast_name
end
local mname = minetest.get_current_modname()
if rdef.mod_name then
mname = rdef.mod_name
end
local roast_png = mname.."_"..rdef.plant_name.."_roasted.png"
local roast_def={
description = S(rdef.description:gsub("^%l", string.upper).." roasted"),
inventory_image = roast_png,
groups = rdef.groups or {flammable = 2},
}
for _,coln in ipairs({"plant_name"}) do
roast_def[coln] = rdef[coln]
end
for _,coln in ipairs({"seed_roastable"}) do
if rdef.groups[coln] then
roast_def.groups[coln] = rdef.groups[coln]
end
end
if rdef.eat_hp then
roast_def.on_use=minetest.item_eat(rdef.eat_hp*2)
end
minetest.register_craftitem(":" .. roastitem, roast_def)
local cooktime = 3
if rdef.roast_time then
cooktime = rdef.roast_time
end
minetest.register_craft({
type = "cooking",
cooktime = cooktime or 3,
output = roastitem,
recipe = rdef.seed_name
})
end