txt import correct
parent
2b5e2d5f16
commit
e2a2e9300e
|
@ -7,7 +7,7 @@ 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,,,,,,,,,,farming:carrot_baked
|
||||
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,,,,,,,,,,,,,,farming:corn_baked
|
||||
corn,1,,10,8,2,2,,,,1,,1,,,,,,,4,1,,3,35,90,30,,,,,,,,,,,,,,farming:corn_cob
|
||||
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,,,,
|
||||
|
|
|
@ -15,13 +15,14 @@ farming.import_csv = function(infile,def)
|
|||
local file = io.open(infile, "r")
|
||||
local outdata = {}
|
||||
-- reading header with column names
|
||||
local header = file:read():split(",",true)
|
||||
local header = file:read():gsub("\r",""):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 attribs = line:gsub("\r",""):split(",",true)
|
||||
local nrow={groups={}}
|
||||
for i,d in ipairs(attribs) do
|
||||
|
||||
if d ~= "" then
|
||||
local th=header[i]
|
||||
local dsaved = false
|
||||
|
@ -38,7 +39,7 @@ farming.import_csv = function(infile,def)
|
|||
end
|
||||
end
|
||||
if not dsaved then
|
||||
nrow[ th ]=d
|
||||
nrow[th]=d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
17
register.lua
17
register.lua
|
@ -27,12 +27,12 @@ local register_plant_check_def = function(def)
|
|||
end
|
||||
if def.groups["seed_grindable"] then
|
||||
if def.grind == nil then
|
||||
def.grind = "Grinded "..def.description
|
||||
def.grind = minetest.get_current_modname()..":"..def.description.."_grinded"
|
||||
end
|
||||
end
|
||||
if def.groups["seed_roastable"] then
|
||||
if def.roast == nil then
|
||||
def.roast = "Roasted "..def.description
|
||||
def.roast = minetest.get_current_modname()..":"..def.description.."_roasted"
|
||||
end
|
||||
end
|
||||
def.grow_time_min=math.floor(def.grow_time_mean*0.75)
|
||||
|
@ -236,7 +236,7 @@ farming.register_seed=function(sdef)
|
|||
if sdef.eat_hp then
|
||||
seed_def.on_use=minetest.item_eat(sdef.eat_hp)
|
||||
end
|
||||
print(dump(seed_def))
|
||||
-- print(dump(seed_def))
|
||||
minetest.register_node(":" .. sdef.seed_name, seed_def)
|
||||
end
|
||||
|
||||
|
@ -574,8 +574,8 @@ farming.step_on_punch = function(pos, node, puncher, pointed_thing)
|
|||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local def = minetest.registered_nodes[name]
|
||||
print(name)
|
||||
print(dump(def))
|
||||
-- print(name)
|
||||
-- print(dump(def))
|
||||
-- grow
|
||||
if def.groups.punchable == nil then
|
||||
return
|
||||
|
@ -906,7 +906,7 @@ function farming.register_roast(rdef)
|
|||
if rdef.mod_name then
|
||||
mname = rdef.mod_name
|
||||
end
|
||||
local roast_png = roastitem:gsub(":","_")..".pnd"
|
||||
local roast_png = roastitem:gsub(":","_")..".png"
|
||||
|
||||
local roast_def={
|
||||
description = S(rdef.description:gsub("^%l", string.upper).." roasted"),
|
||||
|
@ -952,6 +952,9 @@ function farming.register_grind(rdef)
|
|||
if rdef.grind then
|
||||
grinditem = rdef.grind
|
||||
end
|
||||
print(grinditem)
|
||||
local desc = grinditem:split(":")[2]
|
||||
desc = desc:gsub("_"," ")
|
||||
local mname = minetest.get_current_modname()
|
||||
if rdef.mod_name then
|
||||
mname = rdef.mod_name
|
||||
|
@ -959,7 +962,7 @@ function farming.register_grind(rdef)
|
|||
local grind_png = grinditem:gsub(":","_")..".png"
|
||||
|
||||
local grind_def={
|
||||
description = S(rdef.description:gsub("^%l", string.upper).." roasted"),
|
||||
description = S(desc:gsub("^%l", string.upper).." roasted"),
|
||||
inventory_image = grind_png,
|
||||
groups = rdef.groups or {flammable = 2},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue