Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FocusHillGames on Tue 14/05/2024 14:12:52

Title: My fireflies freeze when other characters talk
Post by: FocusHillGames on Tue 14/05/2024 14:12:52
I've got fireflies in my game (they are not meant to be interacted with, they're just decorative), and I've created them as characters, and they are on their own walkable area.

I have this code in Repeatedly Execute -


function room_RepExec()
{
if (cFly3.Room == player.Room) {
   if (cFly3.Moving == false) {
     cFly3.WalkStraight(Random(Room.Width), Random(Room.Height));
  }
}
}


This works great, except when the player talks to another character, as the fireflies then stop moving.

It's not a massive problem, but ideally I'd like to fix it.
Title: Re: My fireflies freeze when other characters talk
Post by: eri0o on Tue 14/05/2024 14:26:28
Leave this function blank and put this code in the void repeatedly_execute_always()
{
  // Your code
}
Title: Re: My fireflies freeze when other characters talk
Post by: Crimson Wizard on Tue 14/05/2024 14:36:59
More information about repeatedly execute functions:
https://adventuregamestudio.github.io/ags-manual/RepExec.html
Title: Re: My fireflies freeze when other characters talk
Post by: FocusHillGames on Tue 14/05/2024 15:13:04
Thanks!
Is it better to use "void" or "function" before it, in this scenario?
Title: Re: My fireflies freeze when other characters talk
Post by: Crimson Wizard on Tue 14/05/2024 15:18:54
Quote from: FocusHillGames on Tue 14/05/2024 15:13:04Is it better to use "void" or "function" before it, in this scenario?

This is mostly irrelevant.
"function" is a traditional type of functions in AGS.
"void" is a way to explicitly tell that the function returns no result.