rpg with arrays
Author |
Message |
diablo
|
Posted: Fri Nov 05, 2004 1:22 pm Post subject: rpg with arrays |
|
|
i am making an RPG and my code is as follows:
%Land of Lost Souls RPG
var classes:array 1..4 of int
var class_classes:array 1..4,1..4 of string
var monsters:array 1..20 of string
var bosses:array 1..5 of string
var x:int
var health:int
var atk:int
var defence:int
var mag:int
var spd:int
var spcl:int
var inventory:array 1..10 of string
/*
class_classes(1,1):="soldier"
class_classes(1,2):="knight"
class_classes(1,3):="teutonic knight"
class_classes(1,4):="king's guard"*/
%choosing classes
put "welcome to the land of lost souls, mortal"
put "are you ready to die?"
put "choose your class of hero"
put "1=soldier, 2=mage, 3=crypt fiend, 4=rifleman"
get classes(x)<----(when i run it, is says that the"get classes(x)" line has no value
can you tell me what i did wrong?
i set my x-variable as an integer and my class array as integers as well |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mazer
|
Posted: Fri Nov 05, 2004 1:28 pm Post subject: (No subject) |
|
|
The problem is that x has no value. This line of code:
Says to get a value from the user and store it in the array classes in the location x.
Try
To get the number. After that, I'm not sure what you are trying to do. |
|
|
|
|
|
diablo
|
Posted: Mon Nov 08, 2004 8:06 am Post subject: (No subject) |
|
|
oh, well after the user enters a number, they will be given a class of character and specific stats to go along with it. |
|
|
|
|
|
Delos
|
Posted: Mon Nov 08, 2004 9:42 am Post subject: (No subject) |
|
|
Ok...here's your problem:
You have a variable within a variable here. The subscript is not defined. You could either use:
for a for loop that will allow the User to select the value of each element in 'classes'.
BTW, please use [code] tags in the future. Thanks. |
|
|
|
|
|
|
|