Mikero/Sandbox - modules – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
 
m (Text replacement - " (\=+)([a-zA-Z0-9][^ ]+[a-zA-Z0-9])(\=+) " to " $1 $2 $3 ")
 
(5 intermediate revisions by 4 users not shown)
Line 10: Line 10:


------------
------------
=config.cpp=
= config.cpp =
--------
--------
==cfgPatches==
== cfgPatches ==
  class CfgPatches
  class CfgPatches
  {
  {
Line 27: Line 27:
   };
   };
  };
  };
==CfgVehicles==
== CfgVehicles ==
  class CfgVehicles
  class CfgVehicles
  {
  {
Line 48: Line 48:
*You can try screaming about _this, and [this]. it doesn't help much.
*You can try screaming about _this, and [this]. it doesn't help much.


=module init script=
= module init script =


whatever functions (plural) you want to achieve, and whatever  you *might* want init fields of units to play with, they must be reference via
whatever functions (plural) you want to achieve, and whatever  you *might* want init fields of units to play with, they must be reference via
Line 61: Line 61:
'YourFunc1' is the reference name. Thus, later on...
'YourFunc1' is the reference name. Thus, later on...


  returnval= [whatever,arguments] spawn YourFunc1;
  returnval= ([whatever,arguments]) spawn/call YourFunc1;


returnval can of course be anything, including arrays or nothing at all
returnval can of course be anything, including arrays or nothing at all
the awfullness of the comref describes arguments as 'anything at all', or _this, or this, or [an array] or somevalue
the truth is
_this is an unconditional name used in the function itself. it refers to the passed argument(s) if any
what _this is, can be, an array, a single value ,or indeed nil. it purely depends on what is passed (why the biki can't state this is beyond me)
thus
retval= call 'blah';
retval= [] call blah;
retval= somevar call blah;
retval= [somevar] call blah;
are purely dependent on the function 'blah'. eg what it wants. not, some semantic requirement of the call verb itself
[[Category:Sandbox]]

Latest revision as of 16:54, 17 November 2021

modules are a way to add pre-packaged features to a mission or island

modules is a pbo addon like any other with a config.cpp

basic constructions are:

  • instantiate whatever functions give you a thrill in the modules package via a config.cpp eventhandler
  • optionally, modify, ammend, alter or bash, whatever gives you a thrill in the init field of the 'module' when added via the editor
  • optionally, call various functions declared above in the init field of given objects/vehicles/units

config.cpp


cfgPatches

class CfgPatches
{
 class Module_Whatever
 {
  units[] = {};
  weapons[] = {};
// requiredVersion = 0.1;// if needed, although BI themselves haven't respected standard versioning increases until arrowhead. most went backwards. 
                         // ofp resistance still remains the highest version 'out there' making upgrade compatibilities pointless
                         // trying to detect arma1 vs 2 addons is another fruitless excercise.
                         // past history being a guide, arma 3 will start off at version 1.00 again

  requiredAddons[] = {CAUI};//to get at class Logic;
 };
};

CfgVehicles

class CfgVehicles
{
 class Logic;
 class Whatever: Logic
 {
  displayName = "Whatever";
  icon = some\sexy\icon\somewhere;
  picture = \some\sexy\picture\somewhere.paa; // note the \ and paa requirement
  vehicleClass = "Modules";//for standard F7 editing
  class Eventhandlers
  {
   init = "_this execVM '\your\modules\init_whatever.sqf';";
   init = "[this] execVM '\your\modules\init_whatever.sqf';";//alternate syntax
  };
 };
};
  • note that just like everything else, all file references are hard paths to make portability impossible
  • You can try screaming about _this, and [this]. it doesn't help much.

module init script

whatever functions (plural) you want to achieve, and whatever you *might* want init fields of units to play with, they must be reference via

YourFunc1 = compile preprocessFile "\some\function\somewhere1.sqf";
YourFunc2 = compile preprocessFile "\some\function\somewhere2.sqf";
YourFunc3 = compile preprocessFile "\some\function\somewhere3.sqf";



'YourFunc1' is the reference name. Thus, later on...

returnval= ([whatever,arguments]) spawn/call YourFunc1;

returnval can of course be anything, including arrays or nothing at all

the awfullness of the comref describes arguments as 'anything at all', or _this, or this, or [an array] or somevalue

the truth is

_this is an unconditional name used in the function itself. it refers to the passed argument(s) if any

what _this is, can be, an array, a single value ,or indeed nil. it purely depends on what is passed (why the biki can't state this is beyond me)

thus

retval= call 'blah';
retval= [] call blah;
retval= somevar call blah;
retval= [somevar] call blah;

are purely dependent on the function 'blah'. eg what it wants. not, some semantic requirement of the call verb itself