diff --git a/init.lua b/init.lua index f22ba6b..98986ce 100644 --- a/init.lua +++ b/init.lua @@ -316,7 +316,7 @@ local function fmt(elem, ...) end local function clean_name(item) - if sub(item, 1, 1) == ":" then + if sub(item, 1, 1) == ":" or sub(item, 1, 1) == " " then item = sub(item, 2) end @@ -454,10 +454,6 @@ function i3.register_craft_type(name, def) def.description = "" end - if not is_str(def.icon) then - def.icon = "" - end - craft_types[name] = def end @@ -538,7 +534,6 @@ function i3.register_craft(def) def.items = {} for i = 1, len do - items[i] = items[i]:gsub(",", ", ") local rlen = #split(items[i], ",") if rlen > width then @@ -548,13 +543,13 @@ function i3.register_craft(def) for i = 1, len do while #split(items[i], ",") < width do - items[i] = items[i] .. ", " + items[i] = fmt("%s,", items[i]) end end for name in gmatch(concat(items, ","), "[%s%w_:]+") do c = c + 1 - def.items[c] = match(name, "%S+") + def.items[c] = clean_name(name) end end diff --git a/test_custom_recipes.lua b/test_custom_recipes.lua index 0c19925..68c2f41 100644 --- a/test_custom_recipes.lua +++ b/test_custom_recipes.lua @@ -1,3 +1,8 @@ +i3.register_craft({ + result = "default:ladder_wood", + items = {"default:copper_ingot 7, default:tin_ingot", "default:steel_ingot 2"}, +}) + i3.register_craft({ grid = { "X #", @@ -7,7 +12,7 @@ i3.register_craft({ }, key = { ['#'] = "default:wood", - ['X'] = "default:glass", + ['X'] = "default:glass 2", }, result = "default:mese 3", })