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 02-11-2013, 04:38 AM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default In game menu

I'm attempting to create an in game menu. The idea is not original to me (I saw Akkadius do it, and I think it is great).

Anyway, I've searched and can't find anyone that's posted code for it. I've attempted to do it myself. However, It is not working for me. Here is my code:

Code:
sub EVENT_SAY
{
	my $menuHelp = quest::saylink("Server Information");
	my $menuScribeSpells = quest::saylink("Scribe your spells");
	my $menuUnscribeSpells = quest::saylink("Unscribe your spells");
	
	if ($text=~/menu/i)
	{
		plugin::Whisper("What would you like to do? Would you like [$menuHelp]?");
		plugin::Whisper("Wold you like to [$menuScribeSpells]?");
		plugin::Whisper("Would you like to [$menuUnscribeSpells]?");		
	}
	
	if($text="Server Information")
	{
		Blah blah Lots of crap here..
		my $Yel = plugin::PWColor("Yellow");
		my $Blu = plugin::PWColor("Light Blue");
		my $Red = plugin::PWColor("Red");
		my $grn = plugin::PWColor("Forest Green");
		quest::popup("Welcome", 
		"$Yel $TextToCenter <br>
		$Yel $TextToCenter2 </c> <br>
		$Yel $TextToCenter3 </c> <br>
		$Yel $TextToCenter4 </c> <br>
		$Yel $TextToCenter5 </c> <br>
		$Yel $TextToCenter6 </c> <br>
		$Yel $TextToCenter7 </7> <br>
		$Yel $TextToCenter8 </7> <br>
		$Yel $TextToCenter9 </7> <br> <br>
		$Indent $globalload <br>
		$Indent $spellfile
		");
	}
}
It isn't finished, but I prefer to check my work as I go to find errors. I get no response when I say menu or Menu, etc. I put it in global_players.pl and also tried it in a zone player.pl.

I put the script on a NPC and it functioned correctly when I said menu. Maybe sub EVENT_SAY is not the correct event to use. Any suggestions? Thanks.
__________________
Disorder
Reply With Quote
  #2  
Old 02-11-2013, 06:15 AM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

Ok, I think I've figured it out.

pluggin::whisper must be just for npc's

I used $client->Message(315, ---------- and it worked.
__________________
Disorder
Reply With Quote
  #3  
Old 02-11-2013, 06:58 AM
liquest
"Special" Member
 
Join Date: Jul 2007
Posts: 373
Default

So its just edited to this here?

Code:
sub EVENT_SAY
{
	my $menuHelp = quest::saylink("Server Information");
	my $menuScribeSpells = quest::saylink("Scribe your spells");
	my $menuUnscribeSpells = quest::saylink("Unscribe your spells");
	
	if ($text=~/menu/i)
	{
		$client->Message(315, ("What would you like to do? Would you like [$menuHelp]?");
		$client->Message(315, ("Wold you like to [$menuScribeSpells]?");
		$client->Message(315, ("Would you like to [$menuUnscribeSpells]?");		
	}
	
	if($text="Server Information")
	{
		Blah blah Lots of crap here..
		my $Yel = plugin::PWColor("Yellow");
		my $Blu = plugin::PWColor("Light Blue");
		my $Red = plugin::PWColor("Red");
		my $grn = plugin::PWColor("Forest Green");
		quest::popup("Welcome", 
		"$Yel $TextToCenter <br>
		$Yel $TextToCenter2 </c> <br>
		$Yel $TextToCenter3 </c> <br>
		$Yel $TextToCenter4 </c> <br>
		$Yel $TextToCenter5 </c> <br>
		$Yel $TextToCenter6 </c> <br>
		$Yel $TextToCenter7 </7> <br>
		$Yel $TextToCenter8 </7> <br>
		$Yel $TextToCenter9 </7> <br> <br>
		$Indent $globalload <br>
		$Indent $spellfile
		");
	}
}
__________________
Also Knows as Tavish

Liquest Auctions, WTB AA's up to the current compatable clients PST with offer.

"A casual stroll through a lunatic asylum shows that faith does not prove anything." ~Fredrick Nietzsche

"Insanity: doing the same thing over and over again and expecting different results.." ~Albert Einstein
Reply With Quote
  #4  
Old 02-11-2013, 07:19 AM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

I changed to this but I am having troubles with unscribespells and untraindiscs.

Code:
  sub EVENT_SAY
{
	$menuHelp = quest::saylink("Server Information");
	$menuScribeSpells = quest::saylink("Scribe your spells");
	$menuUnscribeSpells = quest::saylink("Unscribe your spells");
	$menuUnscribeDiscs = quest::saylink("Unscribe your disciplines");
	$menuTrainDiscs = quest::saylink("Learn your disciplines");
	
	if ($text=~/menu/i)
	{
		$client->Message(315, "What would you like to do? Would you like [$menuHelp]?");
		$client->Message(315, "Wold you like to [$menuScribeSpells]?");
		$client->Message(315, "Would you like to [$menuUnscribeSpells]?");		
		$client->Message(315, "Would you like to [$menuTrainDiscs]?");
		$client->Message(315, "Would you like to [$menuUnscribeDiscs]?");		
	}
	
	elsif($text=~/Server Information/i)
	{
		Taken out for length
                my $Yel = plugin::PWColor("Yellow");
		my $Blu = plugin::PWColor("Light Blue");
		my $Red = plugin::PWColor("Red");
		my $grn = plugin::PWColor("Forest Green");
		quest::popup("Welcome", 
		"$Yel $TextToCenter <br>
		$Yel $TextToCenter2 </c> <br>
		$Yel $TextToCenter3 </c> <br>
		$Yel $TextToCenter4 </c> <br>
		$Yel $TextToCenter5 </c> <br>
		$Yel $TextToCenter6 </c> <br>
		$Yel $TextToCenter7 </7> <br>
		$Yel $TextToCenter8 </7> <br>
		$Yel $TextToCenter9 </7> <br> <br>
		$Indent $globalload <br>
		$Indent $spellfile
		");
	}
	
	elsif ($text=~/Scribe your spells/i)
	{
		quest::scribespells($ulevel);
	}
	
	elsif ($text=~/Unscribe your spells/i)
	{
		quest::unscribespells();
		
	}
	
	elsif ($text=~/Learn your disciplines/i)
	{
		quest::traindiscs($ulevel);
		
	}
	
	elsif ($text=~/Unscribe your disciplines/i)
	{
		quest::untraindiscs();		
		
	}
	
}

	
}
The untrain and unscribe refuse to work. Not sure what I am doing wrong.
__________________
Disorder
Reply With Quote
  #5  
Old 02-11-2013, 07:48 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,743
Default

Quote:
Originally Posted by Disorder View Post
The untrain and unscribe refuse to work. Not sure what I am doing wrong.
What client are you using? Did you zone or relog after you did it?
Reply With Quote
  #6  
Old 02-11-2013, 09:26 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Gonna guess that when you try to use unscribe spells, it scribes them again. This might be because "/Unscribe your spells/i" also contains "/Scribe your spells/i" when it searches for $text that contains the phrase and doesn't match case because you set "i" at the end. And because you are using elsif instead of just if, it matches the first one then stops. You might want to add a "^" at the beginning to make sure the line starts with what you want it to start with and not match both. Though, that doesn't explain why your disc one isn't working. Also, there isn't really a reason to use a bunch of elsifs like that, regulate ifs should be good enough as long as you set your matching correctly.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 02-11-2013, 01:35 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i'm going to have to disagree with your assertion about if/elsif, simply because it's good practice. getting into the habit of using only if statements without using other means of flow control will cause unexpected issues and will make things more difficult to troubleshoot. explicit is always better than implicit in these situations, and not allowing the script to continue looking for a match when you have the only one you need in a subroutine is a good thing.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #8  
Old 02-11-2013, 04:36 PM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

As far as the elsif/if statements, I'm learning everything from the forums, so I've been emulating what I see. I can't exactly say I know the benefits of one vs the other. Either way, Thanks for the information. I'll go look into it more now that I have time.

To clarify /text you want/ would accept randomtextText you wantRandomtext as long as it finds what it is looking for? and ^text you want/ would take only text you wantrandomtext? If that makes sense..
__________________
Disorder
Reply With Quote
  #9  
Old 02-11-2013, 04:57 PM
Disorder
Hill Giant
 
Join Date: Apr 2010
Location: USA
Posts: 133
Default

This was the fix:

Code:
sub EVENT_SAY
{
	$menuHelp = quest::saylink("Server Information");
	$menuScribeSpells = quest::saylink("Scribe your spells");
	$menuUnscribeSpells = quest::saylink("Unscribe your spells");
	$menuUnscribeDiscs = quest::saylink("Unscribe your disciplines");
	$menuTrainDiscs = quest::saylink("Learn your disciplines");
	
	if ($text=~/menu/i)
	{
		$client->Message(315, "What would you like to do? Would you like [$menuHelp]?");
		$client->Message(315, "Wold you like to [$menuScribeSpells]?");
		$client->Message(315, "Would you like to [$menuUnscribeSpells]?");		
		$client->Message(315, "Would you like to [$menuTrainDiscs]?");
		$client->Message(315, "Would you like to [$menuUnscribeDiscs]?");		
	}
	
	elsif($text=~/Server Information/i)
	{
		Removed for length
		my $Yel = plugin::PWColor("Yellow");
		my $Blu = plugin::PWColor("Light Blue");
		my $Red = plugin::PWColor("Red");
		my $grn = plugin::PWColor("Forest Green");
		quest::popup("Welcome", 
		"$Yel $TextToCenter <br>
		$Yel $TextToCenter2 </c> <br>
		$Yel $TextToCenter3 </c> <br>
		$Yel $TextToCenter4 </c> <br>
		$Yel $TextToCenter5 </c> <br>
		$Yel $TextToCenter6 </c> <br>
		$Yel $TextToCenter7 </7> <br>
		$Yel $TextToCenter8 </7> <br>
		$Yel $TextToCenter9 </7> <br> <br>
		$Indent $globalload <br>
		$Indent $spellfile
		");
	}
	
	elsif ($text=~/Scribe your spells/)
	{
		quest::scribespells($ulevel);
	}
	
	elsif ($text=~/Unscribe your spells/)
	{
		quest::unscribespells();
		
	}
	
	elsif ($text=~/Learn your disciplines/i)
	{
		quest::traindiscs($ulevel);
		
	}
	
	elsif ($text=~/Unscribe your disciplines/i)
	{
		quest::untraindiscs();		
		
	}
	
}
__________________
Disorder
Reply With Quote
  #10  
Old 02-11-2013, 06:49 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

regular expressions take a while to learn to use, but you can achieve a great deal of control in your statements when you have a firm grasp of them.

http://perldoc.perl.org/perlre.html
http://www.regular-expressions.info/
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
Reply


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 10:17 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3