Problem with .Say and .Move in my little script

Started by Vargard, Tue 18/08/2020 17:09:16

Previous topic - Next topic

Vargard

Hello ! So I've been having this problem with this little script (and Ive been looking around but nothing):

I interact with a box and I write this:

player.Say("let's see");
player.Move(180, 940);
player.AddInventory(iGun);

So: He says "Let's see", then he moves to the box, then he gets the gun.

That's normal.

Now, I just add another player.Say in the script, like this:

player.Say("let's see");
player.Move(180, 940);
player.AddInventory(iGun);
player.Say("Cool!");

And now, he says "Let's see", then he says "Cool", he does have the gun but he doesn't move to the box anymore

Any ideas what's happening here?

Thanks!

Vargard

Cassiebsg

#1
yes, player.Move was more options than just x, y. You need to add eBlock to it.

Quote from: AGS Manual
Character.Move(int x, int y, optional BlockingStyle,
                             optional WalkWhere);
Starts the character moving from its current location to (X,Y), but does not play the character's walking animation.

The parameters to this command are identical to the Character.Walk command -- see that page for more details. The only difference is that Walk plays the walking animation whereas Move does not.

In the vast majority of cases, you will use Character.Walk instead.

Example:

cEgo.Move(155, 122, eBlock);
will make the character move to 155,122 without playing his walking animation. The script will not continue until the character has reached his destination.



So your line should look like this: player.Move(180, 940, eBlock;)
There are those who believe that life here began out there...

Vargard

Ah!
All right!
Thank you so much for the reply !!

:smiley:

ToeKnee

#3
Quoteplayer.Move(180, 940, eBlock;)
I also wouldn't use Move if I was you... If you use the Walk command you get the following important benefits;

  • The character stays within the walkable areas defined for the screen and doesn't get 'stuck' (trapped outside of the walkable areas and can no longer move anywhere!).
  • Your Character also moves using the View loops assigned for the directions it has to go to get to the destination (i.e: Walking right view Loop)
  • You can also ensure you are facing the right direction you want after the blocked walking action to the destination, eg: to Face the gun (so if the player is BELOW the destination and no left or right walk movement / views were required to get there, then you can be sure they will always face the right way regardless of where they start from on the screen)
  • Your Character can be easily setup to use the Character Scaling for that walkable area - so if the walking makes the character go UP for example then the character will automatically get smaller (further away)
Eg:
Code: ags
cEgo.Walk(XPosOfDestination, YPosOfDestination, eBlock, eWalkableAreas);
cEgo.FaceDirection(eDirectionRight);
If it’s not broken, let’s fix it till it is...!

Khris

The only difference, according to the manual, is that .Move() doesn't play the walking animation. The other stuff like using walkable areas (or not) and scaling is identical.
Since Vargard doesn't mention the "missing" walking animation at all, using .Move() should suit them perfectly fine.

Rik Vargard

Thanks so much for the replies guys, it helped me a lot!

SMF spam blocked by CleanTalk