Request for a QFG Stats Screen Tutorial

Started by , Tue 01/08/2006 01:15:53

Previous topic - Next topic

grinder

Okay, so I've got quite a bunch of int variables, defined and exported in the Global Script and imported in the Script Header. I need a GUI. With it, the player should be able to change eauch of these variables by adding to them or subtracting from them using a limited amount of units which is defined by the coder.
Okay, pardon my English. In two words, I need an easy and nice way to create a QFG-like character stat modification screen. I'm especially interested in the actual interface.

R4L

Well you could create a GUI, and add 3 labels: Strength, blah blah, and blah blah, blah blah being Wisdom or whatever. Then you add 3 up arrow buttons. In the script for that button, you would put something like this:

(don't know if this works with newer AGS)

if (GetGlobalInt(5)>0){
   SetGlobalInt(2,GetGlobalInt(2)+1);
   SetGlobalInt(5,GetGlobalInt(5)-1);
   }

this says if your GlobalInt Stat Points (5) are greater than 0, you will add 1 to GlobalInt Strength (2) and subtract 1 from GlobalInt Stat Points. Before this, you would put:

if (GetGlobalInt(5) <1){
    return;
    }

This says that if Stat Points are less than 0, you can't add anymore points because you don't have any. You can do this with anything really, just make sure you put the correct int values. Not sure if this will help you, but good luck!

Khris

grinder:
What exactly are you having problems with?
Creating the GUI?

Add labels and buttons, enter a Script name for each control (lblstrength, increase_strength, decrease_strength, aso.), make sure that Left click of the buttons is set to Run script, then double click the buttons and select OK in the editor to make AGS add their [button name]_Click-functions to the global script.
A window will open with the cursor already positioned at the newly created functions, then just enter the appropriate code.

If you've created your own global variables, the code should probably look something like this:

Code: ags
function increase_strength_Click(GUIControl *control, MouseButton button) {
Ã,  if (available_units>0) {
Ã,  Ã,  available_units--;
Ã,  Ã,  strength++;
Ã,  Ã,  lblstrength.Text=String.Format("Strength: %d", strength);
Ã,  }
}

...

function decrease_strength_Click(GUIControl *control, MouseButton button) {
Ã,  if (strength>min_strength) {
Ã,  Ã,  available_units++;
Ã,  Ã,  strength--;
Ã,  Ã,  lblstrength.Text=String.Format("Strength: %d", strength);
Ã,  }
}

SMF spam blocked by CleanTalk