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.
Leave this function blank and put this code in the void repeatedly_execute_always()
{
// Your code
}
More information about repeatedly execute functions:
https://adventuregamestudio.github.io/ags-manual/RepExec.html
Thanks!
Is it better to use "void" or "function" before it, in this scenario?
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.