Global Ints with Character Interaction Scripts

Started by ScottDoom, Thu 01/07/2004 09:42:42

Previous topic - Next topic

ScottDoom

Since I'm still a newbie at scritping I'm just posting this in the beginners area, but I guess it could go in the advanced...

Anyways, I had a hotspot on my background with an interaction script like this:

Ã,  Ã,  if (rock == 0) {
Ã,  Ã,  AddInventory(1);
Ã,  }
Ã,  if (rock == 0) {
Ã,  rock += 1;
Ã,  }
Ã,  if (rock == 1) {
Ã,  Ã,  Display("MESSAGE ONE");Ã, 
Ã,  }
Ã,  if (rock == 2) {
Ã,  Ã,  Display("MESSAGE TWO");
Ã,  }
Ã,  if (rock < 2) {
Ã,  Ã,  rock += 1;
Ã,  }Ã, 

It worked out pretty good. But now I replaced the hotspot with a character, and I want this same script on the character. For that, I can no longer put int rock; at the top of the room script, but I need to put it in the global script somewhere...

I'm not sure where or how to insert the int into the game (without having it reset if the game is loaded).

Ishmael

I think putting

int rock;

in start of global script and

import int rock;

into the script header should do it, then you could use it for the character.
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.

ScottDoom

That works. Thanks a lot. I wasn't sure on how to use the import thing... Isn't there also an export function? What's that used for?

Ishmael

eeer... yes, you need to

export rock;

in the end of the global script if you have done something with it in the global script, and want to use it in room scripts.
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.

ScottDoom

Well, it worked without the export line... But I'll add it.

TerranRich

#5
This is all in the BFAQ already. Did you read it?
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk