This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Goof's profile picture

[help/question] write and blinking screen at the same time...

Started by Goof, 23 October 2012 - 03:48 PM
Goof #1
Posted 23 October 2012 - 05:48 PM
Hey everyone…


i have a bit of troubles during my operating system…


#############
[Password] <– here i want to type in password or other thingies…
#############
– BUT is this possible?
###############
# ANTIVIRUSOS() # <– i want this to blink, at the same time, pressing keys into "the box above"
###############



that was the look of my system…

but is it possible, to make a blinking box (or any other things, like that) in the same time, also when you are typing something onto the "[password]" ????




Thanks

—————————————————————————————————————————————————–
- Mikk809h
Kolpa #2
Posted 23 October 2012 - 05:58 PM
well you would have to recreate your read function to do achieve something like that
Goof #3
Posted 23 October 2012 - 05:59 PM
but. is there any tutorial on that, just so i have a bit of knowledge on how to do that?
remiX #4
Posted 23 October 2012 - 06:18 PM
Can't you just use term.setCursorPos(x,y) for each part?
Goof #5
Posted 23 October 2012 - 06:36 PM
ehhm how… ? then i have to make a blinking cursor, and then while i press a key it would print the key and trigger a LOT of other functions ??? or just a for loop / while loop ?
diegodan1893 #6
Posted 23 October 2012 - 06:47 PM
create a function that does the cursor blink in the right position, then call it with parallel API
Kolpa #7
Posted 23 October 2012 - 06:48 PM
not really i will try to create something like that "live"

blink = false
function draw(pa)
  blink = not blink
  term.clear()
  term.setCursorPos(1,5)
  write("Password: ")
  for x=1, pa:len() do
    write("*")
  end
  if blink then
    write("#")
  end
end
function read2()
local pass = ""
while true do
  os.startTimer(0.5)
  local ev,key = os.pullEvent()
  if ev == "char" then
    pass = pass .. key
draw(pass)
  end
  if ev == "timer" then
    draw(pass)
  end
  if ev == "key" then
    if key == 28 then
   return pass
    end
    if key == 14 then
	  pass = pass:sub(0,pass:len()-1)
   draw(pass)
    end
  end
end
end

print(read2())

its probably not an elegant way but it atleast works
PixelToast #8
Posted 23 October 2012 - 08:23 PM
wait, why? thats verry confusing having two things blink at once