Author Topic: Persistant Variables  (Read 2253 times)

0 Members and 1 Guest are viewing this topic.

Offline magatsu1

  • 210
I know these were introduced a while ago but I've never really looked at 'em. I was just wondering how they differ from the standard variables.
Blitzerland: Knows what he's talkin' about

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Basically they persist :D

The Wiki has an explaination of how they work but I've just read it and you may find it a little technical

http://dynamic4.gamespy.com/~freespace/fsdoc/index.php/Persistent%20Variables


So here's a simpler (well less technical at least) explaination :D

Standard variables can only be used in the mission they appear in. At the end of the mission FS2 cleans up wiping the variable completely.
Persistant variables on the other hand are recorded in the campaign file (or pilot file). As a result once you have declared a persistant variable you can use it in any later point in the campaign where it will remember the value it was set to earlier.

There are actually two kinds of persistant variables. Campaign Specific and Player Specific depending on where they are saved. The way they work is subtly different.  

The player specific variable is actually the simpler one of the two. Suppose in mission 2 of a campaign I set a player specific variable to 5. On loading mission 7 of the campaign the variable will still equal 5. Suppose I now set the value to 10. Shortly after this (while still in mission 7) the player gets killed. This time when the mission starts the variable equals 10. In other words PS variables always equal whatever they were last set to.

The campaign specific variable works slightly differently. Taking the above example suppose in mission 2 of a campaign I set a player specific variable to 5. On loading mission 7 of the campaign the variable will still equal 5. Suppose I now set the value to 10. Shortly after this (while still in mission 7) the player gets killed again. On restarting the mission the variable is reset to 5 again. CS variables only permanently change when you move on to the next mission in the campaign.

The write up on the Wiki gives examples of what you could use both kinds for.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline magatsu1

  • 210
Quote
Originally posted by karajorma
Basically they persist :D
The Wiki has an explaination of how they work but I've just read it and you may find it a little technical[



you callin' me thick ?:wtf:












;) ta. I didn't knoiw they were in the wiki.
Blitzerland: Knows what he's talkin' about

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Nah. I just figured that a plain english explaination might be easier to follow :) The Wiki link does rather seem to assume that you have a clue what PVs are. It doesn't so much explain what PV's are so much as exactly how they are saved and used.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]