User:Haama/FAR
< User:Haama
Jump to navigation
Jump to search
Revision as of 15:22, 26 March 2009 by imported>Haama
Functional Activators refer to scripts that behave like common programming functions. Like functions, they can:
- Be called from another script at any time
- Will happen immediately, before the next line of code is processed
- Can be nested (though note the limitation below)
- Take input parameters and can return output parameters
- Make your code easier to read and write
- Centralize sections of your code
In which Bethesda makes things harder (or you realize this is a bit of a hack)
The script is really what defines the Function, what it will do, and does the work. However, you're not able to simply call a script in Oblivion... like quests, added items have to use a function... here we use Activate, and so we need to have a reference to actually Activate...
You have to call a specific reference. there are a few steps you need to go through to set up each Functional Activator.
- Before you make any Functional Activator you'll want to create an empty cell. You'll use this cell to hold all of the activators.
- Each Functional Activators require 3 parts: the script, the base activator, and the persistent reference activator. The script is the fundamental definition of the Functional Activator and is discussed
- The script needs an onActivate block and will generally look like
- Base Activator - it can be any object, but activators
...
empty cell, disable, persistent
...
can be any object, but activators are best
General description
What they're useful for
- Centralize code
- Simplify code - can put complex if tests in separate FAR
Maybe go in order from least to most complex
- onActivate only
- Inputs/Outputs/Variables
- Heart-beat
Limitations
- Only 4 within each other
- Careful with Labels/loops
- Will take more processing due to more set/if statements, but those take 1000s to become a problem
- Probably not a good idea to trust between save/load
Preference over other script types (should really be on Global page)
- Compared to quest scripts
- Run instantly
- No need to handle timing issues and flags
- Quest scripts may be more reliable for long-term scripts
- Run instantly
- Compared to result scripts
- Longer
- Can store variables, use ref variables in functions
- However, result scripts can have an infinite nest depth
- Compared to token
- Store the information
- Tokens better at keeping information for each actor, etc.
scn ScriptNameFAS ;FAS for Functional Activator Script, not necessary but helpful to keep scripts organized begin onActivate ;function code end