Topic:   Gonna hang myself over this glitch...   (Read 21421 times)


0 Members and 1 Guest are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Gonna hang myself over this glitch...
« on: September 01, 2008, 04:38:18 AM »
I started making a simple Hang Man game last night, but now I'm stumped on a peculiar glitch. I think a repeat loop isn't repeating the correct amount of times. It seems to always repeat twice, even though it should repeat an amount of times equal to the length of the "sentence$" string variable.

Here's the source: http://www.mediafire.com/?o8dgyuqkzah

And here's the code: (this is the entire game's code. I've highlighted the area I think the glitch occurs in)

PICT CurrentCard

REPEAT
 Â sentence$ = USERASK Enter the name of a movie or book:
 Â sentence$ = UCASE$ sentence$
 Â block = 0
 Â IF sentence$ = "" THEN block = 1
 Â IF sentence$ = " " THEN block = 1
 Â IF sentence$ CONTAINS "." THEN block = 1
 Â IF sentence$ CONTAINS "," THEN block = 1
 Â IF sentence$ CONTAINS "/" THEN block = 1
 Â IF sentence$ CONTAINS "?" THEN block = 1
 Â IF sentence$ CONTAINS "'" THEN block = 1
 Â IF sentence$ CONTAINS ";" THEN block = 1
 Â IF sentence$ CONTAINS ":" THEN block = 1
 Â IF block = 0 THEN
 Â   EXIT REPEAT
 Â ELSE
 Â   ALERT The sentence must only contain letters and numbers.
 Â END IF
END REPEAT

blank$ = "_"
debug$ = ""
charactercheck$ = ""
characterchecknumber = 1
sentencelength = LEN sentence$
REPEAT
 Â charactercheck$ = MID$ sentence$ characterchecknumber 1
 Â IF charactercheck$ = " " THEN
 Â   debug$ = debug$ + charactercheck$
 Â ELSE
 Â   debug$ = debug$ + blank$
 Â END IF
 Â characterchecknumber = characterchecknumber + 1
 Â IF characterchecknumber > sentencelength THEN EXIT REPEAT
END REPEAT
PRINT $sentence$$ (length test)
PRINT
PRINT $debug$$ (length test)


ON KEYDOWN
 Â guess = 0
 Â keydown$ = UCASE$ keydown$
 Â IF keydown$ = "A" THEN guess = 1
 Â IF keydown$ = "B" THEN guess = 1
 Â IF keydown$ = "C" THEN guess = 1
 Â IF keydown$ = "D" THEN guess = 1
 Â IF keydown$ = "E" THEN guess = 1
 Â IF keydown$ = "F" THEN guess = 1
 Â IF keydown$ = "G" THEN guess = 1
 Â IF keydown$ = "H" THEN guess = 1
 Â IF keydown$ = "I" THEN guess = 1
 Â IF keydown$ = "J" THEN guess = 1
 Â IF keydown$ = "K" THEN guess = 1
 Â IF keydown$ = "L" THEN guess = 1
 Â IF keydown$ = "M" THEN guess = 1
 Â IF keydown$ = "N" THEN guess = 1
 Â IF keydown$ = "O" THEN guess = 1
 Â IF keydown$ = "P" THEN guess = 1
 Â IF keydown$ = "Q" THEN guess = 1
 Â IF keydown$ = "R" THEN guess = 1
 Â IF keydown$ = "S" THEN guess = 1
 Â IF keydown$ = "T" THEN guess = 1
 Â IF keydown$ = "U" THEN guess = 1
 Â IF keydown$ = "V" THEN guess = 1
 Â IF keydown$ = "W" THEN guess = 1
 Â IF keydown$ = "X" THEN guess = 1
 Â IF keydown$ = "Y" THEN guess = 1
 Â IF keydown$ = "Z" THEN guess = 1
 Â IF guess = 1 THEN
 Â   guess$ = keydown$
 Â   IF guessed$ CONTAINS guess$ THEN guess = 0
 Â   guessed$ = guessed$ + guess$
 Â END IF

 Â IF guess = 1 THEN
 Â   debug$ = ""
 Â   charactercheck$ = ""
 Â   characterchecknumber = 1
 Â   sentencelength = LEN sentence$

 Â   REPEAT
 Â     charactercheck$ = MID$ sentence$ characterchecknumber 1
 Â     IF charactercheck$ = " " THEN
 Â       debug$ = debug$ + charactercheck$
 Â     ELSE
 Â       IF guessed$ CONTAINS charactercheck$ THEN
 Â         debug$ = debug$ + charactercheck$
 Â       ELSE
 Â         debug$ = debug$ + blank$
 Â       END IF
 Â     END IF
 Â     characterchecknumber = characterchecknumber + 1
 Â     IF characterchecknumber > sentencelength THEN EXIT REPEAT
 Â   END REPEAT

 Â   CLEAR TEXT
 Â   PRINT $sentence$$ (length test)
 Â   PRINT
 Â   PRINT $debug$$ (length test)
 Â END IF

 Â IF debug$ = sentence$ THEN
 Â   ALERT You Win!
 Â   GOTOCARD 2
 Â END IF
