EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Player.pl and Player.lua - can they coexist? (https://www.eqemulator.org/forums/showthread.php?t=39465)

Twilightmist 03-12-2015 09:57 PM

Player.pl and Player.lua - can they coexist?
 
I was playing around with global server wide quests last night, and wanted to run a simple test in player.pl to write some text when a character levels up. I named the file global_player.pl and put it in the global quest directory. There is a global_player.lua file in there already. When the character leveled, the text did not display. The code was your example sample player quest code:

sub EVENT_LEVEL_UP {
$client->Message(15, "You've leveled up, you are now $ulevel, perhaps you should go adventure elsewhere now.");
}

My question is, does only one of these files take presidence? I don't want to disturb the .lua file there because it looks like it adds adventure text I would like to see.

The reason for asking is my goal is to have a quest that scribes players spells when they level up. Is player.pl the place to put such a quest? Can someone suggest an alternative?

Thanks!

ghanja 03-12-2015 10:28 PM

Quote:

Originally Posted by Twilightmist (Post 238599)
I was playing around with global server wide quests last night, and wanted to run a simple test in player.pl to write some text when a character levels up. I named the file global_player.pl and put it in the global quest directory. There is a global_player.lua file in there already. When the character leveled, the text did not display. The code was your example sample player quest code:

sub EVENT_LEVEL_UP {
$client->Message(15, "You've leveled up, you are now $ulevel, perhaps you should go adventure elsewhere now.");
}

My question is, does only one of these files take presidence? I don't want to disturb the .lua file there because it looks like it adds adventure text I would like to see.

The reason for asking is my goal is to have a quest that scribes players spells when they level up. Is player.pl the place to put such a quest? Can someone suggest an alternative?

Thanks!

Yes, if there is a LUA equivalent to a particular type of quest file (in your case the global_player) then, it has precedence over PL (perl).

So you have two options. Remove the LUA version (or rename it to, say, global_player.lu$) or learn LUA and use it and/or Perl (though knowing what I stated above).

dagulus2 03-13-2015 06:57 AM

It is a bit of a pain tbh. Global_player is probably the one place where it would be nice if there was some sort of workaround allowing you to somehow use both.

ghanja 03-13-2015 11:53 AM

Quote:

Originally Posted by dagulus2 (Post 238609)
It is a bit of a pain tbh. Global_player is probably the one place where it would be nice if there was some sort of workaround allowing you to somehow use both.

But why?

/10char

Twilightmist 03-13-2015 12:27 PM

Thank you for the answers. I suspected this is what was happening. As to "Why" we would like to use both is because learning Perl is probably enough for a beginner in programming, without having to learn Lua too.

This is a great opportunity to learn some basic programming skills, using a medium I love (Everquest) but it is a little overwhelming at first.

Akkadius 03-13-2015 12:34 PM

Quote:

Originally Posted by Twilightmist (Post 238615)
Thank you for the answers. I suspected this is what was happening. As to "Why" we would like to use both is because learning Perl is probably enough for a beginner in programming, without having to learn Lua too.

This is a great opportunity to learn some basic programming skills, using a medium I love (Everquest) but it is a little overwhelming at first.

Perl is the master race.

ghanja 03-13-2015 01:14 PM

Quote:

Originally Posted by Twilightmist (Post 238615)
Thank you for the answers. I suspected this is what was happening. As to "Why" we would like to use both is because learning Perl is probably enough for a beginner in programming, without having to learn Lua too.

This is a great opportunity to learn some basic programming skills, using a medium I love (Everquest) but it is a little overwhelming at first.

I thought you may have had a technical reason for the request. Something that perhaps some coding assistance may have allowed you to overcome. I understand the "why" now to mean, you would have liked both perl and lua versions to be provided in which to learn from. So.

Here is the (older) Perl global_player.pl:

Code:

sub EVENT_ENTERZONE {
  if($ulevel >= 15 && !defined($qglobals{Wayfarer}) && $client->GetStartZone()!=$zoneid && $zoneid !=50 && $zoneid !=12) {
    $client->Message(15,"A mysterious voice whispers to you, 'If you can feel me in your thoughts, know this -- something is changing in the world and I reckon you should be a part of it. I do not know much, but I do know that in every home city and the wilds there are agents of an organization called the Wayfarers Brotherhood. They are looking for recruits . . . If you can hear this message, you are one of the chosen. Rush to your home city, or search the West Karanas and Rathe Mountains for a contact if you have been exiled from your home for your deeds, and find out more. Adventure awaits you, my friend.'");
  }
}

sub EVENT_COMBINE_SUCCESS
{
    if ($recipe_id =~ /^1090[4-7]$/) {
        $client->Message(1,
            "The gem resonates with power as the shards placed within glow unlocking some of the stone's power. ".
            "You were successful in assembling most of the stone but there are four slots left to fill, ".
            "where could those four pieces be?"
        );
    }
    elsif ($recipe_id =~ /^10(903|346|334)$/) {
        my %reward = (
            melee  => {
                10903 => 67665,
                10346 => 67660,
                10334 => 67653
            },
            hybrid => {
                10903 => 67666,
                10346 => 67661,
                10334 => 67654
            },
            priest => {
                10903 => 67667,
                10346 => 67662,
                10334 => 67655
            },
            caster => {
                10903 => 67668,
                10346 => 67663,
                10334 => 67656
            }
        );
        my $type = plugin::ClassType($class);
        quest::summonitem($reward{$type}{$recipe_id});
        quest::summonitem(67704);
        $client->Message(1,"Success");
    }
}


ghanja 03-13-2015 01:25 PM

Actually, now looking at the new global_player.lua, perhaps this code would more closely resemble the way it works:

Code:

sub EVENT_ENTERZONE {
        if (($ulevel >= 15) && (!defined($qglobals{Wayfarer}))) {
                my @wayfarerzones = [1,2,3,8,9,10,19,22,23,24,29,30,34,35,40,41,42,45,49,52,54,55,60,61,62,67,68,75,82,106,155,202,382,383,392,393,408];
                if ($client->GetStartZone()!=$zoneid && $zoneid ~~ @wayfarerzones) {
                        $client->Message(15,"A mysterious voice whispers to you, 'If you can feel me in your thoughts, know this -- ".
                                                                "something is changing in the world and I reckon you should be a part of it. I do not know much, ".
                                                                "but I do know that in every home city and the wilds there are agents of an organization called the ".
                                                                "Wayfarers Brotherhood. They are looking for recruits . . . If you can hear this message, you are ".
                                                                "one of the chosen. Rush to your home city, or search the West Karanas and Rathe Mountains for a ".
                                                                "contact if you have been exiled from your home for your deeds, and find out more. Adventure awaits you, my friend.'");
                }
        }
}

Untested, as every server I've helped with has ripped out the entire WB functionality.

Twilightmist 03-13-2015 01:40 PM

Yes, that's exactly the reason! Thanks for the code. I will try it out and let you know.

Hey Akkadius, you work on the EZ server, right? How was the spell scribing when you level implemented there? I thought that was a great feature.

ghanja 03-13-2015 01:50 PM

There are at least two posts showing such level up examples. Here is just one thread:

http://www.eqemulator.org/forums/showthread.php?t=36263

Twilightmist 03-13-2015 02:48 PM

Perfect, thanks ghanja!

dagulus2 03-14-2015 05:51 AM

Quote:

Originally Posted by ghanja (Post 238621)
Actually, now looking at the new global_player.lua, perhaps this code would more closely resemble the way it works:

Code:

sub EVENT_ENTERZONE {
        if ($ulevel >= 15 & !defined($qglobals{Wayfarer})) {
                my @wayfarerzones = [1,2,3,8,9,10,19,22,23,24,29,30,34,35,40,41,42,45,49,52,54,55,60,61,62,67,68,75,82,106,155,202,382,383,392,393,408];
                if ($client->GetStartZone()!=$zoneid && $zoneid ~~ @wayfarerzones) {
                        $client->Message(15,"A mysterious voice whispers to you, 'If you can feel me in your thoughts, know this -- ".
                                                                "something is changing in the world and I reckon you should be a part of it. I do not know much, ".
                                                                "but I do know that in every home city and the wilds there are agents of an organization called the ".
                                                                "Wayfarers Brotherhood. They are looking for recruits . . . If you can hear this message, you are ".
                                                                "one of the chosen. Rush to your home city, or search the West Karanas and Rathe Mountains for a ".
                                                                "contact if you have been exiled from your home for your deeds, and find out more. Adventure awaits you, my friend.'");
                }
        }
}

Untested, as every server I've helped with has ripped out the entire WB functionality.

Brings up the feedback message '[Quests] Possible precedce problem on bitwise & operator at quests/global/global_player.pl line 2.'

ghanja 03-14-2015 11:48 AM

Quote:

Originally Posted by dagulus2 (Post 238634)
Brings up the feedback message '[Quests] Possible precedce problem on bitwise & operator at quests/global/global_player.pl line 2.'

Put your global_player.pl in code blocks so we can look at it.

dagulus2 03-14-2015 12:10 PM

Currently:

Code:

###EQ20 global_player file, based on code by ghanja, Kingly_Krab, spyyder

sub EVENT_ENTERZONE {
        if (quest::istaskcompleted(9999) == 0 && quest::istaskactive(9999) == 0) #Check if completed Task: Welcome to EQ20
        {
            quest::assigntask(9999); #Force assign Task: Welcome to EQ20
                }
        if ($ulevel >= 15 & !defined($qglobals{Wayfarer})) {
                my @wayfarerzones = [1,2,3,8,9,10,19,22,23,24,29,30,34,35,40,41,42,45,49,52,54,55,60,61,62,67,68,75,82,106,155,202,382,383,392,393,408];
                if ($client->GetStartZone()!=$zoneid && $zoneid ~~ @wayfarerzones) {
                        $client->Message(15,"A mysterious voice whispers to you, 'If you can feel me in your thoughts, know this -- ".
                                                                "something is changing in the world and I reckon you should be a part of it. I do not know much, ".
                                                                "but I do know that in every home city and the wilds there are agents of an organization called the ".
                                                                "Wayfarers Brotherhood. They are looking for recruits . . . If you can hear this message, you are ".
                                                                "one of the chosen. Rush to your home city, or search the West Karanas and Rathe Mountains for a ".
                                                                "contact if you have been exiled from your home for your deeds, and find out more. Adventure awaits you, my friend.'");
                }
        }
}

sub EVENT_COMBINE_SUCCESS
{
    if ($recipe_id =~ /^1090[4-7]$/) {
        $client->Message(1,
            "The gem resonates with power as the shards placed within glow unlocking some of the stone's power. ".
            "You were successful in assembling most of the stone but there are four slots left to fill, ".
            "where could those four pieces be?"
        );
    }
    elsif ($recipe_id =~ /^10(903|346|334)$/) {
        my %reward = (
            melee  => {
                10903 => 67665,
                10346 => 67660,
                10334 => 67653
            },
            hybrid => {
                10903 => 67666,
                10346 => 67661,
                10334 => 67654
            },
            priest => {
                10903 => 67667,
                10346 => 67662,
                10334 => 67655
            },
            caster => {
                10903 => 67668,
                10346 => 67663,
                10334 => 67656
            }
        );
        my $type = plugin::ClassType($class);
        quest::summonitem($reward{$type}{$recipe_id});
        quest::summonitem(67704);
        $client->Message(1,"Success");
    }
}

sub EVENT_SAY {
        if($text=~/internet/i) {
        $client->SendWebLink("https://www.google.com");
        }
}

sub EVENT_DISCOVER_ITEM {
        $client->Message(335, "You discovered " . quest::varlink($itemid) . "!");
        #quest::we("$name discovered " . quest::varlink($itemid) . "!", 335, 1, 0, 0);
        #quest::crosszonemessageplayerbyname(335, "$name discovered " . plugin::varlink($itemid) . "!");
}

Feedback message is now on line 8. The feedback message was there before I added the code to assign the task.

ghanja 03-14-2015 12:19 PM

Replace line 8 with:
Code:

if (($ulevel >= 15) && (!defined($qglobals{Wayfarer}))) {
I mistyped and had only one ampersand.


All times are GMT -4. The time now is 12:29 PM.

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