Jump to content




Can someone help me out?


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

#1 Matthew

  • Members
  • 3 posts

Posted 05 April 2013 - 09:16 AM

I'm new to ComputerCraft so bare with me,

1. How can I center input = read()? Because my text is all centered except for when the user inputs data. Or is there another way to prompt the user for an answer (simple yes/no with an if statement)
2. Is there a simpler way to insert a new line without doing print(" ")?

Thank you ^_^

#2 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 09:20 AM

Hey !
I don't know if it is what you mean but you should take a look at term.setCursorPos(x, y) !

#3 OmegaVest

  • Members
  • 436 posts

Posted 05 April 2013 - 09:33 AM

Actually, the easiest(or most useful) way to center input is to make your own read function that uses chars or keys and an pullEvent loop. Everything else is either imperfect or destroys whatever GUI you happen to have.

And, for new lines, yeah, setCursorPos is the only alternative. For whatever reason escape characters don't always work with term.write. Or any write, for that matter.

#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 05 April 2013 - 09:33 AM

1. For that, you would need to make your own read() function. This is an edit of the vanilla read() that centers text, but also clears the entire current line (because it has to.)

Spoiler

2. It would probably help to know that \n represents the newline character, and therefore, doing write('\n\n\n') would make three new lines, and move the cursor down three times.

Note that this only works with print and write and not term.write, and when using this with print, it will print one more newline than you have provided, since print automatically makes a newline.

There's also the method of simply using term.setCursorPos() to print where you want your text.

#5 Matthew

  • Members
  • 3 posts

Posted 05 April 2013 - 09:39 AM

Thank you :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users