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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Sat May 01, 2010 3:54 am   

Help:Prefixing movement commands with "sneak"
 
Hi, I am in DragonRealms. I came up with this altered movement package:
Code:
<module name="DragonRealms Directions" global="true">
  <uid>{6DB1B67F-DB4A-49F7-B900-D569ADB7C34E}</uid>
  <class name="Directions" initenable="true" setdefault="true" id="1">
    <notes>Default direction settings (cardinal directions)</notes>
    <dir name="n" reverse="s" dir="n" id="2">n|north|sneak n|sneak north</dir>
    <dir name="s" reverse="n" dir="s" id="3">s|south|sneak s|sneak south</dir>
    <dir name="w" reverse="e" dir="w" id="4">w|west|sneak w|sneak west</dir>
    <dir name="e" reverse="w" dir="e" id="5">e|east|sneak e|sneak east</dir>
    <dir name="u" reverse="d" dir="u" id="6">u|up|sneak u|sneak up</dir>
    <dir name="d" reverse="u" dir="d" id="7">d|down|sneak d| sneak down</dir>
  </class>
  <class name="DirectionsDiag" initenable="true" setdefault="true" id="8">
    <notes>Default direction settings (diagonal directions)</notes>
    <dir name="h" reverse="l" dir="nw" id="9">nw|northwest|sneak nw|sneak northwest</dir>
    <dir name="j" reverse="k" dir="ne" id="10">ne|northeast|sneak ne|sneak northeast</dir>
    <dir name="k" reverse="j" dir="sw" id="11">sw|southwest|sneak sw|sneak southwest</dir>
    <dir name="l" reverse="h" dir="se" id="12">se|southeast|sneak se| sneak southeast</dir>
  </class>
  <trigger priority="9360" id="20">
    <pattern>You sneak *...</pattern>
    <value>#OK</value>
  </trigger>
  <trigger priority="210" id="21">
    <pattern>You melt into the background</pattern>
    <value>IsHidden = 1</value>
  </trigger>
  <var name="IsHidden" usedef="true" id="22">
    <value>1</value>
    <default>0</default>
  </var>
  <trigger priority="240" id="24">
    <pattern>You come out of hiding</pattern>
    <value>IsHidden = 0</value>
  </trigger>
</module>


Problem 1:

Which will update the mapper when I do sneak a valid direction, except for when I do something like "sneak trail" which would normally be "go trail" anyone know a way to make the system recognize the sneak when the location is not a normal direction?

Problem 2:

I tried to create a series of triggers that will detect when I am hidden, making IsHidden positive, and when it is positive if it sees a direction input like "n" for north it will stop the command from the command line and output "sneak north" instead.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger type="Command Input" priority="230">
    <pattern>(d)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak d}</value>
  </trigger>
  <trigger type="Command Input" priority="230">
    <pattern>(e)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak e}</value>
  </trigger>
  <trigger type="Command Input" priority="232">
    <pattern>(n)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak n}</value>
  </trigger>
  <trigger type="Command Input" priority="231">
    <pattern>(ne)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger type="Command Input" priority="230">
    <pattern>^(d)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak d}</value>
  </trigger>
  <trigger type="Command Input" priority="230">
    <pattern>^(e)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak e}</value>
  </trigger>
  <trigger type="Command Input" priority="232">
    <pattern>^(n)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak n}</value>
  </trigger>
  <trigger type="Command Input" priority="231">
    <pattern>^(ne)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak ne}</value>
  </trigger>
  <trigger type="Command Input" priority="234">
    <pattern>^(nw)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak nw}</value>
  </trigger>
  <trigger type="Command Input" priority="230">
    <pattern>^(o)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak o}</value>
  </trigger>
  <trigger type="Command Input" priority="234">
    <pattern>^(s)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak s}</value>
  </trigger>
  <trigger type="Command Input" priority="235">
    <pattern>^(se)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak se}</value>
  </trigger>
  <trigger type="Command Input" priority="236">
    <pattern>^(sw)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak sw}</value>
  </trigger>
  <trigger type="Command Input" priority="230">
    <pattern>^(u)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak u}</value>
  </trigger>
  <trigger type="Command Input" priority="237">
    <pattern>^(w)</pattern>
    <value>#GAG 0
#IF (@IsHidden) {#EXEC sneak w}</value>
  </trigger>
</cmud>


It worked fine for the first direction, when it was the only trigger, but when I got the rest in all directions ended up outputting "sneak s" and I know why.
Quote:
| DragonRe |Command Input: ^(n) : (%1="n")
0.0013 | c DragonRe |exec : Command Input "^(n)" : #GAG 0#IF (@IsHidden) {#EXEC sneak n}
0.0003 | g DragonRe |-> Line 999 gagged
0.0006 | c DragonRe |exec : sneak n
0.0003 | f DragonRe |Command Input: ^(s) : (%1="s")
0.0011 | c DragonRe |exec : Command Input "^(s)" : #GAG 0#IF (@IsHidden) {#EXEC sneak s}
0.0002 | g DragonRe |-> Line 998 gagged
0.0006 | c DragonRe |exec : sneak s
0.0126 | a DragonRe |sneak s
0.0012 | j DragonRe >sneak s
0.2484 | a DragonRe |You can't sneak in that direction.
0.0066 | a DragonRe ]>

It always processes the ^(s) trigger because the line beings with "sneak *". Any ideas on a work around? Thanks
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat May 01, 2010 5:03 am   
 
#oninput {^({go *|n|e|w|s|u|d|nw|ne|se|sw})$} {
$command = %1
#noinput
#switch (@IsHidden) {$command = %concat("sneak ",%remove("go ",$command))}
(@IsSomethingElse) {}
#send $command
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Ambelghan
Novice


Joined: 04 Apr 2010
Posts: 49

PostPosted: Sat May 01, 2010 10:56 am   
 
Thank you, MattLofton, I had to make some adjustments to your script as it produced an infinite loop, I know have:
Code:
#oninput ^({go *|n|e|w|s|u|d|nw|ne|se|sw|o})$
{
#IF (@IsHidden)
{
  #IF (%begins(%1,"sneak"))
  {}
  {
    #NOINPUT
    #SEND %concat("sneak ",%remove("go ",%1))
  } 
}
}


It works beautifully, I can even use the auto mapper to sneak everywhere.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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