Persistent Variables

Scripted ALFA systems & related tech discussions (ACR)

Moderators: ALFA Administrators, Staff - Technical

Locked
User avatar
Teric neDhalir
Githyanki
Posts: 1495
Joined: Mon Jan 05, 2004 10:04 pm
Location: Manchester UK

Persistent Variables

Post by Teric neDhalir »

Following on from various discussions about alignment/reputation and dynamic statics I'm interested to try some scripts including persistent variables. Two questions; To use the functions detailed on the Wiki do you need an include in your script; and are you encouraging such things or would you rather the database was left alone?
Cheers,
Teric
User avatar
indio
Ancient Red Dragon
Posts: 2810
Joined: Sat Jan 03, 2004 10:40 am

Post by indio »

This is to be used in a conversation in Actions Taken (hit refresh so you can set the variable name and value).

Code: Select all

#include "ginc_param_const"
#include "ginc_var_ops"
#include "acr_db_persist_i"

void main(string sVariable, string sChange, string sTarget)
{
    object oPC = GetPCSpeaker();
	if (GetIsObjectValid(oPC) == FALSE) 
		PrintString("ga_local_int: " + sTarget + " is invalid");

	int nOldValue = ACR_GetPersistentInt(oPC, sVariable);
	int nNewValue = CalcNewIntValue(nOldValue, sChange);

	ACR_SetPersistentInt(oPC, sVariable, nNewValue, 0);
	
    //PrintString(sTarget + "'s variable " + sVariable + " is now set to " + IntToString(nNewValue) );
}
And this is the Text Appears When version:

Code: Select all

#include "ginc_var_ops"
#include "acr_db_persist_i"

int StartingConditional(string sVariable, string sCheck)

{
	object oPC = GetPCSpeaker();	
	int nValue = ACR_GetPersistentInt(oPC, sVariable);
    int iRet = CompareInts(nValue, sCheck);

    //PrintString ("gc_global_int: nValue = " + IntToString(nValue) + ",  sCheck = " + sCheck + " -- return val: " + IntToString(iRet));
    return (iRet);
}
But AL will have the definitive method of doing it. This is just the way I do it.
Image
Locked