[SOLVED] SetBackgroundFrame problem

Started by simulacra, Tue 27/07/2004 19:35:47

Previous topic - Next topic

simulacra

I have a room where there is an area you can look at, and if you do there is the following interaction:

Code: ags

Look at hotspot
- Game - Display a message (0)
- (?) Conditional - If the player has inventory item (11)
-- Run script [No 1, See below]
-- Game - Display a message (11)
-- Game - Run dialog (17)
-- Run script [No 2, See below]


Script no 1:

Code: ags

Ã,  // script for hotspot1: Look at hotspot
SetBackgroundFrame(1);
Wait(20);Ã,  Ã, 


Script no 2:

Code: ags

Ã,  // script for hotspot1: Look at hotspot
SetBackgroundFrame(0);Ã,  
Wait(20);


I want background frame 1 to appear for the duration of the dialog, then switch back to frame 0. But when I run the game, nothing happens. Why is that?

Gilbert

Hmm did the other stuffs (Display message, dialog) get executed?

Radiant

adding a wait(1) between enabling the bg frame and the displaying of the message should do it.
Because displaying a message doesn't actually update the screen behind it.

simulacra

Quote from: Gilbot V7000a on Wed 28/07/2004 07:29:40
Hmm did the other stuffs (Display message, dialog) get executed?

Yes, no problem there.

simulacra

Quote from: Radiant on Wed 28/07/2004 15:15:37
adding a wait(1) between enabling the bg frame and the displaying of the message should do it.
Because displaying a message doesn't actually update the screen behind it.


I see. But as you can see in the scripts above, I already did that.

strazer

Try this:

Code: ags

Look at hotspot
- Game - Display a message (0)
- (?) Conditional - If the player has inventory item (11)
-- Run script [No 1, See below]
-- Run script [No 2, See below]


Script no 1:

Code: ags

  // script for hotspot1: Look at hotspot
SetBackgroundFrame(1);
Wait(20);   
DisplayMessage(11);
RunDialog(17);


Script no 2:

Code: ags

  // script for hotspot1: Look at hotspot
SetBackgroundFrame(0); 
Wait(20);

simulacra


strazer

You're welcome. :)

I suspect it didn't work because "Run script" commands are always executed last in the interaction editor list, so the execution order was actually

-- Game - Display a message (11)
-- Game - Run dialog (17)
-- Run script [No 1, See below]
-- Run script [No 2, See below]

Thus, the dialog did run before the background was changed.
Anyway, I'm glad it works now.

simulacra

Quote from: strazer on Wed 28/07/2004 21:35:22
I suspect it didn't work because "Run script" commands are always executed last in the interaction editor list

Do they? That's very odd, I think.

strazer

Last time I checked, yes.
I agree it's not very intuitive, but I think if it was easy to do CJ would already have changed it, so I guess it has to do with the way AGS works internally.
Deal with it. ;)

Scorpiorus

Quote from: simulacra on Wed 28/07/2004 21:38:23
Quote from: strazer on Wed 28/07/2004 21:35:22
I suspect it didn't work because "Run script" commands are always executed last in the interaction editor list

Do they? That's very odd, I think.
Yeah, and it's even odder because they are also can be executed at the exact order you put them in. It's due to the fact AGS can only run one script at a time and thus if you look at the hotspot AGS is inside the on_mouse_click function running ProcessClick(), it can't run the script you attached to the RunScript action so AGS delays it till the on_mouse_click function is done (i.e. after the interaction). It would preserve the sequence of RunScript's scripts if you used a Player enters screen (after fade-in) interaction instead, for example.

SMF spam blocked by CleanTalk