Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: simulacra on Tue 27/07/2004 19:35:47

Title: [SOLVED] SetBackgroundFrame problem
Post by: simulacra on Tue 27/07/2004 19:35:47
I have a room where there is an area you can look at, and if you do there is the following interaction:


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:


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


Script no 2:


Ã,  // 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?
Title: Re: SetBackgroundFrame problem
Post by: Gilbert on Wed 28/07/2004 07:29:40
Hmm did the other stuffs (Display message, dialog) get executed?
Title: Re: SetBackgroundFrame problem
Post by: 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.
Title: Re: SetBackgroundFrame problem
Post by: simulacra on Wed 28/07/2004 20:01:18
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.
Title: Re: SetBackgroundFrame problem
Post by: simulacra on Wed 28/07/2004 20:02:35
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.
Title: Re: SetBackgroundFrame problem
Post by: strazer on Wed 28/07/2004 20:34:35
Try this:


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:


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


Script no 2:


  // script for hotspot1: Look at hotspot
SetBackgroundFrame(0);
Wait(20);
Title: Re: SetBackgroundFrame problem
Post by: simulacra on Wed 28/07/2004 20:54:25
It worked!

Thank you strazer!
Title: Re: SetBackgroundFrame problem
Post by: strazer on Wed 28/07/2004 21:35:22
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.
Title: Re: SetBackgroundFrame problem
Post by: 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.
Title: Re: [SOLVED] SetBackgroundFrame problem
Post by: strazer on Wed 28/07/2004 22:49:14
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. ;)
Title: Re: SetBackgroundFrame problem
Post by: Scorpiorus on Wed 28/07/2004 23:49:21
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.