|
|
(5 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | '''Variables''', implemented in retail FS2, can be a powerful FRED tool. [[FREDder]]s use variables for the same two reasons that programmers do. One, they allow you to easily store pieces of information for later use, which can be modified and used to do cool things. Two, they let you avoid hard-coded or "magic" numbers for arguments that you use several times in your mission's events.
| + | #Redirect: [[Variable]] |
− | | |
− | Using variables is simple. You can use variables in place of any SEXP argument where you would normally use a string or number. Right-click on the argument in the Events list and look at the three options at the bottom of the menu, '''Add Variable''', '''Modify Variable''', and '''Insert Variable'''. Click '''Add Variable''' to create a new variable. '''Modify Variable''' allows you to change a variable that you've already created. '''Insert Variable''' replaces the currently selected SEXP argument with the variable of your choice.
| |
− | | |
− | == Three Types of Variables ==
| |
− | | |
− | There are three types of variables.
| |
− | | |
− | '''Player-persistent:''' This type of persistent variable is stored in the pilot file. Further, they are stored immediately when they are created/changed from within a mission. This means that any change is going to be there regardless of the later outcome of the mission. Player-persistent variables can be accessed and changed from any campaign played with the same pilot.
| |
− | | |
− | '''Campaign-persistent:''' These persistent variables are stored in the campaign file, and are only stored when a campaign progresses to a new mission. So if the player is killed or quits during a mission, and changes made to a campaign-persistent variable are not stored.
| |
− | | |
− | '''Network variables''' are only relevant in a multiplayer game. Non-network variables are only ever altered on the server. This means that they can not be used in messages or scripting because all the client machines will only ever have the default value. If you need to have the value of a variable display in a message you will need to mark it as a network variable. ''
| |
− | | |
− | == Variables and Messages ==
| |
− | | |
− | Variables can also be used in messages. To do this, use the variable's name preceded by the '$' token (for example "$killcount"), and in-game this will be replaced with the value of the variable. It works for both numeric and string variables.
| |
− | | |
− | ==Links==
| |
− | | |
− | *[http://homepage.ntlworld.com/karajorma/FAQ/fredretail.html#variables Karajorma's FreeSpace FAQ on variables]
| |
− | * Fred Zone examples for variables [http://fredzone.hard-light.net/cetanu_adv-fred-lessons.shtml] [http://fredzone.hard-light.net/cetanu_adv-fred-lessons-2.shtml]
| |
− | | |
− | [[Category:FRED]] | |