mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-26 02:40:38 +01:00
Fix some issues with register_cratf()
This commit is contained in:
parent
056d4a3dde
commit
451dde2a73
11
init.lua
11
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
|
||||
|
||||
|
@ -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",
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user