0

I'm making a simplistic text adventure game for practice. I want players to be able to backtrack once they go farther into a scenario, for example after they go down a staircase I want them to be able to have "back" as an option and be able to retrace their steps.

I've already figured out every aspect of that except: How to clear the message that popped up telling them about the scenario they just entered.

I have code making their response a variable, and then determining if that variable is one of a set list of viable options, and if not looping them back to the start and deleting their previous entry with the line of code print("\033[A \033[A")

However, this code only deletes the last line of code, which varies wildly depending on screen ratio and different devices, and not the last output, which is the entire message that described to them the scenario.

Does anyone know a piece of code that can either

  • delete the entire last output of the console, in this case a printed line of code which exceeds one line and may extend for as many as 8-10 lines, detailing their scenario, or
  • clear the console and then warp them back to my predefined starting point (Example: def start0():), because after I clear the console the code start0() doesn't work.
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Liium
  • 1
  • Does this answer your question? [Rewrite multiple lines in the console](https://stackoverflow.com/questions/6840420/rewrite-multiple-lines-in-the-console) – mkrieger1 Feb 26 '22 at 21:41
  • Thank you, and maybe? I'm not entirely sure. The top answer seems to be editing a line, which honestly would work fine opposed to sending new prompts each time, but I'm just not sure how I would adjust it to fit with multiple lines of description instead of singular characters on one line. T_T sorry. I'll mess around with it though, thanks. – Liium Feb 26 '22 at 21:54

0 Answers0