This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
phoe's profile picture

Problem with elseif

Started by phoe, 03 June 2014 - 10:22 PM
phoe #1
Posted 04 June 2014 - 12:22 AM
Problem:
1. after first input is wrong program is "stuck" in loop until correct input is typed, removing elseif part didn't seems to help (v2) - program ignores everything past line 28
2. In v2 term.clear and setcursor, clears "rendering verdict" text, but doesn't do anything about first message (cursor is set under it)

I tried removing/adding "end"s in diffrent spots, but it doesn't change anything.
Any sugestions?

Versions:
v1: http://pastebin.com/yAL1C5gm
v2: http://pastebin.com/hykez4sq
Whitecatblack #2
Posted 04 June 2014 - 01:12 AM
I'm sure I will be able to find your problem, but I'd rather not do work I don't need to. Which one do you want me to debug, v1 or v2?

Whitecatblack
Bomb Bloke #3
Posted 04 June 2014 - 02:18 AM
v1 is looking good, but swap lines 1 and 2 around. You don't want to reset "tries" to 0 every time the loop repeats.

v2 has some of its "end"s in the wrong positions - cleaner indentation would make it obvious to you where they should go. Because of this, if you type the wrong password the loop repeats right away, and so the first message gets redrawn right away (it does get cleared an instant before that happens, however).