rename a function to be more specific
This caused a bug in Lua Carousel. Scenario: - Run carousel.love - run the abbreviations screen which creates an abbreviation called `color` - run driver.love Before this commit, carousel.love would silently exit, and driver.love would then hang waiting for it to come back. The cause: - driver.love sends MANIFEST - in processing it, carousel.love calls color() to emit a color escape. - the error silently quits the app After restarting carousel.love, the error shows up in driver.love: Error: live.lua:104: bad argument #3 to 'color' (number expected, got no value) stack traceback: [C]: in function 'color' live.lua:104: in function 'receive_from_driver' ...
This commit is contained in:
parent
d60139bdb5
commit
6daec24aea
8
live.lua
8
live.lua
|
@ -101,7 +101,7 @@ function live.receive_from_driver()
|
||||||
local result = f:read('*a')
|
local result = f:read('*a')
|
||||||
f:close()
|
f:close()
|
||||||
if result == '' then return nil end -- empty file == no message
|
if result == '' then return nil end -- empty file == no message
|
||||||
print('<='..color(--[[bold]]1, --[[blue]]4))
|
print('<='..color_escape(--[[bold]]1, --[[blue]]4))
|
||||||
print(result)
|
print(result)
|
||||||
print(reset_terminal())
|
print(reset_terminal())
|
||||||
os.remove(love.filesystem.getAppdataDirectory()..'/_love_akkartik_driver_app')
|
os.remove(love.filesystem.getAppdataDirectory()..'/_love_akkartik_driver_app')
|
||||||
|
@ -113,7 +113,7 @@ function live.send_to_driver(msg)
|
||||||
if f == nil then return end
|
if f == nil then return end
|
||||||
f:write(msg)
|
f:write(msg)
|
||||||
f:close()
|
f:close()
|
||||||
print('=>'..color(0, --[[green]]2))
|
print('=>'..color_escape(0, --[[green]]2))
|
||||||
print(msg)
|
print(msg)
|
||||||
print(reset_terminal())
|
print(reset_terminal())
|
||||||
end
|
end
|
||||||
|
@ -123,7 +123,7 @@ function live.send_run_time_error_to_driver(msg)
|
||||||
if f == nil then return end
|
if f == nil then return end
|
||||||
f:write(msg)
|
f:write(msg)
|
||||||
f:close()
|
f:close()
|
||||||
print('=>'..color(0, --[[red]]1))
|
print('=>'..color_escape(0, --[[red]]1))
|
||||||
print(msg)
|
print(msg)
|
||||||
print(reset_terminal())
|
print(reset_terminal())
|
||||||
end
|
end
|
||||||
|
@ -131,7 +131,7 @@ end
|
||||||
-- args:
|
-- args:
|
||||||
-- format: 0 for normal, 1 for bold
|
-- format: 0 for normal, 1 for bold
|
||||||
-- color: 0-15
|
-- color: 0-15
|
||||||
function color(format, color)
|
function color_escape(format, color)
|
||||||
return ('\027[%d;%dm'):format(format, 30+color)
|
return ('\027[%d;%dm'):format(format, 30+color)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue