I know someone out there has solved this: save/read trigger between levels

Hello! I’ve scoured the forums and have gotten close to what I want, but am still experiencing issues. I am trying to use the Save feature to dictate between multiple spawn points between levels. I have a simple Portal 2 example here: http://www.flowlab.io/game/play/1051433

Desired effect: When Chell exits Level 1 through the RED DOOR, I want her to spawn on the left side of Level 2. If she exits Level 1 through the BLUE DOOR, I want her to spawn on the left side of Level 2.

The spawn point on level 1 is set to the center currently so it can be tested again upon return from level 2. The Save function is on the RED DOOR and the BLUE DOOR arrows on Level 1. The Variable Spawn function is on the DOOR block on Level 2.

I feel like I’m really close, and I’m certain someone out there has figured out how to communicate a variable between levels, but I’ve hit a wall and need some expertise. This is a core mechanic that I plan to use in a lot of my games and would really appreciate the help. Thanks!

ALSO: Is there a way to duplicate layers?

Please help! I’m stuck and frustrated on this task and need to solve this issue to be able to proceed on my game. I read through this thread http://forum.flowlab.io/discussion/2220/saving-update that I found and tried to adapt what I found and made it as far as I could. Spent 3 hours on it last night to no avail. :frowning:

hmm, why dont you make the doors handle the saves, and when Chell touches one side, it takes its own X position and Y position, then adds/subtracts 32 to X based off what side she was on, saves it. And when The level starts, have Chell read two saves set to the same things.

(Saves can share numbers if theyre set to the same name)

Hey @todorrobot - there are a bunch of ways to solve this, and using save probably isn’t the simplest way. Save/Read is designed to save values between game sessions, not really between levels. Usually the simplest way to save values between levels is to store it in an object that is set to “keep between levels” and have that object manage what happens when a new level loads.

That being said, you can totally make it work with saves. Here’s an example: https://flowlab.io/game/view/1061775

How that works:

  1. Two doors, one wood (#1), one metal (#2)
  2. When the player touches a door, that door stores the door number using a save block, the player gets deleted, and the next level is loaded
  3. When a level is loaded, each door reads the door value from the Save block. If the value is 2 then the metal door emits a player, otherwise the wood door emits a player.

Some notes:

  • The wood door doesn’t check for any value less than 2, this way it will spawn a player even when nothing is stored (first game on level 1)
  • I used emit instead of spawn, so that it’s a little more Portal-like
  • Using this style system, you can just drop the doors to a level and not worry about adding logic for each level.
    Hope this helps

@grazer Thanks! I’ve been eager to mess around with this all day, but had to do “actual” work this morning. Boooooo! Thanks for the example. I can’t wait to try it out.