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 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. |
Ok, I think I've figured it out.
pluggin::whisper must be just for npc's I used $client->Message(315, ---------- and it worked. :) |
So its just edited to this here?
Code:
sub EVENT_SAY |
I changed to this but I am having troubles with unscribespells and untraindiscs.
Code:
sub EVENT_SAY |
Quote:
|
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.
|
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.
|
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.. |
This was the fix:
Code:
sub EVENT_SAY |
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/ |
All times are GMT -4. The time now is 01:30 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.