diff --git a/res/layouts/code_editor.xml b/res/layouts/code_editor.xml
index 3d3e584d5..fb4833da1 100644
--- a/res/layouts/code_editor.xml
+++ b/res/layouts/code_editor.xml
@@ -31,6 +31,12 @@
hover-color="#1080FF"
onclick="run_current_file()"
color="#FFFFFF80" size="16">
+
+
diff --git a/res/layouts/code_editor.xml.lua b/res/layouts/code_editor.xml.lua
index 733fa9036..61e90842f 100644
--- a/res/layouts/code_editor.xml.lua
+++ b/res/layouts/code_editor.xml.lua
@@ -113,6 +113,78 @@ local function reload_model(filename, name)
assets.parse_model(file.ext(filename), document.editor.text, name)
end
+-- === TODO: remove after 0.32 ===
+local pattern =
+ "region %(%s*"
+ .. "([+-]?%d+%.?%d*[eE]?[+-]?%d*)%s*,%s*"
+ .. "([+-]?%d+%.?%d*[eE]?[+-]?%d*)%s*,%s*"
+ .. "([+-]?%d+%.?%d*[eE]?[+-]?%d*)%s*,%s*"
+ .. "([+-]?%d+%.?%d*[eE]?[+-]?%d*)"
+ .. "%s*%)"
+
+local function replace1(x1, y1, x2, y2)
+ return string.format("region (%s, %s, %s, %s)", x2, y2, x1, y1)
+end
+
+local function replace2(x1, y1, x2, y2)
+ return string.format("region (%s, %s, %s, %s)", x2, y1, x1, y2)
+end
+
+function convert_vcm(text)
+ local lines = {}
+ local zpairs = {
+ {"%(north%)", "%(south%)", "(TMPS)", "(TMPN)"},
+ {"%,north", "%,south", ",TMPS", ",TMPN"},
+ {"north%,", "south%,", "TMPS,", "TMPN,"},
+ }
+ local xpairs = {
+ {"%(west%)", "%(east%)", "(TMPE)", "(TMPW)"},
+ {"%,west", "%,east", ",TMPE", ",TMPW"},
+ {"west%,", "east%,", "TMPE,", "TMPW,"},
+ }
+
+ for i, pair in ipairs(zpairs) do
+ text = text:gsub(pair[1], pair[3])
+ text = text:gsub(pair[2], pair[4])
+ end
+ text = text:gsub("TMPS", "south")
+ text = text:gsub("TMPN", "north")
+
+ for i, pair in ipairs(xpairs) do
+ text = text:gsub(pair[1], pair[3])
+ text = text:gsub(pair[2], pair[4])
+ end
+ text = text:gsub("TMPW", "west")
+ text = text:gsub("TMPE", "east")
+
+ for line in text:gmatch("[^\n]*\n?") do
+ if line == "" then
+ break
+ end
+
+ if line:find("(top)", 1, true) then
+ line = line:gsub(pattern, replace1)
+ end
+
+ if line:find("(bottom)", 1, true)
+ or line:find("(east)", 1, true) then
+ line = line:gsub(pattern, replace2)
+ end
+
+ table.insert(lines, line)
+ end
+
+ return table.concat(lines)
+end
+
+function fix_vcm_regions()
+ if not current_file.filename then
+ return
+ end
+ document.editor.text = convert_vcm(document.editor.text)
+end
+-- ===============================
+
function run_current_file()
if not current_file.filename then
return