View Single Post
  #1  
Old 10-27-2007, 11:43 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default Integer in a global example.

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.

Code:
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.
Reply With Quote