need help with variables

Started by BenZB, Sun 08/06/2003 12:49:57

Previous topic - Next topic

BenZB

im trying to get it so when you interact with a hotspot on the third time you get an inventory item. Iv got it so when the player enters the room for the first time it runs this script:
int my_counter

and for the hotspot iv got this script:

if ( my_counter == 0) {
  Display("Its just a boring old calender.");
 int my_counter = 1);
}
if ( my_counter == 1) {
  Display("Wait theres a paper clip holding Febuary and March together.");
  int my_counter = 2);
}
if ( my_counter == 2) {
  Display("You take the paper clip.");
  AddInventory(1);
  int my_counter = 3);
}
if ( my_coounter == 3) {
  Display("Its a paper-clip-free calender");
}

Could somebody please tell me what is wrong with this. Im getting a tad annoyed. >:( >:( >:(

Captain Mostly

it might be that you need to declare the int to be 0 to start with (I'm not sure, but you certainly need to do this in C++) otherwise it might be some dodgy made-up value, or null or something...

int my_counter;
my_counter = 0;

BenZB

I tried putting "my_counter = 0;" at the front but it still doesent work. I t says something like undefined token line...

Ive tried changing the variable name, type and lots of other things but it still dosent work.

>:( :( >:( :( >:( :( >:( :( >:( :( >:(


Ishmael

add the line

int my_counter=0;

in to the start of the hotspot interaction code... allthough I think you dont need the 0, coz all new ints are allready zeros... ;)
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

BenZB

Yay. No more windows stating errors but i wanted it so it when you intereact with it it says the first message,on the second time you interact with it displays the second message, on the third time you interact with it it displays the third message and every time after that it displays the fourth message.

at the moment my script looks like this:
function hotspot2_a() {
 // script for hotspot2: Interact hotspot
 
 int my_counter = 0;
if ( my_counter == 0) {
Display("Its just a boring old calender.");
my_counter += 1;
}

if ( my_counter == 1) {
Display("Wait theres a paper clip holding Febuary and March together.");
my_counter += 1;
}

if ( my_counter == 2) {
Display("You take the paper clip.");
AddInventory(1);
my_counter += 1;
}

if ( my_counter == 3) {
Display("Its now a paper-clip-free calender");
}

 
}

scotch

move the line
int my_counter = 0;
out of the function, and put it at the top of the room script.

change the line
if ( my_counter == 3) {
to
if ( my_counter > 3) {

and after the second to last } put
my_counter++;

I hope that works.

BenZB


Scorpiorus

He means this way:

int my_counter = 0;
function hotspot2_a() {
// script for hotspot2: Interact hotspot

if ( my_counter == 0) {
Display("Its just a boring old calender.");
}
else if ( my_counter == 1) {
Display("Wait theres a paper clip holding Febuary and March together.");
}
else if ( my_counter == 2) {
Display("You take the paper clip.");
AddInventory(1);
}
else if ( my_counter > 3) {
Display("Its now a paper-clip-free calender");
}

my_counter++;

}

-Cheers

BenZB

#8
:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D
Thanx 4 the help i got it 2 work properly now
:D

SMF spam blocked by CleanTalk