EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Integer in a global example. (https://www.eqemulator.org/forums/showthread.php?t=23826)

Secrets 10-27-2007 11:43 PM

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.


All times are GMT -4. The time now is 04:44 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.