script and variables [SOLVED]

Started by deltree, Mon 25/04/2005 00:05:59

Previous topic - Next topic

deltree

Hi,
I'm sorry for asking suh a basic question, what is more, I keep asking a lot of question these days:
Here is my problem:

I've got a  variable "noblague" that is modified in the "repetedly execute" script, it's linked to a timer, so this variable is modified every 5 seconds. (I simplify)
I know the variable "noblague" actually changes, because in the "repetedly execute" script, I've placed some "displayspeech" to check it (I don't know any other way to check the state of a value, is there any?)

But now, I need to check in another script (and interaction script) the value of the "noblague" variable.
I need to do this:

if (noblague==1) {
   DisplaySpeech(3,"it works, noblague=1.");
}
(I simplify again)

It just doesn't work. Well, it compiles, the game runs, but it seem that the script considers noblague=0 all the time.

I feel confused about the scripts. there are a lot of place to put scripts in, and I just don't know how they mix together in the end, and which one comes priority.

I hope someone understood my question and could help me about this.

Ashen

What's the repeatedly_execute script? Is is possible you've changed noblague again (back to 0, or to a higher number)?

Whay if you try:
Code: ags

if (noblague != 0) {
  DisplaySpeech (3, "It worked.");
}


Or just :
Code: ags

DisplaySpeech (3, "noblague = %d", noblague);

For testing purposes.
I know what you're thinking ... Don't think that.

strazer

Where have you put the declaration of the variable (int noblague)?
And what interaction is it (object/character/hotspot/item)?

TerranRich

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

deltree

#4
to ashen:

thanx for the tips (DisplaySpeech (3, "noblague = %d", noblague);) didn't know how to display a variable. will be usefull.
Here is where I go to  the repetedly execute script:



to strazer:
Where have you put the declaration of the variable (int noblague)?

in the main header (CTRL+H)

And what interaction is it (object/character/hotspot/item)?
It's a "talk to character"

TerranRich
thanx for the link, didn't knew that one. It's possible that it can solve my problem, but I can't test it now.
I might have something to do with "import global variable!!"

strazer

Quotein the main header (CTRL+H)

If you declare a variable in the main script header, seperate variables will be created for the global script and for each room.

To access a variable defined in the global script from inside room scripts, you have to export it first, then import it into the room script where you need it or in the main script header to make it accessible from all room scripts.
Character interactions are handled in the global script, so you wouldn't need to export/import it just for that.
So do

Code: ags

// main global script

int noblague;
export noblague;


and

Code: ags

// room script

import int noblague;
// now this room script (rep_ex) has access to the variable defined in the global script


or

Code: ags

// main script header

import int noblague;
// variable is now accessible from ALL rooms

Ashen

QuoteHere is where I go to  the repetedly execute script:

Actually, I meant what's in the rep_ex script. You said noblague is modified every 5 seconds, on a timer - what code are you using?

Although, it sounds like strazer's right, and you've just declared noblague in the wrong place.
I know what you're thinking ... Don't think that.

deltree

Quote from: Ashen on Mon 25/04/2005 11:01:57
QuoteHere is where I go to  the repetedly execute script:

Actually, I meant what's in the rep_ex script. You said noblague is modified every 5 seconds, on a timer - what code are you using?

Although, it sounds like strazer's right, and you've just declared noblague in the wrong place.

lol, sorry about it!
Actually, the code is quite long, but I've got the explanation, it's about the place where the variables are.

SMF spam blocked by CleanTalk