A Few more noob Script issues, Regarding givescore and parser triggered events

Started by snerzel, Fri 17/03/2017 21:54:14

Previous topic - Next topic

snerzel

Well not long after a problem is fix another is found :undecided:   I'm still new to this!

My problem is that when I type the proper word in the text parser to trigger and event it keeps running the other scripted events also, adds up all the scores, and freezes on the last frame of animation without resuming the idle animation.

I keep reading the manual on this and as far as I can tell it shouldn't run EVERYTHING under this function like this. Although being new to the C language and ags I wouldn't be surprised if I'm missing something. 

Here's my script to help anyone who wishes to help me (Please excuse the words and what's being said, They're inside jokes):

function TextBox1_OnActivate(GUIControl *control)
{Parser.ParseText(Cmdbox.Text);
Cmdbox.Text= "";
String badword = Parser.SaidUnknownWord();
if (badword != null) cGirl.Say("I don't have words for that.");

if (Parser.Said("madness"))
cGirl.Say("Madness?..... THIS.. IS.. TEXAS!!");
GiveScore(5);

if (Parser.Said("hair"))
cBoy.Animate(1,5,eOnce);
cGirl.Say("Floof the hair for power!");
GiveScore(20);

if (Parser.Said("arms"))
cBoy.Animate(5,5,eOnce);
cGirl.Animate(4,3,eOnce);
GiveScore(20);

}



Cassiebsg

Please use the code tag.  ;)

You have to understand to that if you don't use { } AGS will only process the first line as being part of the if condition, thus running all the next lines until your next if.
Also, in this case you can use "else if", since you're only processing 1 word at a time (am I'm guessing, if it's more than don't use the else).

Also, note the indentation, as it makes it more clear to read.   ;)

Try this:

Code: ags

function TextBox1_OnActivate(GUIControl *control)
{
  Parser.ParseText(Cmdbox.Text);
  Cmdbox.Text= "";
  String badword = Parser.SaidUnknownWord();
  if (badword != null) cGirl.Say("I don't have words for that.");
  else if (Parser.Said("madness"))
  {
    cGirl.Say("Madness?..... THIS.. IS.. TEXAS!!");
    GiveScore(5);
  }
  else if (Parser.Said("hair"))
  {
    cBoy.Animate(1,5,eOnce);
    cGirl.Say("Floof the hair for power!");
    GiveScore(20);
  }
  else if (Parser.Said("arms"))
  {
     cBoy.Animate(5,5,eOnce);
     cGirl.Animate(4,3,eOnce);
     GiveScore(20);
  }
}
There are those who believe that life here began out there...

snerzel

THANK YOOOU!!!!! Things were becoming quite messy. only thing now is how do I get it to resume the idle animation for both characters?
:grin:

Cassiebsg

If you using the idle view, you just set it up on the character's property pane under idle view. It just then run automatically whenever the character is not doing anything. I think the delay is 20 by default.

If you have some code to go along and/or are setting the view manually, put your code in repeatedly_execute:
Code: ags

function repeatedly_execute()  // put it in repeatedly_execute_always if you wish it to run under blocking events too
{
  if (!character.Animating) // if your character is NOT animating
  {
     // put code in here
  }
}

There are those who believe that life here began out there...

snerzel


Snarky

There's probably a typo in your code. Post it here (inside a [code=ags][/code] tag) so we can see what it is.

snerzel

Code: ags
 
function repeatedly_execute() 
{
 if (!character.Animating)
  {
   cBoy.Animate(0,7,eRepeat,eNoBlock);
  
  cGirl.Animate(0,8,eRepeat,eNoBlock);
  }
  
}

Snarky

Well, that looks basically correct (it does mean the characters will be doing their idle animation all the time, but let's take one problem at a time). There could be an error on a line above it that the AGS parser only catches when it comes to the if-line, so maybe if you post the function above it too? Or you could try removing the body of the repeatedly_execute() function and seeing if the error shows up somewhere else.

Wait, no! It's because "character" is not a valid Character. You need to put the name of one of your characters (cBoy or cGirl) there instead.

In AGS, "character" is an array of all the characters in the game, so you can write character[0] and so on to reference characters by index instead of by name. That's why it's telling you to use a bracket.

dayowlron

your problem is ur using the character type not the specific character occurrence.

Code: ags
function repeatedly_execute() 
{
  if (!cBoy.Animating)
  {
    cBoy.Animate(0,7,eRepeat,eNoBlock);
  }
  if (!cGirl.Animating)
  {
    cGirl.Animate(0,8,eRepeat,eNoBlock);
  }
  
}


Basically it is saying when you specified character in the if statement it didn't know which character you were querying about so it wanted an index.
for instance instead of putting cBoy you could put character[1] if cBoy is character number 1, etc.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell


Cassiebsg

Oops, sorry about that. When I typed character, I just meant you character's name, as I didn't knew which character you wanted to animate.  :-[
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk