(SOLVED) How does Room End work?

Discussion in 'Programming' started by ZombieSquirrel, Jun 14, 2019 at 11:11 PM.

  1. ZombieSquirrel

    ZombieSquirrel Member

    Joined:
    Oct 18, 2018
    Posts:
    60
    Hi,

    I was wondering just how the room end event works. I have a room with a bunch of instances.
    I would like to set a certain variable when I leave the room, in this case the current "day" in my game.
    This should only happen when I leave the room. When I return, and it's not the same day,
    that difference between that variable and what the current day is, will cause things to happen, to update.

    However, this room is persistent, so I was wondering if this would affect anything if I use the room end event.
    The documentation isn't clear enough for me to understand the exact way Room End works.

    Anyone got a little more in-depth explanation about this event?
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,368
    Room End events simply run when you leave a room. Whether or not the room or any instances are persistent won't matter.
     
    ZombieSquirrel likes this.
  3. ZombieSquirrel

    ZombieSquirrel Member

    Joined:
    Oct 18, 2018
    Posts:
    60
    okay that's incredibly useful then! thanks!
     
  4. ZombieSquirrel

    ZombieSquirrel Member

    Joined:
    Oct 18, 2018
    Posts:
    60
    Hmm it doesn't seem to work in even the most basic form.
    I have a tree, it needs to spawn a new one each day.
    In the tree's room end event I say: "DayLeftRoom = TimeDays".
    TimeDays is a global variable that updates each day by +1.
    Since this code is only run once in the Room End event, when I leave the map, DayLeftRoom is set to that exact day.
    When I return the next day, that DayLeftRoom is still the day I left.
    Then I say something like (step event): if DayLeftRoom < TimeDays {Growth +1), meaning
    if a day is not the same one as when i left, the tree needs to grow.
    Nothing happens, as if the room end event also updates and DayLeftRoom is always equal to the constantly updated TimeDays global variable! This leads me to believe the room end event doesn't work on persistent rooms... I'm doing something wrong for sure.
     
  5. ZombieSquirrel

    ZombieSquirrel Member

    Joined:
    Oct 18, 2018
    Posts:
    60
    Never mind, i forgot to set a very important create event variable xD It does indeed work by leaving the room, to set a variable "in stone" so to speak.
     
    obscene likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice