Author Topic: How to write some AS modules  (Read 3448 times)

Offline adumbperson

  • Turn around in orbit!
How to write some AS modules
« on: June 30, 2016, 02:50:09 pm »
Write your constants into some module_name_h.fos
Code: [Select]
#define ONE_THING (0)
#define TWO_THING (1)
#define THREE_THING (2)

// also write your IMPORT here
#ifdef _MODULE_NAME
import void superFuncDoingSuperStuff() from "module_name.fos";
#endif

write your module abstraction into some module_name.fos
Code: [Select]
#include "module_name_h.fos" // to have our previous declaration available

string@[] meh = {
"one_thing",
"two_thing",
"three_thing"
};

void superFuncDoingSuperStuff()
{
    Log("Sorry for my lazyness.\n" + meh[THREE_THING] );
}


Now to use your module just add this to scripts.cfg
Code: [Select]
@ server module module_name
and to use it through your scripts
into client_main.fos as example
Code: [Select]
#define _MODULE_NAME
#include "module_name_h.fos" // so the IMPORTS works here

// through some client_main.fos's function
#ifdef _MODULE_NAME // checks the availability
superFuncDoingSuperStuff(); // use if available
#endif

You can also use __CLIENT/__SERVER constants
Code: [Select]
#ifdef __SERVER
// server side
#endif

#ifdef __CLIENT
// client side
#endif


That's all.
« Last Edit: June 30, 2016, 03:31:30 pm by adumbperson »
The Death After Life.
About me. I hate people generally I still may have respectful talk and recognize the good persons. Careful to what you say, I'm not a kid. My experiences defines me.
[Awaxx] -2024/10/17-