Running script during dialog. Howto?

Started by Minimi, Thu 10/07/2003 10:07:54

Previous topic - Next topic

Minimi

Hi there... I searched for this matter everywhere but couldn't find the answer so I'll post it. I made a script that when I'm hitting the right side of the screen, there is going to be a variable weither you already talked to someone. If you didn't you get the message that you still need to talk, and if you did, you proceed to the next room. Here is my code for making the variable:

int alreadytalked;

function room_a() {
 // script for room: Walk off right screen edge{
if (alreadytalked == 0){
     MoveCharacter(SAM, 300,120);
     Wait(70);
     DisplayMessage(5);     
}
if (alreadytalked == 1){     
     NewRoom(2);
}
}

Well that is all working, but now I need to change that variable during a dialog. First I tried inserting it, but it wouldn't work, and second I checked the manual about  "run-script x". I tried that, but I couldn't manage to get it working, so please help me with this matter!

Gilbert

There is an easier way, use a GlobalInt().
First think about using which GlobalInt you want to use, say, you use globalInt #10.

Note that all the globalints were already defined and set to 0 when the game starts, so you don't need ot define them yourself.

In the dialog script where you want to set the variable to a value, just use:

set-globalint 10 1

so GlobalInt 10 will be set to 1 there, then in your "walk off edge" script:

function room_a() {
// script for room: Walk off right screen edge{
if (GetGlobalInt(10) == 0){
   MoveCharacter(SAM, 300,120);
   Wait(70);
   DisplayMessage(5);    
} else if (GetGlobalInt(10) == 1){    
   NewRoom(2);
}
}

SMF spam blocked by CleanTalk