Storing variables directly on the module object doesn’t automatically make them accessible in all scripts within the module. Module variables can be set up and accessed like this:
int nCakes = GetLocalInt(GetModule(), "AMOUNT_OF_CAKES");
… and modified the usual way, too:
SetLocalInt(GetModule(), "AMOUNT_OF_CAKES", 41);
… while constants can be read (but not modified!) from within any function, provided that the constant has previously been declared within that script, or within a library included in the script:
const int AMOUNT_OF_CAKES = 42;
void OutputCakeMessage(object oTarget)
{
SendMessageToPC(oTarget, "There is only one acceptable amount of cakes. "+IntToString(AMOUNT_OF_CAKES)+". If we have fewer cakes than that, we are doing something wrong.");
}
int AmountOfCakes()
{
return AMOUNT_OF_CAKES;
}