Frictional Games Forum (read-only)
[SCRIPT] How to make something happen in the after doing something in another level. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] How to make something happen in the after doing something in another level. (/thread-24626.html)



How to make something happen in the after doing something in another level. - Radical Batz - 02-14-2014

This may be hard to explain but I'll tell you in detail.

I have this door in a map which is a gate and it's locked, so you go in this level door/other map. and when you finished puzzle in that map and return to the old map, then something has happened. The door has been opened.

What I'm trying to say is, How do you make something happen in a map when you did something in another map. uuuuuuh this is hard to explain. I am trying to make something happen in the level where everything is safe and the door is locked but when you have solved a puzzle or did anything in another level then when you enter the old map again some thing appears and the door is unlocked.

Very similar when you finished the puzzle in the machine room. elevator doors open and the shadow starts appearing, only when you finished the puzzle in the other level. There I hope you understand what I'm trying to say.

So pls tell me what's that code to do that or what I'm supposed to do plss. thanks Big Grin


RE: How to make something happen in the after doing something in another level. - Unearthlybrutal - 02-14-2014

Use global variables.
More info


RE: How to make something happen in the after doing something in another level. - PutraenusAlivius - 02-14-2014

You can only use Global Variables in the Global.hps, a seperate hps file than the rest. No need to pair it with a map, just an hps file.


RE: How to make something happen in the after doing something in another level. - Mudbill - 02-14-2014

Yes, I recommend reading up on some of the variables linked above. You will need at least some understanding of how they work. In some practical work, you'd use the script called
Code:
SetGlobalVarInt(string& asName, int alVal);
or related ones. This one creates a variable you can use within a level, but which can also be read from other levels. This means you can change the value in one level, then check for the value in another level and it will get the most recent change.

So in this case you'd want to change the value when you trigger what needs to be done in that one map, then when you return to your other map, you use an if statement within OnEnter(). Make it compare with the value you set in the other map using the GetGlobalVarInt(string& asName); function.

For example in map A you pull a lever. The callback for the lever uses
Code:
SetGlobalVarInt("Lever", 1);
When you return to map B, OnEnter() has
Code:
if(GetGlobalVarInt("Lever") == 1) UnlockDoor();
or something similar.

(02-14-2014, 03:19 PM)JustAnotherPlayer Wrote: You can only use Global Variables in the Global.hps, a seperate hps file than the rest. No need to pair it with a map, just an hps file.

You can actually use them in the level .hps files as well.


RE: How to make something happen in the after doing something in another level. - PutraenusAlivius - 02-14-2014

(02-14-2014, 03:24 PM)Mudbill Wrote:
(02-14-2014, 03:19 PM)JustAnotherPlayer Wrote: You can only use Global Variables in the Global.hps, a seperate hps file than the rest. No need to pair it with a map, just an hps file.

You can actually use them in the level .hps files as well.

My whole life is a lie.