END KEYDOWN
« Last Edit: September 01, 2008, 05:10:02 AM by Silverwind »
I survived the spammage of 2007

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Gonna hang myself over this glitch...
« Reply #1 on: September 01, 2008, 07:30:15 AM »
Strange. If you put the keydown code on another card then it works.
TD is having a problem with multiple REPEAT loops on a card too. I haven't been able to fix this fully yet. I keep trying.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Gonna hang myself over this glitch...
« Reply #2 on: September 01, 2008, 09:50:58 AM »
Thanks Al, that's a fine fix! :D I'll post the complete source and the compiled game later when I've added animations.
I survived the spammage of 2007

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Gonna hang myself over this glitch...
« Reply #3 on: September 07, 2008, 09:29:30 AM »
OK. I found 2 problems in REPEAT loops. One should solve Silverwind's bug and the other should solve Tireas-Dragon's error in compiled games.

Silverwind:
There is still a bug that skips a line, but now it seems to skip the first line in the REPEAT loop of every REPEAT loop after the first one (2nd loop and all others).
Try this workaround and let me know if that fixes it.

REPEAT 3
 PRINT Loop 1
END REPEAT
REPEAT 3
  ' skip a line
  PRINT Loop 2
END REPEAT


Tireas-Dragon:
I found a typo in my engine for compiled games which caused the error. I wrote the wrong variable name in my code. I fixed the typo and I will send you an update to try. Also see above and make sure you skip a line after the REPEAT for now until I get that corrected.


Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: Gonna hang myself over this glitch...
« Reply #4 on: September 07, 2008, 11:45:49 AM »
Well that was very interesting. It doesn't say error contact maker of program anymore. But now when I get close to a wall it the one to the right is the same as the one to the left, but in run mode they both show up correctly. The interesting thing is that I know exactly what is happening, it just makes no sense that it happens in compiled but not run.  Oh and I did do that skip a line thing.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Gonna hang myself over this glitch...
« Reply #5 on: September 07, 2008, 01:37:31 PM »
OK. Thanks. I'm still working on it.

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: Gonna hang myself over this glitch...
« Reply #6 on: September 07, 2008, 05:32:58 PM »
It's good to know that you are working on it.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Gonna hang myself over this glitch...
« Reply #7 on: September 08, 2008, 02:47:40 AM »
Yup, it's working great on my end Al. Thanks! :) It's exactly as you said, it skips the first line on every repeat block after the first.
« Last Edit: September 08, 2008, 02:49:44 AM by Silverwind »
I survived the spammage of 2007

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Gonna hang myself over this glitch...
« Reply #8 on: September 11, 2008, 08:04:46 AM »
Both bugs are fixed for the next update.