What is wrong with this code? [SOLVED]

Started by simulacra, Tue 12/10/2004 00:26:00

Previous topic - Next topic

simulacra

In repeatedly execute of a room:

Code: ags
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?

strazer

#1
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...

simulacra

I added it in a "Run script" action in the interaction editor.

strazer

Oh, ok.
Well, I tested your code and it worked fine for me (using latest beta).

Goot

Is there anything before it in repeatedly execute? Like maybe a
return; or something?

simulacra

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.  :-\

Radiant

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.

strazer

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?

simulacra


SMF spam blocked by CleanTalk