Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: simulacra on Tue 12/10/2004 00:26:00

Title: What is wrong with this code? [SOLVED]
Post by: simulacra on Tue 12/10/2004 00:26:00
In repeatedly execute of a room:

if (GetBackgroundFrame()==4) {
SetBackgroundFrame(-1);
character[ENGINE].room = 42;
}


Despite that the background is animating, and has five frames, this never gets triggered. Could anyone figure out why?
Title: Re: What is wrong with this code?
Post by: strazer on Tue 12/10/2004 00:48:46
Be sure to create the room's repeatedly_execute function from the interaction editor.

I too remember it used to work if you just wrote
  function repeatedly_execute() {
into the room script but it doesn't seem to work anymore.

Edit:

I've just remembered: I was thinking of the repeatedly_execute_always function...
Title: Re: What is wrong with this code?
Post by: simulacra on Tue 12/10/2004 00:51:26
I added it in a "Run script" action in the interaction editor.
Title: Re: What is wrong with this code?
Post by: strazer on Tue 12/10/2004 00:55:28
Oh, ok.
Well, I tested your code and it worked fine for me (using latest beta).
Title: Re: What is wrong with this code?
Post by: Goot on Tue 12/10/2004 03:17:06
Is there anything before it in repeatedly execute? Like maybe a
return; or something?
Title: Re: What is wrong with this code?
Post by: simulacra on Tue 12/10/2004 13:30:05
Quote from: Goot on Tue 12/10/2004 03:17:06
Is there anything before it in repeatedly execute? Like maybe a
return; or something?

There isn't.  :-\
Title: Re: What is wrong with this code?
Post by: Radiant on Tue 12/10/2004 20:21:44
Probably this: every time you call SetBackgroundFrame (-1), the bg animation starts over, from frame one. Since you call SBF every single frame, the bg never reaches frame 2.
Title: Re: What is wrong with this code?
Post by: strazer on Tue 12/10/2004 21:00:38
Yeah, technically the SBF line is unnecessary since the background animation loops anyway, but it doesn't affect the functionality since it's encased in the conditional clause.

As I said, the code works for me, so there must be something else wrong with your game.
Have you tried putting a Display line in there to see if it's triggered at all?
I see you have posted in the Beginner's Forum that you have problems displaying the character, so maybe the code is triggered, but the problem is with the character view/room/position/whatever?
Title: Re: What is wrong with this code?
Post by: simulacra on Thu 14/10/2004 19:53:51
I got it to work, no idea how.