mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
fixed a bug where for whatever reason io.read would return 0x0D (CR)
Former-commit-id: 769e2d3931472d14ce66cfef3a496a3913dc51be
This commit is contained in:
@@ -88,21 +88,25 @@ end
|
|||||||
|
|
||||||
io.read = function(option)
|
io.read = function(option)
|
||||||
if io.__openfile__ == "stdin" then
|
if io.__openfile__ == "stdin" then
|
||||||
local input = ""
|
local input = {}
|
||||||
local inkey = null -- local variable init REQUIRED!
|
|
||||||
|
|
||||||
-- RETURN not hit
|
-- RETURN not hit
|
||||||
while inkey ~= 13 do
|
while true do
|
||||||
inkey = machine.__readFromStdin()
|
local inkey = machine.__readFromStdin()
|
||||||
if inkey > 0 then
|
if inkey == 13 or inkey == 10 then
|
||||||
|
break
|
||||||
|
elseif inkey == 8 or inkey == 127 then
|
||||||
io.write(string.char(inkey))
|
io.write(string.char(inkey))
|
||||||
input = input..string.char(inkey)
|
table.remove(input)
|
||||||
|
elseif inkey > 0 then
|
||||||
|
io.write(string.char(inkey))
|
||||||
|
table.insert(input, string.char(inkey))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- RETURN finally hit
|
-- RETURN finally hit
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
|
|
||||||
return input
|
return table.concat(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _readAll()
|
function _readAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user