Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 07-13-2009, 04:13 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

How can you make it store a text string? Been thinking about a bot to do guilds.
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #2  
Old 07-13-2009, 04:17 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

here is the final quest I came up with that works with no errors. Thanks again to pfyon for the help.

Code:
#############
#Written By : cubber
#Quest Name: #summonitem proxy
#Quest Zone: Cshome
#Quest NPC: Krakskull
#################
sub EVENT_SAY
{
   if($text=~/Hail/i)
      {
         quest::say("Hello there $name,  need some [items summoned]?");
      }
elsif ($text=~/items summoned/i)
			
			{
				quest::say("$race, I have been gifted with the ability to summon any item or spell in this world for you.  However, I am not a mind reader, and in order for me to summon anything for you I need to know it's ID number.  Please use the command: #itemsearch insert_itemname_here , and just tell me the number next to the item you desire.");
			}
			
				elsif ($text=~/\d{0,9}/)
					{
						quest::emote("Krakskull begins to chant...");
						quest::summonitem("$text");      	
						quest::emote("The item you seek apears before your eyes!");
					}
			
				
}
Obviously you could stick this on any NPC or create one and do whatever you want with it. I just stuck it in cshome now with a very basic setup so I could test it and take it from there before I put it in a place where players could access it.

But it works!
Reply With Quote
  #3  
Old 07-13-2009, 04:29 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

Quote:
Originally Posted by Dibalamin View Post
How can you make it store a text string? Been thinking about a bot to do guilds.
Under EVENT_SAY you should be able to just do
Code:
$myString = $text;
That'll just store the current text since it would be overwritten whenever someone said something to the npc with the current text. A better approach would be to put it in an if block with a regex to check for a string like "Guildname: xxxxxx" then store the xxxxxx part with another regex.
Code:
if($text =~/<some regex to check guildname>/i)
{
$text =~/<regex to pull out the guildname>/;
$guildname = $text;
}
Again, no real experience using perl or regular expressions, so I'm not sure exactly how you'd do that. One way would be to store the initial say text in a temporary variable since performing the regex puts the output in the variable that you perform it on (I think, so $text =~ something modifies $text to be the output of the expression).

Kinda getting over my head with regular expressions and perl in this thread, I'm just waiting for someone who actually uses it regularly to come in and say "no, that's all wrong". :p

Also, not sure if it's good programming practice with perl, but you could declare the variable as a global variable (outside EVENT_SAY, like at the top of the script) so it can be accessed from other events.
Reply With Quote
  #4  
Old 07-13-2009, 05:52 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Yeah, I figure it is possible, but I'm not sure what the expression should be to store the variable, but after reading what you put I think just using a say and storing it should be sufficient, but then it will be slightly more difficult to give instructions on how to use it....

As you said, hopefully someone better at the ins and outs of perl will chime in =p
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #5  
Old 07-14-2009, 01:29 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

These should help as references:
Regular expression examples - Wikipedia, the free encyclopedia
Perl regular expressions for the common man

Here's the finished product:

Code:
#############
#Written By : cubber, regexp by AndMetal
#Quest Name: #summonitem proxy
#Quest Zone: Cshome
#Quest NPC: Krakskull
#################
sub EVENT_SAY {
	if($text=~/Hail/i) {
         quest::say("Hello there $name,  need some [items summoned]?");
	} elsif ($text=~/i seek item (\d{1,6})/i) {
		my $itemNum = $1;
		quest::emote("Krakskull begins to chant...");
		quest::summonitem($itemNum);      	
		quest::emote("The item you seek apears before your eyes!");
	}
}
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #6  
Old 07-14-2009, 08:09 AM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Thanks AndMetal for cleaning up the regex stuff.
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:44 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