Session variables

Tutorials and guides for Plazma Burst and community features.

Session variables

Postby mrnat444 » 24 December 2017, 10:54

Recently in a PB2 update, some new actions were added to triggers, these included session variables. It might be a little confusing how session variables work, or how to use them, so this post should hopefully help you understand and utilize them in maps.


What are session variables?

A session variable is used like a regular variable (refer here), except that, unlike regular variables, session variables are independent from a single map, and maintain their values as long as the page life lasts before closing/reloading the page. This means that you can transfer values for variables between maps or map restarts. Because session variables are not used for anything else, you can think of them as separate, more permanent (but still temporary) data storage that is exclusively used and modified by regular variables.


How do you use them?

You can first save the value of a regular variable into a session variable, and then on another map (or the same map), load that session variable's value into a regular variable.
Session variables are available through three different action types:

1.
Clears all the current saved session variables, as if you reloaded the page

2.
Saves the value of a regular variable into the value of a session variable

3.
Loads the value of a session variable into the value of a regular variable (if this regular variable was previously defined with a value, it is overwritten)


What are their uses?

Session variables allow for different maps to be tied together more, and influence each other (or themselves) in any way you like. Session variables can be saved and loaded both in and across singleplayer/multiplayer, although note that session variables will only affect your session of the game, and will not affect other players unless a map is specifically designed to do so.


For some reason the parameters of session variable trigger actions seem to be reversed as to how they are described, but you will not need to worry about this most of the time because you can use identical session variable names to regular variables, since session variables and regular variables do not conflict with each other. In short, both parameters can be identical.
Last edited by mrnat444 on 22 January 2020, 11:38, edited 2 times in total.
User avatar
mrnat444
Usurpation Soldier [50]
 
Posts: 70
Joined: 16 October 2013, 00:51

Re: Session variables

Postby wreak » 30 December 2017, 07:39

Could you make an open source for this. Also could this in theory work for zooming so some players could have farther viewing range? (I'm trying to make a hostage map and some of the trigger systems I need are somewhat complex)
wreak
User avatar
wreak
Civil Security Boss [500]
 
Posts: 577
Joined: 23 January 2015, 02:01

Re: Session variables

Postby darkstar 1 » 1 January 2018, 11:35

wreak wrote:Could you make an open source for this. Also could this in theory work for zooming so some players could have farther viewing range? (I'm trying to make a hostage map and some of the trigger systems I need are somewhat complex)

I think that could work, but there are easier ways without the session variables.



User avatar
darkstar 1
Proxy [700]
 
Posts: 712
Joined: 13 September 2014, 13:20
Location: Here... or there :|


Return to Tutorials

Who is online

Users browsing this forum: No registered users