bar level and idle view issue

Started by Andrea1992, Thu 09/07/2020 18:29:08

Previous topic - Next topic

Andrea1992

Hi,
I added a "hunger" level bar using Gui's and it's updated each loop in repeatedly_execute function. I followed Gurok tutorial: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54827.0

When the hunger level reaches a specific value I want my character to change its idle view, so I'm using SetIdleView function inside the repeatedly_execute function as well.
Code: ags

function repeatedly_execute() 
{
  if(hungerLevel== 408)
  {
    cPedro.SetIdleView(71, 0);
  }
}


The bar level is working perfectly, but not the idle view.

The idle view is only changing when I set a delay of 0. It changes to the first frame of the view but doesn't animate. And when I set a different delay it doesn't even change the view at all.

Now, I tested the idle view animation by itself and is working fine when I set it in the character's properties. But is not working in the script above.
I also tested the script using other views that have been animating fine in other scenarios and this didn't help either.

I have no clue how to proceed and make it work. Please help!!  :-D

Matti

#1
If hungerLevel stays at 408 your script runs every game loop, so the idleview will reset again and again.

Try this:

Code: ags

function repeatedly_execute() 
{
  if (hungerLevel == 408 && cPedro.IdleView != 71)
  {
    cPedro.SetIdleView(71, 0);
  }
}

Andrea1992

Thanks Matti!  :grin:

Instead of cPedro.IdleView != 71 I used  cPedro.View != 71 and worked perfect. I struggle with debugging.

Have a lovely day/night!

Khris

Just out of curiosity, what happened when you used cPedro.IdleView != 71?

Andrea1992

Hi Khris,
it was not animating nor walking, like stuck updating the idle view.
But that was also my mistake. I had an useless command just below that make it do that.

Then, it worked exactly as Matti suggested.

Cheers

SMF spam blocked by CleanTalk