Question about Global Int

Started by anime2019master, Wed 30/06/2010 05:17:20

Previous topic - Next topic

anime2019master

The following is my setup for battles using global int.

Code: ags
  SetGlobalInt(1, 50); //Health 
  SetGlobalInt(2, 0); //Mana
  SetGlobalInt(3, 0); //Exp
  SetGlobalInt(4, 1); //Level
  SetGlobalInt(5, 100); //Town gaurd 1 health.
  SetGlobalInt(6, 15); //Charcater attack
  SetGlobalInt(7, 20); //Town gaurd 1 attack


This is how I set up a GUI to show your health. I did the same with the opponets.

Code: ags
function Health1_OnClick(GUIControl *control, MouseButton button)
{
  Display("You have %d HP remaining",GetGlobalInt(1));
}


My question is, how do I subtract the value of int 7 from int 1? like wise with int 6 from int 5.
Is there a line of script to take the value of one int from another? The only thing I can come up with is this:

Code: ags
  SetGlobalInt(1, GetGlobalInt(1)-20); //Deals atk damage from opponets attack.


While I already know that will work, It will take alot of typing in the long run. Is there another way?

Gilbert

Quote from: anime2019master on Wed 30/06/2010 05:17:20
My question is, how do I subtract the value of int 7 from int 1? like wise with int 6 from int 5.
Is there a line of script to take the value of one int from another? The only thing I can come up with is this:
Something like:
Code: ags
SetGlobalInt(1, GetGlobalInt(1)-GetGlobalInt(7));


QuoteWhile I already know that will work, It will take alot of typing in the long run. Is there another way?
Not if you are still using GlobalInts. Instead you may use the more preferred import-export method or the Global Variable pane that was suggested in your other thread.

anime2019master

Tnks! It was so simple that I don't know why I didn't tnk of it myself.

SMF spam blocked by CleanTalk