Jump to content




Computer is displaying invalid thing.


9 replies to this topic

#1 Zambonie

  • Members
  • 477 posts
  • LocationSpring Hill, Fl

Posted 26 January 2013 - 03:36 PM

I am making an factory,and to get in,you have to get threw with the pass first.And before that even displays,I made a message that my facotry uses extreme explosives an need to be handled with care.And since im going to use that same message for other computers,I put it in varibles.Then I made it so it could print the message,off course.But when Im done with that,I start the program,It displays the message but in a unusaual way?For the code I use for the program is:

term.clear()
term.setCursorPos(11,3)
UGR0 = ("*--------------------------------*")
URG1 = ("|									   |")
URG2 = ("|	  ^								|")
URG3 = ("|	 /!\	 URGENT			|")
URG4 = ("|	 ---							   |")
URG5 = ("|										|")
URG6 = ("|   Please be aware that	|")
URG7 = ("|   this factory has ex-		|")
URG8 = ("|   plosives.So please		|")
URG8 = ("|   take care of them.		 |")
URG9 = ("|   Thank You.				   |")
URG10 = ("|									   |")
URG11 = ("|		   |1:Ok.|				  |")
URG12 = ("*-------------------------------*")
print(URG0)
print(URG1)
print(URG2)
print(URG3)
print(URG4)
print(URG5)
print(URG6)
print(URG7)
print(URG8)
print(URG9)
print(URG10)
print(URG11)
print(URG12)

When it outputs,
its missing the top line.
And its also is missing the \ in the caution sign.On that same line the | is one before its suposed to be.
Anything Im doing wrong?

Edit:Sorry,THe | in the code are uneven because thats how the text editor printed it.But it you run it,the lines will be equal.(I think.And exept for the one on 3'd line.)

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 26 January 2013 - 03:38 PM

For the missing the \ issue, the problem is that \ is an escape character, so to get it to print you must escape it with itself so it would be, \\ instead of \ ...

#3 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 26 January 2013 - 03:40 PM

Besides the \\ thingy, instead of
term.setCursorPos(11,3)
shouldn't you do
term.setCursorPos(1,3)
?

#4 Zambonie

  • Members
  • 477 posts
  • LocationSpring Hill, Fl

Posted 26 January 2013 - 03:42 PM

Ya,I guess I clicked 1 by acsedent..

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 26 January 2013 - 03:43 PM

another alternative is to do something like this, this will draw it in the middle of the screen
local function drawWarning()
  local warning = {

    ("*--------------------------------*"),
    ("|                                |"),
    ("|        ^                       |"),
    ("|       /!\\     URGENT           |"),
    ("|       ---                      |"),
    ("|                                |"),
    ("|   Please be aware that         |"),
    ("|   this factory has ex-         |"),
    ("|   plosives.So please           |"),
    ("|   take care of them.           |"),
    ("|   Thank You.                   |"),
    ("|                                |"),
    ("|           |1:Ok.|              |"),
    ("*--------------------------------*"),
  }
  local w, h = term.getSize()
  term.clear()
  for i = 1, #warning do
   term.setCursorPos( w/2-#warning[1]/2, h/2-#warning/2+i) -- set the cursor so that the screen will be printed in the middle
   write( warning[i] )
  end
end

Edited by TheOriginalBIT, 26 January 2013 - 03:51 PM.


#6 Zambonie

  • Members
  • 477 posts
  • LocationSpring Hill, Fl

Posted 26 January 2013 - 03:45 PM

Ok,That will be a little to advanced to me...But how about the missing top line?

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 26 January 2013 - 03:48 PM

its all the spaces on the top line, they go wider than the screen width, so print moves it to the next line.

also you say print(URG0) but you call the variable UGR0

Edited by TheOriginalBIT, 26 January 2013 - 03:50 PM.


#8 crazyguymgd

  • Members
  • 139 posts
  • LocationUSA

Posted 26 January 2013 - 03:59 PM

View PostP4isHere., on 26 January 2013 - 03:45 PM, said:

Ok,That will be a little to advanced to me...But how about the missing top line?

It might seem a little too advanced but this is the direction you should be going. Learning to use tables will dramatically increase the quality of your programs.

And the missing top line is a typo, as TheOriginalBIT said

#9 Zambonie

  • Members
  • 477 posts
  • LocationSpring Hill, Fl

Posted 27 January 2013 - 02:44 AM

@original,I did call he varible URG0 and used print(URG0).

#10 Zambonie

  • Members
  • 477 posts
  • LocationSpring Hill, Fl

Posted 27 January 2013 - 03:05 AM

Nevermind guys,I solved it.I couldve just used
URG0 = URG12






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users