Jibble

There is a new version of the forums ready for testing. Please post here if you're willing to help test! We could also use the help of coders!

Author Topic: Room resets the BG when leaving the room  (Read 196 times)

AndreasBlack

  • Max Fury that's me
Room resets the BG when leaving the room
« on: 15 May 2022, 09:41 »
I have two bakground images one with Lights and one without, so to flip the light switch in the room, i obviously call "SetBakgroundframe(1)", etc.
Everything was working fine, until i realised that the light keeps resetting itself when leaving the room.
So obvious would be to put something in "leaves room" i suppose, tried that, no success. or "Room load".


I've tried various codes, but they all come down to the same outcome visually, which is that for a microsecond the lights are the "standard state when loading the room with SetBakground" and then changes back to the correct BG image (Lights on=true/false), which is obviously not what i want.

This was my last try in the globalscripts repeatedly_execute_always()



Code: Adventure Game Studio
  1. if (player.Room==1 && Lights_On==false)
  2.  {
  3.    SetBackgroundFrame(0);
  4.  }
  5.  
  6.  
  7. else if (player.Room==1 && Lights_On==true)
  8.  {
  9.    SetBackgroundFrame(1);
  10.  }

 



Matti

Re: Room resets the BG when leaving the room
« Reply #1 on: 15 May 2022, 11:05 »
The manual says "The frame lock is released when the game changes rooms." so this is normal behavior.

Putting SetBackgroundFrame(); in room_load should work though, because it sets the background before the screen fades in. You should try that (again) and post your code in case it really doesn't work.

AndreasBlack

  • Max Fury that's me
Re: Room resets the BG when leaving the room
« Reply #2 on: 15 May 2022, 12:33 »
Jesus, that was the first thing i've tried and i think the screen flickered between the two frames?! I must have done something to mess up the code that i did not notice last night (laugh) Thanks anyways! Nothing wrong with the code itself that's posted, just where it's placed in the room. Beginners take notice :)

Re: Room resets the BG when leaving the room
« Reply #3 on: 17 May 2022, 12:31 »
This should be enough:
Code: Adventure Game Studio
  1. function room_Load() {
  2.    SetBackgroundFrame(Lights_On); // bool becomes 0 or 1
  3. }

AndreasBlack

  • Max Fury that's me
Re: Room resets the BG when leaving the room
« Reply #4 on: 17 May 2022, 14:12 »
Thanks Khris!