Jump to content




[recipe] Getting User Input



1 reply to this topic

#1 Xab

  • Members
  • 9 posts

Posted 23 October 2014 - 08:24 PM

Here's a pretty neat recipe for when you want to get the user's input for something.
If the user enters the wrong kind of input in the promptt function, it will erase their entered text and lets the user try again, without starting a new line. It also provides a default value for a user: pressing enter will use the default value, or typing anything else will let the user enter their own value. Finally, I've included a function - promptYesNo - for answering simple yes/no questions in a similar way as promptt.

Spoiler

pastebin: pastebin get u5K7DCXi

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 24 October 2014 - 04:02 AM

Moved to APIs and Utilities.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users