|  |  | 
 
  |  |  |  |  
  |  |  |  |  
  |  |  |  |  
  |  |  |  |  
  |  | 
	
		
   
   
      | Quests::Q&A This is the quest support section |  
	
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				02-11-2013, 04:38 AM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Apr 2010 Location: USA 
						Posts: 133
					      |  |  
	| 
				 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
 |  
 
  |  |  |  |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 06:15 AM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Apr 2010 Location: USA 
						Posts: 133
					      |  |  
	| 
 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
 |  
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				02-11-2013, 06:58 AM
			
			
			
		 |  
	| 
		
			
			| "Special" Member |  | 
					Join Date: Jul 2007 
						Posts: 373
					      |  |  
	| 
				  
 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
 |  
 
  |  |  |  |  
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				02-11-2013, 07:19 AM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Apr 2010 Location: USA 
						Posts: 133
					      |  |  
	| 
				  
 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
 |  
 
  |  |  |  |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 07:48 AM
			
			
			
		 |  
	| 
		
			
			| Demi-God |  | 
					Join Date: Aug 2010 
						Posts: 1,742
					      |  |  
	| 
 
	Quote: 
	
		| 
					Originally Posted by Disorder  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? |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 09:26 AM
			
			
			
		 |  
	| 
		
			|  | Developer |  | 
					Join Date: Aug 2006 Location: USA 
						Posts: 5,946
					      |  |  
	| 
 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. |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 01:35 PM
			
			
			
		 |  
	| 
		
			|  | Dragon |  | 
					Join Date: Dec 2009 
						Posts: 719
					      |  |  
	| 
 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; |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 04:36 PM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Apr 2010 Location: USA 
						Posts: 133
					      |  |  
	| 
 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
 |  
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				02-11-2013, 04:57 PM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Apr 2010 Location: USA 
						Posts: 133
					      |  |  
	| 
				  
 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
 |  
 
  |  |  |  |  
	
		
	
	
	| 
			
			 
			
				02-11-2013, 06:49 PM
			
			
			
		 |  
	| 
		
			|  | Dragon |  | 
					Join Date: Dec 2009 
						Posts: 719
					      |  |  
	| 
 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; |  
	
		
	
	
	
	
	| 
	|  Posting Rules |  
	| 
		
		You may not post new threads You may not post replies You may not post attachments You may not edit your posts 
 HTML code is Off 
 |  |  |  All times are GMT -4. The time now is 02:36 PM.
 
 |  |  
    |  |  |  |  
    |  |  |  |  
     |  |  |  |  
 |  |