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
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Thu Feb 12, 2009 7:09 am   

zMud trigger to cMud translation?
 
I'm having a bit of difficulty with this, because zMud isn't quite working as well with my
new computer as my old one, so naturally I was excited about cMud which runs smoothly
on it. I have this old zMud script written up, it's more of a series of complex triggers
really, and it doesn't seem to fire correctly when uploaded into cMud, I'm certain this
is because of some minor alteration in syntax that I'm having difficulty narrowing down,
I was hoping for some guidance from a helping hand.
the zMud script is as follows, and is meant to identify where tokens are (something shiny) in adjacent
rooms using a command that in the game scans them, then travel to said adjacent room (up to three away)
collect the item, and return to the spot of origin from whence the rooms were scanned. It takes into account
some serious variables when determining what will fire the trigger, and is going to be a pain to rewrite if
I can't figure out where to begin:

#CLASS {Dwarf} {enable}
#ALIAS scan {
#VAR dir {}
#VAR distance 0
#T+ scan
~scan
emote done
}
#VAR imps {31}
#TRIGGER {You eat Spice of the black, aquatic centipede.} {scan}
#TRIGGER {Sammy done} {eat spice}
#TRIGGER {You do not have that item.} {
c gate delica
vis
#10 buy 50*spice
c dark
eat spice
}
#TRIGGER {Your vision blurs and feels limited.} {c far}
#TRIGGER {Some unknown magic holds you here.} {
C portal zein
enter gate
}
#TRIGGER {A pile of coins.} {get all}
#TRIGGER {*pile*} {get all}
#CLASS 0
#CLASS {Dwarf|scan} {disable}
#TRIGGER {Nearby (%w):} {
#VAR dir %1
#VAR distance 1
#IF (@dir = West) {#VAR backtrack East}
#IF (@dir = Down) {#VAR backtrack Up}
#IF (@dir = Up) {#VAR backtrack Down}
#IF (@dir = South) {#VAR backtrack North}
#IF (@dir = North) {#VAR backtrack South}
#IF (@dir = East) {#VAR backtrack West}
}
#TRIGGER {Not Far (%w):} {
#VAR dir %1
#VAR distance 2
#IF (@dir = West) {#VAR backtrack East}
#IF (@dir = Down) {#VAR backtrack Up}
#IF (@dir = Up) {#VAR backtrack Down}
#IF (@dir = South) {#VAR backtrack North}
#IF (@dir = North) {#VAR backtrack South}
#IF (@dir = East) {#VAR backtrack West}
}
#TRIGGER {Far off (%w):} {
#VAR dir %1
#VAR distance 3
#IF (@dir = West) {#VAR backtrack East}
#IF (@dir = Down) {#VAR backtrack Up}
#IF (@dir = Up) {#VAR backtrack Down}
#IF (@dir = South) {#VAR backtrack North}
#IF (@dir = North) {#VAR backtrack South}
#IF (@dir = East) {#VAR backtrack West}
}
#TRIGGER {- Something Shiny} {
#IF (@distance = 0) {~get all}
#IF (@distance = 1) {
@dir
~get all
@backtrack
}
#IF (@distance = 2) {
@dir
@dir
~get all
@backtrack
@backtrack
}
#IF (@distance = 3) {
@dir
@dir
@dir
~get all
@backtrack
@backtrack
@backtrack
}
}
#TRIGGER {Right (%w):} {
#VAR dir %1
#VAR distance 0
}
#CLASS 0

Thoughts?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Thu Feb 12, 2009 8:50 am   
 
This would be much easier with some sample output from the game. From your triggers, I think your game does something like this:

Quote:
scan

You sense the following...

Far off west:
- some rubbish
- something shiny


But frankly, that's a complete guess, and I'm way more effective when I'm working with non-guesses.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 12, 2009 2:02 pm   
 
It would indeed be useful to have samples of the actual text.

I do see one bit of syntax that has changed between Zmud and Cmud. You can no longer start a command line with @ or %. Instead you would need a #call in front of it. Actually, for what you have, I would change, for instance, the "@dir;@dir;@dir" to "#3 #call @dir".

As an aside, the "#TRIGGER {*pile*} {get all}" can be simplified to "#TRIGGER {pile} {get all}", and "#TRIGGER {A pile of coins.} {get all}" is probably superfluous, since it also matches the other trigger.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Thu Feb 12, 2009 4:03 pm   
 
Rahab

*cough*
I wished to write the same about "start line with command", but have made a test. What can I say - CMUD still executes single @dir or @backtrace lines. CMUD does send, say, @dir verbatim from the command line, but expand it value from within a setting.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 12, 2009 5:38 pm   
 
Whoa, you're right. Embarassed I have a vague memory of Zugg deciding to put that capability back in. It's still true for %, but not for @ (in scripts) I guess. And in any case, I should have said to use #send instead of #call, in this situation.
Reply with quote
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Thu Feb 12, 2009 11:43 pm   
 
[quote="gamma_ray"]This would be much easier with some sample output from the game. From your triggers, I think your game does something like this:

Quote:
scan

You sense the following...

Far off west:
- some rubbish
- something shiny


But frankly, that's a complete guess, and I'm way more effective when I'm working with non-guesses.[/quote]

That's an amazing guess, because that's exactly what it is. or:

scan

You see the following...

Far off west:
- some rubbish
- a troll
- some more rubbish
- something shiny

or
scan

You see the following...

Not far South:
- a troll

Nearby West:
- rubbish
- rubbish
- something shiny


To put things into perspective, so the reason it's not firing is because I'm calling commands with @ instead of #call?
Reply with quote
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Thu Feb 12, 2009 11:49 pm   
 
