mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-04 01:20:23 +02:00
Add custom operators (Part 2)
This commit is contained in:
@ -88,7 +88,7 @@ function i3.register_craft(def)
|
||||
end
|
||||
|
||||
for symbol in gmatch(concat(def.grid), ".") do
|
||||
c = c + 1
|
||||
c++
|
||||
def.items[c] = def.key[symbol]
|
||||
end
|
||||
else
|
||||
@ -110,7 +110,7 @@ function i3.register_craft(def)
|
||||
end
|
||||
|
||||
for name in gmatch(concat(items, ","), "[%s%w_:]+") do
|
||||
c = c + 1
|
||||
c++
|
||||
def.items[c] = clean_name(name)
|
||||
end
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ local function drop_table(name, drop)
|
||||
end
|
||||
|
||||
if not di.rarity then
|
||||
count_sure = count_sure + 1
|
||||
count_sure++
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -146,7 +146,7 @@ local function cache_recipes(item)
|
||||
end
|
||||
|
||||
for k, v in pairs(replacements[item]) do
|
||||
k = k + shift
|
||||
k += shift
|
||||
|
||||
if _recipes[k] then
|
||||
_recipes[k].replacements = v
|
||||
|
@ -1,6 +1,5 @@
|
||||
local fmt = string.format
|
||||
local _loadfile = loadfile
|
||||
local var = "[%w%.%[%]_]"
|
||||
local var = "[%w%.%[%]\"\'_]"
|
||||
|
||||
local operators = {
|
||||
["([%+%-%*%^/&|])="] = function(a, b, c)
|
||||
@ -26,6 +25,14 @@ local operators = {
|
||||
[">>"] = function(a, b)
|
||||
return fmt("bit.rshift(%s, %s)", a, b)
|
||||
end,
|
||||
|
||||
["<<="] = function(a, b)
|
||||
return fmt("%s = bit.lshift(%s, %s)", a, a, b)
|
||||
end,
|
||||
|
||||
[">>="] = function(a, b)
|
||||
return fmt("%s = bit.rshift(%s, %s)", a, a, b)
|
||||
end,
|
||||
}
|
||||
|
||||
local function compile(data)
|
||||
@ -61,6 +68,6 @@ local function _load(path, line, data)
|
||||
return l, err
|
||||
end
|
||||
|
||||
function loadfile(path)
|
||||
return _load(path) or _loadfile(path)
|
||||
return function(path)
|
||||
return _load(path) or loadfile(path)
|
||||
end
|
||||
|
Reference in New Issue
Block a user