Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
DeathDealer
Adept


Joined: 20 Jul 2004
Posts: 268

PostPosted: Wed Apr 20, 2005 5:22 pm   

#ONINPUT & #IF *SOLVED*
 
Modifying an existing spellup code that I have to be more functional.
When you level and gain a new spell for a spellup you have to add in the spell to the spellup list via something like 5 clicks on a prompt type thing.
I want to get rid of that.
I had every spell in an alias working with #if's to see if you are a certain lvl and are a certain class it would cast. Worked great by itself, but not with the existing spellup cause it uses a mud-side out put of spells you have on you currently for example:
Spell: call upon faith for 21 hours

and in the var it's stored as call upon faith
But my alias was calluponfaith and i couldnt figure out how to get the spaces outta there for the casting.

#ALIAS {calluponfaith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'}}

Now, if you have paladin in your @current_classes and are lvl 30 or under (depending also on your tiers which are -10 levels for each tier) it will cast when you type calluponfaith. which is correct. If you go in and change paladin in the alias to a class that you DON'T have listed then it won't cast which is correct.

Atreides_096 gave me an idea with the #ONINPUT command to work with the spaced vars. And I came up with this:

#ONINPUT {^call upon faith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'}}

And it works PERFECT. until you change the class from Paladin to something else. then it sending it as a raw command which is NOT what the #if is all about.

With Paladin typing call upon faith results in:
cast '156' <--Correct

With change to Mage typing call upon faith results in:
call upon faith
Your warhorse will not enter here!
obviously if the #if fails it thinks that I want the actually command sent to the mud.

NOTE: the same problem occurs with a change in the level. Rather than 30 make it lvl 300 (which is impossible because the mud has only 201 levels) and it send the raw command.

How, if possible, can i get it to not bypass the #if? Cause I am working with a list of some 80+ spells that in my test run sent every single one to the mud. The ones that I CAN use were sent correctly, while the ones that I CAN'T use because I am not that class or level are being sent directly to the mud.

(i know so much damned background for a simple how do i get this to work)
_________________


Last edited by DeathDealer on Thu Apr 21, 2005 6:06 pm; edited 1 time in total
Reply with quote
DeathDealer
Adept


Joined: 20 Jul 2004
Posts: 268

PostPosted: Wed Apr 20, 2005 5:49 pm   
 
bleh, think i just found out from this post: http://forums.zuggsoft.com/phpbb/viewtopic.php?t=20006&highlight=oninput
Quote:
Well the #oninput help file is lovely :P

#ONINPUT {^(%w) t$} {#GAG;#IF (@target != %null) {%1 @target} {#NOOP}}
From Nexela
My question is, does it prevent the WRONG command from being SENT or is it just gagging the error?


EDIT: Well, it don't even work.
1) it don't even cast the spell for some reason
2) it seems to block the messages that follow it so u can't tell if it worked or not. But i knew it didnt cast cause when I tried to disrupt it it said i wasnt affected by that spell.

So the #gag is not what I am looking for.
_________________
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Wed Apr 20, 2005 10:01 pm   
 
Why not just add a if-not-true to the if statement? *untested* (I'm not at my home comp)

#ONINPUT {^call upon faith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'} {#SAY You cannot use that spell.}}
_________________
Everyone is entitled to their beliefs - until they die. Then only the truth matters.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Thu Apr 21, 2005 12:52 am   
 
Just tested and it works perfectly.

#ONINPUT {^call upon faith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'} {#GAG}}

#ONINPUT has an implcit substitution for the first command sent to the mud from the contained script. Anything not sent to the mud does not effect this with the exception of #SUB. After the first sub then subsequent use of #SUB is undefined, and I don't know if anyone ever tested it during the beta cycles that introduced #ONINPUT.

The use of #GAG will clear all pending output from the script. So for example:
#ONINPUT {^abc} {def;ghi;jkl;mno;pqr;#GAG}
outputs nothing.
Oddly #ONINPUT {^abc} {def;ghi;jkl;mno;pqr;#GAG;stu} also outputs nothing. I do not believe this is the way Zugg meant it to work. So will report it as a bug.

If you require further arguments such as targetting you will have to explicitly include them in the resultant output.

Aarlot, your suggestion of #SAY would still sent the original command to the mud.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
DeathDealer
Adept


Joined: 20 Jul 2004
Posts: 268

PostPosted: Thu Apr 21, 2005 1:58 pm   
 
Aarlot wrote:
Why not just add a if-not-true to the if statement? *untested* (I'm not at my home comp)

#ONINPUT {^call upon faith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'} {#SAY You cannot use that spell.}}


I'd rather not have ANY output. except for the successful casting :-)
The point of it all is that if i can use the spell it will cast. if i can't, it won't. Don't need to know that I can't. :)
_________________
Reply with quote
DeathDealer
Adept


Joined: 20 Jul 2004
Posts: 268

PostPosted: Thu Apr 21, 2005 2:10 pm   
 
Vijilante wrote:
#ONINPUT {^call upon faith} {#IF (%ismember( Paladin, @current_classes) AND @current_level >= %eval( 30-(@tier*10))) {cast '156'} {#GAG}}


Just to make a quick confirm. the #gag will NOT SEND ANYTHING to the mud if it is not successful?
I'm used to #GAG not showing anything on screen but something still going on mud-side. Just don't want to spam in 40+ errors when i am spelling up with the 20+ spells i have.

EDIT: Checked it with someone in the room with me. Before the gag it tried to use the skill call warhorse, which showed in the room when someone did it. So I did my usual change of class and lvl and the person in the room didn't see a failed or successful attempt at the call warhorse.

Thanks tons Vij!
_________________
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net