Welcome, Guest. Please login or register.
Did you miss your activation email?
December 06, 2019, 12:37:20 AM
Home Famicom World Search Calendar Login Register

+  Famicom World
|-+  Family Computer
| |-+  Famicom / Disk System (Moderators: manuel, L___E___T)
| | |-+  Help with my rock-paper-scissors game in Family BASIC
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Help with my rock-paper-scissors game in Family BASIC  (Read 150 times)
childishbeat
Famiclone
*
Posts: 15


« on: November 10, 2019, 03:51:16 PM »

I'm making a rock-paper-scissors game in Family BASIC. I get an ?IL ERROR (illegal function call error) at either line 110 or line 130 when I make my choice. How can that be fixed? Here's my code:
Code:
10 COMPUTER=RND(3)+1
20 COMPUTER$="ROCK"
30 IF COMPUTER=2 THEN COMPUTER$="PAPER"
40 IF COMPUTER=3 THEN COMPUTER$="SCISSORS"
50 INPUT "ROCK, PAPER OR SCISSORS? ",HUMAN$
60 IF HUMAN$="ROCK" THEN GOTO 100
70 IF HUMAN$="PAPER" THEN GOTO 100
80 IF HUMAN$="SCISSORS" THEN GOTO 100
90 PRINT "INVALID GUESS. TRY AGAIN.": GOTO 50
100 PRINT "YOU CHOSE "HUMAN$" AND THE COMPUTER CHOSE "COMPUTER$"."
110 IF HUMAN$=COMPUTER$ THEN PRINT "YOU MADE THE SAME CHOICE AS THE COMPUTER, SO YOU TIED."
120 IF HUMAN$="ROCK" AND COMPUTER=2 THEN PRINT "PAPER COVERS ROCK, SO YOU LOSE."
130 IF HUMAN$="ROCK" AND COMPUTER=3 THEN PRINT "ROCK BLUNTS SCISSORS, SO YOU WIN."
140 IF HUMAN$="PAPER" AND COMPUTER=1 THEN PRINT "PAPER COVERS ROCK, SO YOU WIN."
150 IF HUMAN$="PAPER" AND COMPUTER=3 THEN PRINT "SCISSORS CUT PAPER, SO YOU LOSE."
160 IF HUMAN$="SCISSORS" AND COMPUTER=1 THEN PRINT "ROCK BLUNTS SCISSORS, SO YOU LOSE."
170 IF HUMAN$="SCISSORS" AND COMPUTER=2 THEN PRINT "SCISSORS CUT PAPER, SO YOU WIN."
« Last Edit: November 10, 2019, 04:07:22 PM by childishbeat » Logged
UglyJoe
Administrator
Disk-kun
*****
Gender: Male
United States United States
Posts: 5493



WWW
« Reply #1 on: November 10, 2019, 11:24:46 PM »

Some of your strings are too long.  Seems to barf if you go over 31 characters.

You might be able to concat them together in chunks of 31 characters using semicolons (like "ABC";"DEF").
Logged
childishbeat
Famiclone
*
Posts: 15


« Reply #2 on: November 11, 2019, 04:47:23 PM »

Your suggestion worked. Here's my new code, which I've fully tested, and, as I found out from these tests, which involved me triggering every possible outcome as if one was playing it normally (there's nine possible outcomes), is fully bug-free:
Code:
10 COMPUTER=RND(3)+1
20 COMPUTER$="ROCK"
30 IF COMPUTER=2 THEN COMPUTER$="PAPER"
40 IF COMPUTER=3 THEN COMPUTER$="SCISSORS"
50 INPUT "ROCK, PAPER OR SCISSORS? ",HUMAN$
60 IF HUMAN$="ROCK" THEN GOTO 100
70 IF HUMAN$="PAPER" THEN GOTO 100
80 IF HUMAN$="SCISSORS" THEN GOTO 100
90 PRINT "INVALID GUESS. TRY AGAIN.": GOTO 50
100 PRINT "YOU CHOSE "HUMAN$" AND THE COMPUTER CHOSE "COMPUTER$"."
110 IF HUMAN$=COMPUTER$ THEN PRINT "THOSE ARE THE SAME CHOICES";", SO YOU TIED."
120 IF HUMAN$="ROCK" AND COMPUTER=2 THEN PRINT "PAPER COVERS ROCK, SO YOU LOSE."
130 IF HUMAN$="ROCK" AND COMPUTER=3 THEN PRINT "ROCK BLUNTS SCISSORS";", SO YOU WIN."
140 IF HUMAN$="PAPER" AND COMPUTER=1 THEN PRINT "PAPER COVERS ROCK, SO YOU WIN."
150 IF HUMAN$="PAPER" AND COMPUTER=3 THEN PRINT "SCISSORS CUT PAPER";", SO YOU LOSE."
160 IF HUMAN$="SCISSORS" AND COMPUTER=1 THEN PRINT "ROCK BLUNTS SCISSORS";", SO YOU LOSE."
170 IF HUMAN$="SCISSORS" AND COMPUTER=2 THEN PRINT "SCISSORS CUT PAPER, SO YOU WIN."
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!