mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-24 01:40:38 +01:00
Tweak preprocessor to add -- decrement
This commit is contained in:
parent
72d4a5d4b8
commit
3dfcd95c6f
2
init.lua
2
init.lua
@ -63,7 +63,7 @@ i3 = {
|
||||
caches = lf"/src/caches.lua",
|
||||
callbacks = lf"/src/callbacks.lua",
|
||||
common = lf"/src/common.lua",
|
||||
compress = lf"/src/compress.lua",
|
||||
compress = lf"/src/compression.lua",
|
||||
detached = lf"/src/detached_inv.lua",
|
||||
fields = lf"/src/fields.lua",
|
||||
groups = lf"/src/groups.lua",
|
||||
|
@ -51,6 +51,10 @@ local function compile(data)
|
||||
end
|
||||
end)
|
||||
|
||||
data = data:gsub("([%w_]+)-%-\n", function(a)
|
||||
return fmt("%s = %s - 1", a, a)
|
||||
end)
|
||||
|
||||
for op, func in pairs(operators) do
|
||||
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ local files = {
|
||||
"caches",
|
||||
"callbacks",
|
||||
"common",
|
||||
"compress",
|
||||
"compression",
|
||||
"detached_inv",
|
||||
"fields",
|
||||
"groups",
|
||||
@ -91,6 +91,10 @@ local function compile(data)
|
||||
end
|
||||
end)
|
||||
|
||||
data = data:gsub("([%w_]+)-%-\n", function(a)
|
||||
return fmt("%s = %s - 1", a, a)
|
||||
end)
|
||||
|
||||
for op, func in pairs(operators) do
|
||||
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||
end
|
||||
@ -123,7 +127,7 @@ for _, p in ipairs(files) do
|
||||
end
|
||||
end
|
||||
|
||||
local _file = io.open(path:match("(.*)%.") .. ".l", "w")
|
||||
local _file = io.open(path:match("(.*)%.") .. ".lc", "w")
|
||||
_file:write(data)
|
||||
_file:close()
|
||||
end
|
||||
@ -133,5 +137,5 @@ end
|
||||
|
||||
exec "luacheck ../init.lua"
|
||||
exec "luacheck ../src/preprocessor.lua"
|
||||
exec "luacheck ../src/*.l"
|
||||
exec "rm ../src/*.l"
|
||||
exec "luacheck ../src/*.lc"
|
||||
exec "rm ../src/*.lc"
|
||||
|
Loading…
Reference in New Issue
Block a user