Two dispicable questions...

Started by Akumayo, Thu 03/06/2004 20:41:20

Previous topic - Next topic

Akumayo

1.  In the game I am making, your current and max Hp's are displayed on a GUI.  In the script, I have SetGlobalInt(3, 20);
SetGlobalInt(4, 20);
On the GUI, I have a text label that reads
HP= @GI3@ / @GI4@
However, when I start the game, all the GUI displays is
Hp=    /   
What have I done wrong?...

2.  I am having trouble with the following code:


if (GetGlobalInt(18)==1) { //If attack order is MONSTER then YOU, then continue
      DisplaySpeech(YOU,"Foe's turn to strike!"); //Displays a message
      Wait(120);
      character[MONSTER].x-=10;//MONSTER moves towards YOU in a striking motion
      Wait(10);
      //(Here we would normally have a sound effect for attaking)
      character[MONSTER].x+=10;//MONSTER moves back
      Wait(10);
      SetGlobalInt(7, GetGlobalInt(7)-GetGlobalInt(1)); //Sets YOU's HP to YOU's HP minus MONSTER's attack power
}

The problem is that the code runs completely normally, only the character MONSTER does not move forward and then backwards.  What is wrong with this code?...
"Power is not a means - it is an end."

®2-D2

1. try setting the gui labels' text manually in the global repeatedly_execute function

2. you might want to use one of the MoveCharacter commands instead of manually setting the char's position

Akumayo

1. Okay, I will try doing that shortly.

2. I see no reason to move character.  I already have a script similar to the one having trouble, and in it the character jumps forward and then backward like he is supposed to.  Just, in the script I gave, the game engine seems to skip the commands for moving back and forth.  I need to know how to fix that, or at least why it is doing that...
"Power is not a means - it is an end."

Akumayo

1. Okay, I tried setting them from the script:

SetLabelText(YOUHP, 1, "HP= @GI3@ / @GI4@");

But still, when I start up the game, the GUI reads

HP=    /   

I don't understand, what have I done wrong???

2. I still need an answer for this one...
"Power is not a means - it is an end."

Moox

Perhaps you have to put get global int in repeatedly execute for it to work.

Akumayo

I did set it in the Global Script reapetedly execute, and the GUI's still don't display the @GIx@'s
"Power is not a means - it is an end."

..

Are you already using the @score@ things? If not you could alwasy use these for HP...

Ashen

1. It's not very elegant, but try this in the global repeatedly_execute:

string hp;
string hpmax;
string buffer;
StrFormat (hp, "HP: %d", GetGlobalInt (3));
StrFormat (hpmax, "/ %d", GetGlobalInt (4));
StrCopy (buffer, hp);
StrCat (buffer, hpmax);
SetLabelText (YOUHP , 1, buffer);

I think I've got your GlobalInts and GUI's right, but you should check anyway.

2. Try using MoveCharacter anyway, just to see if it works that way. Also, what's the 'similar script' you have, the one that works?
I know what you're thinking ... Don't think that.

®2-D2

1. yes, that's what i meant in the first place: use "GetGlobalInt" instead of "@GIx@". hence the repeatedly_execute function

2. i've done something involving moving objects and i just use MoveObject instead of manually setting their x and y values, it should also work for characters

Phemar


For number one i would go:

//top of global script

int currenthp;
int totalhp=100;

function repeatedly_execute() {
//now split your current label in quarters, making four labels. Leave two blank, 
//Label the other "Hp:", and other "/"
//Postion it like this: "HP:" " " "/" " "
SetLabelText (YOUHP, 2, currenthp);
SetLabelText (YOUHP, 4, totalhp);


//now use this to increase health:
currenthp=currenthp+5;
//or to deduct:
currenthp=currenthp-5;
if (currenthp<0) {
  Display ("Hehe...you are now pushing up the daisies...");
  RestartGame ();
  }
//That should be it...
[/pre]

Edwin Xie

Isn't HP supposed to be a variable?
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Moox

Thats what a global int is...

Akumayo

Here is the similar spript.  When it is run, the character moves forward, then backwards, just like he should.

Here it is:






DisplaySpeech(YOU,"Foe is faster, it strikes first!"); //Displays a message
Wait(120);
  character[MONSTER].x-=10;//MONSTER moves towards YOU in a striking motion
  Wait(10);
//(Here we would normally have a sound effect for attaking
  character[MONSTER].x+=10;//MONSTER moves back
  Wait(10);
  SetGlobalInt(7, GetGlobalInt(7)-GetGlobalInt(1)); //Sets YOU's HP to YOU's HP minus Sneak's attack power
  SetGlobalInt(18, 2); //Says to repeatedly execute that the attack order is now YOU, then MONSTER, then repeat.


As for the GUI, I will try using the SetGlobalText command in a little bit.
"Power is not a means - it is an end."

Akumayo

Okay, I tried the string hp; string maxhp, etc.  Code, and it worked!!!!  And listen to this, when I got the Hp's displayed, the characters began jumping back and forth just like they are supposed to!!!!  thanks for all your help, and some of you have just made the credits!!!!
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk