SetBackgroundFrame() not setting the right graphic [SOLVED]

Started by tkitez, Sun 05/08/2007 14:57:49

Previous topic - Next topic

tkitez

In an animating room with 3 background animations, I have an interaction for
when player enters room (after fadein) that runs this dialog script

// dialog script file
@S  // dialog startup entry point
@1  // option 1
run-script 1
return
@2  // option 2
run-script 2
return
@3  // option 3
run-script 3
return
@4  // option 4
run-script 4
stop

In the global script I have
#sectionstart dialog_request //
function dialog_request(int parameter)
{
// 0 not a valid parameter
  if (parameter==1) {
      SetBackgroundFrame(1);
       //  SetBackgroundFrame(GetBackgroundFrame()+1);

     }
  if (parameter==2) {SetBackgroundFrame(2);}
  if (parameter==3) {SetBackgroundFrame(3);}
  if (parameter==4) {SetBackgroundFrame(0);}
}
#sectionend dialog_request//

Everything compiles and runs, but the only option that works correctly is #4.  The others all change the background, but never to the appropriate frame number.  For example, If I chose option 1, I pass a "1" to the dialog_request, and so expect to see background #1, but instead I will get something different. 

Ashen

Which frame do you see - is it reliably different (always the same 'wrong' frame for each number), or does it choose at random? The obvious things to check are that you've imported the frames in the right order and that you're not choosing, for example, frame 1 when you actually want frame 0. (Frame 0 is the one you see in the Room editor, 1-3 are the ones you import in the 'Animating backgrounds' window.)

EDIT:
Looking at it, it seems like the Dialog is blocking the frame from updating when it changes - the fist click doesn't do anything, butclicking another option causes the last SetBackgroundFrame command to be run. Adding Wait(1); after SetBackgroundFrame(x) should fix that. Alternately, you could make a GUI to handle this. It'll look better and should actaully work like you want it to (of course, if this is just for debugging / testing, that doesn't really matter).
I know what you're thinking ... Don't think that.

tkitez

Quote from: Ashen on Sun 05/08/2007 15:09:17
Which frame do you see - is it reliably different (always the same 'wrong' frame for each number), or does it choose at random? The obvious things to check are that you've imported the frames in the right order and that you're not choosing, for example, frame 1 when you actually want frame 0. (Frame 0 is the one you see in the Room editor, 1-3 are the ones you import in the 'Animating backgrounds' window.)
The frames themselves are imported correctly, which I verified by testing without the script and just watched the animations appear in the proper sequence.  It appears to be a different wrong sequence depending on which option I choose first, but I get that same wrong sequence every time I restart the game and pick the same option. For example:
   Option Sequence          Shows Background
           3                                        1
           2                                         3
           1                                         2
           1                                         1
           2                                         1
           3                                         2

By option sequence, I mean I chose those in order (3,2,1,1,2,3).  If I start instead
with choosing 2, the sequence 2,3,1 shows 1,2,3.

Ashen

Check my edit above, I must've made it while you were typing. It looks like the 'shown' sequence is the same as the 'chosen' sequence, just a step behind like I said. Adding a Wait command to dialog_request will force the screen to update then so you actually get the background you chose.

Oh, and the first frame is always 1 because you didn't put 'return' after the @S option in the dialog script. Option 1 runs as soon as the dialog starts, and SetBackgroundFrame(1) is called before the dialogue properly starts and blocks the script.
I know what you're thinking ... Don't think that.

tkitez

WONDERFUL!!  Your suggestion to put in Wait(1) in the dialog_request function worked perfectly.  Thanks so much...hard to find something like that in the faq or forums.


EDIT by Ashen: No need to quote the entire post just above yours. And you're welcome.

SMF spam blocked by CleanTalk