Variables [SOLVED]

Started by Sam., Fri 17/12/2004 14:47:21

Previous topic - Next topic

Sam.

right, i want my player to have a limited freedom of choice . They have to complete everything in a room in order to progress, i want them to be able to choose which order to pick stuff up berofre an event happens. I thought, ill use a variable and then add to this integer everytime they do something, so when the variable reaches a certain value the event occurs. simple enough. i look up variables in the manual and learn to declare an integer i :

int progress;

so i declare my variable in the game start code.

I then need to add to this every time they do something so i ask on IRC, i get told to:

progress = prgress + 1;

no probs. But i then run and get told that prgress is unrecognised and so my game won't work. what am i doing wrong?

i
Bye bye thankyou I love you.

Rui 'Trovatore' Pires

Maybe because you mispelled it?

progress= progress + 1;

At any rate, it might be better to

progress++;

or

progress+=1;
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Sam.

just tried that and I got "undefined Token"
Bye bye thankyou I love you.

Rui 'Trovatore' Pires

Oh, you declared int progress; in game start?

Ok, it's like this - if you only need the variable in THAT room, declare in in your ROOM script, BEFORE any code, kay? Inside NO function.

If you need it in more rooms, you declare it at the BEGINNING of the global script, not in game start. You declare it BEFORE any functions. Then at the end of the script you add "export progress;". And THEN you add "import int progress;" to your script header.

Again, if you only need this in one room, stick to the first method.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Sam.

cheers, solved now.
Bye bye thankyou I love you.

TerranRich

Zooty, next time, check the BFAQ at least: http://bfaq.terran-x.com/#coding01

Thanks.
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk