Global variables and ...

Started by Bijulinus, Wed 19/09/2007 13:25:24

Previous topic - Next topic

Bijulinus

Hello, I've a big doubt and I'm sinking in the manual  ::)

In the new version of AGS, HOW do I do variables globally accessable?
Or better, a struct globally accessable?

Another thing, stupid but that's annoying me: how do I cast int to strings???

Thanks a lot :o
I'm too lazy at the moment to find a good signature.

Khris

The way to do it didn't change in the new version (regardless whether you're speaking of 2.8 or 2.72). Export the variable after its declaration, then import it in the header.

Int to string:

Int i=3;
String s=String.Format("%d", i);

Bijulinus

Could you make an example? Specifying where the instructions are put?

Thanks
I'm too lazy at the moment to find a good signature.

Khris

Code: ags
// header

struct mystruct {
  int a;
  String name;
};

import int var;

import mystruct test[8];

// global script

int var;
mystruct test[8];

export var, test;


Just remember: export only the name, but import the whole declaration.

Bijulinus

Thanks! I only knew the infamous GetGlobalInt(... !
;D ;D
I'm too lazy at the moment to find a good signature.

Ashen

#5
In future, READ THE BFAQ before posting.

Admittedly it doesn't mention structs (it's only 'the basics', after all), but it deals with making other variable types Globally accessable, in detail.

EDIT: I've updated the Inserting variables into speech/messages entry to also mention ints.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk