Jump to content




Problem with colors on terminal


  • You cannot reply to this topic
4 replies to this topic

#1 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 02 December 2013 - 01:42 PM

Hello everyone,

I try to make a colored security lock but I do something wrong and I dont know what that is.

What I try to make:
The first 2 lines need to be orange background with white text.
from the 3th line needs to be a white background with black text.

and then the last 2 lines on the bottom need to be orange again.

Many thanks if you can help me

os.pullEvent = os.pullEventRaw
local standby = 5
local side = "left"
local password = "xixili"
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.orange)
term.clear()
term.setCursorPos(12,1)
term.setTextColor(colors.white)
print("Security Panel")
term.clear()
term.setCursorPos(1,3)
term.setBackgroundColor(colors.white)
term.clear()
term.setCursorPos(1,4)
write("Password: ")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,4)
print("Correct")
rs.setOutput(side,true)
sleep(5)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,4)
print("Wrong Password")
sleep(2)
os.reboot()
end


#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 02 December 2013 - 02:13 PM

term.clear fills the entire screen with the current background color. Call it only when you want to clear the screen. I fixed up everything a little bit.
I'm sure the code is self-explanatory

EDIT: Line 22: Forgot the length operator (#)...

Edited by LBPHacker, 02 December 2013 - 02:16 PM.


#3 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 02 December 2013 - 02:19 PM

View PostLBPHacker, on 02 December 2013 - 02:13 PM, said:

term.clear fills the entire screen with the current background color. Call it only when you want to clear the screen. I fixed up everything a little bit.
I'm sure the code is self-explanatory

EDIT: Line 22: Forgot the length operator (#)...

Its a long time ago that I worked with computercraft so I need to learn it all over again :(

There is an error on line 22
1:22: attempt to perform arithmetic on string

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 02 December 2013 - 02:20 PM

View PostXixili, on 02 December 2013 - 02:19 PM, said:

-snip-
Even the block you quoted states that I forgot the # operator from line 22...

EDIT: Aaaaaand as an addition, I forgot that you wanted the orange lines to be two char high. Heck, sorry for that.

Edited by LBPHacker, 02 December 2013 - 02:24 PM.


#5 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 02 December 2013 - 02:28 PM

View PostLBPHacker, on 02 December 2013 - 02:20 PM, said:

View PostXixili, on 02 December 2013 - 02:19 PM, said:

-snip-
Even the block you quoted states that I forgot the # operator from line 22...

EDIT: Aaaaaand as an addition, I forgot that you wanted the orange lines to be two char high. Heck, sorry for that.
Thank you very much!
It works!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users