mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-23 07:33:12 +09:00
.
This commit is contained in:
1 parent
91984d319c
commit
24a24971e0
1 file changed
+13
-4
@@ -312,7 +312,7 @@ function Elements.parse(expression)
|
|||||||
return lhs
|
return lhs
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, result = pcall(function()
|
return ok, result = pcall(function()
|
||||||
local value = parse_expr(1)
|
local value = parse_expr(1)
|
||||||
skip_space()
|
skip_space()
|
||||||
|
|
||||||
@@ -326,13 +326,22 @@ function Elements.parse(expression)
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return ok and ("= " .. format_number(result, false)) or (type(result) == "table" and result or {"", {"exp-gui_calculator.error"}, tostring(result)})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Value change
|
--- Value change
|
||||||
function Elements.change(event)
|
function Elements.change(event)
|
||||||
event.element.parent.calculator_result_label.caption = event.text == "" and "" or Elements.parse(event.text:lower())
|
local label = event.element.parent.calculator_result_label
|
||||||
|
|
||||||
|
if event.text == "" then
|
||||||
|
label.caption = ""
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, result = Elements.parse(event.text:lower())
|
||||||
|
label.font_color = ok and {0, 0, 0} or {1, 0, 0}
|
||||||
|
label.caption = ok
|
||||||
|
and ("= " .. format_number(result, false))
|
||||||
|
or (type(result) == "table" and result or {"", {"exp-gui_calculator.error"}, tostring(result)})
|
||||||
end
|
end
|
||||||
|
|
||||||
local e = defines.events
|
local e = defines.events
|
||||||
|
|||||||
Reference in new issue
Block a user