Skip to content

Tutorial Create an SQF Object

friznit edited this page Feb 12, 2016 · 1 revision

h1. Tutorial - Create an SQF Object

{{toc}}

h2. Object Base Classes

SQF objects come in two base classes:

  • Game Logic (fnc_baseClass.sqf) - ideally suited for editor modules or anything that will be based upon an in-game object.
  • CBA Hash (fnc_baseClassHash.sqf) - more lightweight and can be used for everything that doesn't need an in-game object.

h2. Object States

!http://i.imgur.com/qOuROkQ.png! Every object should go through the following states:

  • Create - this creates the object or CBA Hash required for the object to operate around. You do not need to call the create operation if you already have an object, like that created by an Editor Module.
  • Init(ialise) - Init sets up the object basics, such as MAINCLASS and SUPERCLASS pointers, and any other attributes that need to be initialised.
  • State Restored - once you have a base object or hash, you can call the state operation, to restore the object to a previously saved state.
  • State Saved - the state operation can be used to output the current state of the object to a serialised string and future restoration of the current state.
  • Processing - its what the object does
  • Active/Inactive - the standard is the have an active operation, with a boolean argument (true/false), that activates or deactivates the object.
  • Debug Enabled/Disable - using the debug operation, you should be able to turn on and off debug at any time during the lifetime of the object. Ensure any use of markers and logging caters for this ability.
  • Destroyed - use the destroy function to clean up your object to ensure no memory leaks are created instantiating your objects