Problem with GetGlobalString

Started by ags_newbie, Thu 15/12/2005 23:59:31

Previous topic - Next topic

ags_newbie

Yes. I'm having trouble again.

I'm having a problem with GetGlobalString.Ã,  I do a bit of experimenting and find out that I need another factor. The problem is that I have NO idea what I need to do.

Code: ags

#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
SetGlobalInt(6,0);//Placeholder1
SetGlobalInt(7,10);//Health, used for battle and non-battle
SetGlobalInt(8,0);//Money
SetGlobalInt(9,0);//Placeholder2 
SetGlobalString(11,"none");//Equipped Melee Weapon (eg knife)
SetGlobalString(19,"none");//Equipped Ranged Weapon (eg glock)
SetGlobalInt(12,0);//Attack Points, set at start of battle
SetGlobalInt(13,0);//Enemy Health, set at start of battle
SetGlobalInt(14,0);//Enemy Atk. Points, set at start of battle
SetGlobalInt(15,0);//Enemy Melee Weapon
SetGlobalInt(16,0);//Enemy Ranged weapon
SetGlobalInt(17,0);//Ammo of equipped ranged weapon
SetGlobalInt(18,0);//Ammo of enemy's equipped ranged weaponÃ,  Ã, 
// called when the game starts, before the first room is loaded
Ã,  Ã, }
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  string money;
Ã,  string health;
Ã,  string meleeweapon;
Ã,  string rangedweapon;
Ã,  string ammo;
Ã,  string attackpoints;
Ã,  string enemyhealth;
Ã,  string enemyattackpoints;
Ã,  StrFormat(money,"%d",GetGlobalInt(8));
Ã,  StrFormat(health,"%d",GetGlobalInt(7));
Ã,  StrFormat(meleeweapon,"%s",GetGlobalString(11));
Ã,  StrFormat(rangedweapon,"%s",GetGlobalString(19));
Ã,  StrFormat(ammo,"%d",GetGlobalInt(17));
Ã,  StrFormat(attackpoints,"%d",GetGlobalInt(12));
Ã,  StrFormat(enemyhealth,"%d",GetGlobalInt(13));
Ã,  StrFormat(enemyattackpoints,"%d",GetGlobalInt(14));
Ã,  SetLabelText(0,4,health);
Ã,  SetLabelText(0,2,money);
Ã,  SetLabelText(3,0,health);
Ã,  SetLabelText(3,1,meleeweapon);
Ã,  SetLabelText(3,2,rangedweapon);
Ã,  SetLabelText(3,3,ammo);
Ã,  SetLabelText(3,5,attackpoints);
Ã,  SetLabelText(3,4,enemyhealth);
Ã,  SetLabelText(3,6,enemyattackpoints);Ã,  
Ã,  
Ã,  
Ã,  // put anything you want to happen every game cycle here
}
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE

Don't confuse me with AGS Newbie!

Proud user of AGS 2.61... still!

strazer

Quote from: ags_newbie on Thu 15/12/2005 23:59:31I do a bit of experimenting and find out that I need another factor.

Can you please explain in more detail what you want to do?

And please, if you're not sure where to post, please post in the Beginners Forum first.
If your question cannot be answered there, it will be moved to the Technical Forum. The main Technical Forum is reserved for advanced questions and bug reports.
Thank you.

Ashen

At a guess, I'd say the problem was here:
Code: ags

  StrFormat(meleeweapon,"%s",GetGlobalString(11));
  StrFormat(rangedweapon,"%s",GetGlobalString(19));


Read the manual, the usage for GetGlobalString() is:
Quote
GetGlobalString
GetGlobalString (int index, string buffer)

Copies the current Global String INDEX into BUFFER. See SetGlobalString for more information.
Example:

string buffer;
GetGlobalString (15, buffer);


So, those above lines should be:
Code: ags

  GetGlobalString (11, meleeweapon);
  GetGlobalString (19, rangedweapon);


NOTE: I'm assuming you're not using V2.71.
I know what you're thinking ... Don't think that.

monkey0506

In 2.71 it's Game.GlobalStings[index]...or something like that.

ags_newbie

Don't confuse me with AGS Newbie!

Proud user of AGS 2.61... still!

SMF spam blocked by CleanTalk