To elaborate even further, when executed successfully in zMud this is what it looks like and how the trigger
responds:


Right Here:
- A medium-sized mutant
- A small mutant
-
- a large-sized mutant

Far off South:
- A small mutant
- A medium-sized mutant
- a large-sized mutant
- A medium-sized mutant
- Something Shiny
#3South
get all
#3North
- A medium-sized mutant
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Feb 13, 2009 5:13 pm   
 
You say "it doesn't seem to fire correctly when uploaded into cMud." What do you mean? I don't see any syntax problems in your code. There are several places where it could be greatly simplified, but I don't see any reason why it shouldn't work. What exactly isn't working?
Reply with quote
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Sat Feb 14, 2009 9:17 am   
 
Most specifically, it's firing "west get all" instead of "west" and then "Get all", I thought perhaps cMUD might have had a different syntax for separating multiple commands. It's firing all 3-7 of the trigger commands in one line, or one command.
West,
West
West
get all
in the script is returning
West West West Get all
with no carriage return between the commands, but it works just fine in zMud, not in cMud.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Sat Feb 14, 2009 1:08 pm   
 
You may want to see if this works. Try going through the script and removing the line breaks in the #IF statements. For example:

#IF (@distance = 2) {
@dir
@dir
~get all
@backtrack
@backtrack
}

just change it in the editor to be #IF (@distance=2) {@dir;@dir;~get all;@backtrack;@backtrack}

I've had the occasional issue where I've reformatted a script in the editor, and the inserted line breaks sometimes end up doing this.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Feb 14, 2009 3:06 pm   
 
Code:
<class name="scan" enabled="false" id="116">
  <trigger priority="1100" case="true" regex="true" id="110">
    <pattern>^Nearby (\w)\w+:$</pattern>
    <value>#path path %concat(".",%1)</value>
  </trigger>
  <trigger priority="1110" case="true" regex="true" id="111">
    <pattern>^Not far (\w)\w+:$</pattern>
    <value>#path path %concat(".","2",%1)</value>
  </trigger>
  <trigger priority="1120" case="true" regex="true" id="112">
    <pattern>^Far off (\w)\w+:$</pattern>
    <value>#path path %concat(".","3",%1)</value>
  </trigger>
  <path name="path" id="113"/>
  <trigger priority="1140" case="true" regex="true" id="114">
    <pattern>^Right here:$</pattern>
    <value>#path path %null</value>
  </trigger>
  <trigger priority="1150" case="true" regex="true" id="115">
    <pattern>^- Something Shiny$</pattern>
    <value>.path;get all;#retrace path</value>
  </trigger>
</class>


Based more or less on your way of doing it. You could pretty it up a lot if you wanted to teach it some logic (i.e. if there's something "nearby west" and "far off west" then I shouldn't go nearby, come back, and then go far off). But I have homework to do. :/
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Feb 14, 2009 9:47 pm   
 
I noticed you had posted this same question in the MUSHclient forum. You can use Lua in Cmud too and using Lua tables makes things a little easier. Plus you only need one trigger really.

For example:

Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="Scanning" copy="yes">
    <trigger priority="170" case="true" regex="true" copy="yes">
      <pattern>^(Right|Nearby|Not far|Far off) (\w+)\:$</pattern>
      <value>local line = zs.param(1)
scanning.dir = zs.param(2)
scanning.distance = scanning.distances[line]
scanning.backtrack = scanning.backtracks[scanning.dir]</value>
      <trigger case="true" regex="true" language="Lua">
        <pattern>^\- Something Shiny$</pattern>
        <value>if scanning.distance == 0 then
  send("get all")
else
  for i=1,scanning.distance do
    send(scanning.dir)
  end
  send("get all")
  for i=1,scanning.distance do
    send(scanning.backtrack)
  end
end</value>
      </trigger>
    </trigger>
    <event event="onConnect" priority="200" copy="yes">
      <value>scanning = {}
scanning.backtrack = nil
scanning.backtracks = {
  West = "East",
  Down = "Up",
  Up = "Down",
  South = "North",
  North = "South",
  East = "West",
  }
scanning.dir = nil
scanning.distance = 0
scanning.distances = {
  ["Far off"] = 3,
  ["Not far"] = 2,
  ["Nearby"] = 1,
  ["Right"] = 0,
  }</value>
    </event>
    <trigger type="Command Input" priority="210" regex="true" copy="yes">
      <pattern>^scan$</pattern>
      <value>scanning.dir = nil
scanning.distance = 0
send("scan")</value>
    </trigger>
  </class>
</cmud>
Reply with quote
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Mon Feb 16, 2009 12:56 am   
 
Problem solved! And how minor the problem was in the end.
semicolons no longer separate commands without a carriage return at the end of them. I rewrote the whole thing a number of different times just to find out that west;get all;east wasn't firing
west
get all
east

because in the trigger it needed to be
west;
get all;
east.

I feel stupid. Thanks for all your help everyone.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Feb 16, 2009 5:59 am   
 
Actually, if you have the carriage return, you don't need the semicolon - the idea of the semicolon is that it's supposed to let you separate commands without using a semicolon. I don't see this problem with a simple test:

#trig {test} {lol;hax;pwn}
#say test

So something else is going on.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Mjolnir07
Newbie


Joined: 12 Feb 2009
Posts: 6

PostPosted: Thu Feb 26, 2009 2:02 am   
 
This is true, while it corrected my trigger problem I did notice that other triggers programmed into the client function just fine with semi colons in place of carriage returns.
Oh well.
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