Ask coding questions

← Back to all posts
how to erase only one line
thenullified

hi guys. im creating the next installment of the humble story of a teapot.
i want to know if its possible to erase only certain lines like:
teapot:
support = 1
...
[1]make some potcrafts
[2]use the power of 0/0 and cause multiversal instability
[3]summon the genie using the lamp-shaped teapot
user picks 3
shows:
teapot:
support = 1
...
[3]summon the genie using the lamp-shaped teapot
you used the lamp-shaped teapot
genie: ....

and also, if anyone know how to create a backspace effect, help me too
if you can teach me how, ill add you to the game and upvote all the comments you put here.
the repl is a preview of the minigames
thanks to @SixBeeps @CodingCactus @Muffinlavania for your help!(although i havent really found a satifactory ans yet).
thanks!

Voters
KitMacKinnon
squidcoder
mkw
thenullified
Comments
hotnewtop
Muffinlavania

This is python right? This is how i do it:
import sys
print("Not going to be erased")
print("Is going to be erased")
sys.stdout.write('\x1b[1A') #These two lines move the cursor up and
sys.stdout.write('\x1b[2K') #Erase that line(I think)

Muffinlavania

@Muffinlavania This just straight up deletes the lines btw, not really smoothly like the "backspace effect"

CodingCactus

clear the console and don't print out that line is how i would do it

thenullified

that would be troublesome with my code. but ill add a mention to the game anyway. @CodingCactus

CodingCactus

@starblazer i'm pretty sure that you can't just delete lines, once they are displayed, they are displayed, maybe there is a package that does it for you?

thenullified
SixBeeps

@starblazer @CodingCactus I'd pair it with an array containing the options that have already been used, and only print each option if they are not in the array.

thenullified

i have completely no idea how to do [email protected]

thenullified

here are the mentions in my sequel:
@SixBeeps @CodingCactus @Muffinlavania
('+m', '+m', '', 'attempt to reverse-engineer Muffinlavania\'s turtle onkey() into a 3d printer'),
('+s', '+s', '', 'Find the CodingCactus and get his encoded cacti encyclopedia'),
('+t', '+t', '', 'get the unsanitzed 15 cents from SixBeeps since its 3 nickels too many'),

thenullified

this is the raw source code