Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Plugins & Mods

Quests::Plugins & Mods Completed plugins for public use as well as modifications.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-27-2012, 08:29 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default stupid perl tricks, vol. 1

i have a migraine, so i decided to share.

plugins\client_first.pl
Code:
use Scalar::Util qw(blessed);

# insert missing $client object as first parameter passed to subroutine
# usage: @_ = plugin::ClientFirst(@_);
sub ClientFirst
{
    unshift(@_, plugin::val('$client'))
        if ((blessed($_[0]) // '') ne 'Client');
    @_;
}
example usage (in plugins\check_hasitem.pl):
Code:
#checks to see if player has item
#useage plugin::check_hasitem($client, itemid);
sub check_hasitem
{
    @_ = plugin::ClientFirst(@_);
    my $client = shift;
    my $itmchk = shift;
    # yada yada
    ...;
}
with this addition, either of these would be valid:

Code:
my $found = plugin::check_hasitem($client, $itemid);
my $found = plugin::check_hasitem($itemid);
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:57 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3