3 posts
Posted 25 November 2012 - 07:52 PM
I'm sorry if this is really simple, but I'm trying to create text in real time on a monitor, so if I say, typed in "Hello World." It would show up on the monitor as I type it out. Sorry if this is either really simple, or imposible. Any help is greatly appriciated.
3790 posts
Location
Lincoln, Nebraska
Posted 25 November 2012 - 07:57 PM
First of all, welcome to the forums.
Second, questions like these should be posted in the Ask A Pro section of the forums.
Third, You want to take a look at the peripheral API in the wiki. That's how you attach to a monitor and write on it.
3 posts
Posted 25 November 2012 - 10:13 PM
I thought I posted in ask a pro, my mistake.
715 posts
Posted 26 November 2012 - 12:30 AM
You would basically have to write your own read() function that contains only the functionality you are looking for.
As I don't know what features your live-input should have I just wrote a little example off the top of my head that contains at least a backspace ability, but nothing much else.
Spoiler
local _, yMax = term.getSize()
local line = ""
term.clear()
term.setCursorPos(1, 1)
term.setCursorBlink(true)
print("Input:")
while true do
term.setCursorPos(1, 2)
write(line)
local event, par = os.pullEvent()
if event == "char" then
line = line .. par
elseif event == "key" then
if par == keys.backspace then
local xCur, yCur = term.getCursorPos()
term.setCursorPos(xCur - 1, yCur)
write(" ")
term.setCursorPos(xCur - 1, yCur)
line = string.sub(line, 1, #line - 1)
elseif par == keys.enter then
print("nnEntered line: " .. line)
return
end
end -- events
end -- while
I'd suggest taking a look at the read() function in the "bios.lua" file and then take out the parts and make the modifications you need.
3 posts
Posted 26 November 2012 - 07:59 AM
This is exactly what I need, thank you. I'm very inexperienced in Lua, so this helped me a lot. Thank you.