PDA

View Full Version : Integer in a global example.


Secrets
10-27-2007, 11:43 PM
This is an example of how you can store an integer for later use using perl.

This script can add one to a global every time you tell it 'store'.

It's an overlooked concept, so i'd thought i'd post it.


sub EVENT_SAY
{
my $variable = 1;
my $storedvariable = $qglobals{variablesaved} ? $qglobals{variable saved} : 0;

if ($text=~/hail/i)
{
quest::say("Do you wish to [store] the variable + 1 and have me [return] it as two?");
}

if ($text=~/store/i)
{
$variable += 1;
quest::setglobal('storedvariable', $variable, 5, 'F');
quest::say("I have stored the variable plus one as $storedvariable.");
}

if ($text=~/return/i)
{
quest::say("My storedvariable is $storedvariable.");
}
}


Make sure quest globals are toggled on, on the NPC you try this on.