mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-27 11:20:40 +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
|
end
|
||||||
|
|
||||||
local function clean_name(item)
|
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)
|
item = sub(item, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -454,10 +454,6 @@ function i3.register_craft_type(name, def)
|
|||||||
def.description = ""
|
def.description = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_str(def.icon) then
|
|
||||||
def.icon = ""
|
|
||||||
end
|
|
||||||
|
|
||||||
craft_types[name] = def
|
craft_types[name] = def
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -538,7 +534,6 @@ function i3.register_craft(def)
|
|||||||
def.items = {}
|
def.items = {}
|
||||||
|
|
||||||
for i = 1, len do
|
for i = 1, len do
|
||||||
items[i] = items[i]:gsub(",", ", ")
|
|
||||||
local rlen = #split(items[i], ",")
|
local rlen = #split(items[i], ",")
|
||||||
|
|
||||||
if rlen > width then
|
if rlen > width then
|
||||||
@ -548,13 +543,13 @@ function i3.register_craft(def)
|
|||||||
|
|
||||||
for i = 1, len do
|
for i = 1, len do
|
||||||
while #split(items[i], ",") < width do
|
while #split(items[i], ",") < width do
|
||||||
items[i] = items[i] .. ", "
|
items[i] = fmt("%s,", items[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name in gmatch(concat(items, ","), "[%s%w_:]+") do
|
for name in gmatch(concat(items, ","), "[%s%w_:]+") do
|
||||||
c = c + 1
|
c = c + 1
|
||||||
def.items[c] = match(name, "%S+")
|
def.items[c] = clean_name(name)
|
||||||
end
|
end
|
||||||
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({
|
i3.register_craft({
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
@ -7,7 +12,7 @@ i3.register_craft({
|
|||||||
},
|
},
|
||||||
key = {
|
key = {
|
||||||
['#'] = "default:wood",
|
['#'] = "default:wood",
|
||||||
['X'] = "default:glass",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user