|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Thu Apr 22, 2004 8:47 pm
Squinting in all directions |
I have had mixed amount of luck with creating a way to squint in every direction when I use a particular alias. Here's what I have so far:
#ALIAS qs {squintlist="";#t+ "exitcheck1";#t+ "exitcheck2";exits;#alarm +0.4 {#STATE "exitcheck2" 0;#t- "exitcheck1";#t- "exitcheck2";#forall @squintlist {squint %i}}}
#TRIGGER "exitcheck1" {^You see exits leading(*)} {squintcon="%1";#if (@squintcon =~ "%snorth") {#additem squintlist north};#if (@squintcon =~ "%ssouth") {#additem squintlist south};#if (@squintcon =~ "%seast") {#additem squintlist east};#if (@squintcon =~ "%swest") {#additem squintlist west};#if (@squintcon =~ "%snorthwest") {#additem squintlist northwest};#if (@squintcon =~ "%snortheast") {#additem squintlist northeast};#if (@squintcon =~ "%ssoutheast") {#additem squintlist southeast};#if (@squintcon =~ "%ssouthwest") {#additem squintlist southwest};#if (@squintcon =~ "%sin") {#additem squintlist in};#if (@squintcon =~ "%sout") {#additem squintlist out};#if (@squintcon =~ "%sdown") {#additem squintlist down};#if (@squintcon =~ "%sup") {#additem squintlist up}} "" {disable}
#TRIGGER "exitcheck2" {^You see exits leading} {} "" {disable}
#COND {(*)} {squintcon=%concat("%1",@squintcon);#if (%pos("north",@squintcon)) {#additem squintlist north};#if (%pos("south",@squintcon)) {#additem squintlist south};#if (%pos("east",@squintcon)) {#additem squintlist east};#if (%pos("west",@squintcon)) {#additem squintlist west};#if (%pos("northwest",@squintcon)) {#additem squintlist northwest};#if (%pos("northeast",@squintcon)) {#additem squintlist northeast};#if (%pos("southeast",@squintcon)) {#additem squintlist southeast};#if (%pos("southwest",@squintcon)) {#additem squintlist southwest};#if (%pos("in",@squintcon)) {#additem squintlist in};#if (%pos("out",@squintcon)) {#additem squintlist out};#if (%pos("down",@squintcon)) {#additem squintlist down};#if (%pos("up",@squintcon)) {#additem squintlist up}}} {within|param=1|disable}
This works, but only in some situations. Here is an output from the MUD after using the 'exits' query:
You see exits leading north (open door), northeast, east, southeast, south, southwest,
west, and northwest (closed door).
As you can see, places with numerous exits wrap to the next line. The problem I am having, is that this script only works when there aren't directions with overlapping names (north, northeast, northwest all in one exits query, for instance).
I have tried using %replace(), %concat(), etc. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Apr 22, 2004 10:44 pm |
It seems simpler, and probably faster, to just modify the strings directly with a series of nested replaces.
#TR {You see exits leading (*)} {#VAR squintlist {%replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", ""), " ", "")}}
#COND {({north|east|south|west|and}*).} {#VAR squintlist {@{squintlist}%replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", ""), " ", "")}} {Within|Param=1} |
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Fri Apr 23, 2004 5:07 am |
As usual your coding expertise is excellent, LightBulb. All that was required was a slight modification on the third parameter of the first %replace() to get it sorted into a stringlist:
#TR {You see exits leading (*)} {#VAR squintlist {%replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", ""), " ", "|")}}
#COND {({north|east|south|west|and}*).} {#VAR squintlist {@{squintlist}%replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", ""), " ", "|")}}
Thank you. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Apr 23, 2004 5:40 am |
I don't recommend that change. I already replaced commas with the |. If you also replace spaces with the |, then half your list will be empty strings.
|
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Fri Apr 23, 2004 5:20 pm |
Without the change I made, the variable is concatenated together, not in stringlist form. Such as:
northeastsouthwest
etc. I didn't have much time last night to look at the solution, when I get home today I will look at it more in depth as well to find out which %replace() is not working correctly if you don't get to it first.
Edit: I don't know why, but your original solution is working correctly for me now. As I said before it was concatenating it, very odd. Thank you again LightBulb. |
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Sat Apr 24, 2004 2:57 am |
I found out where I had the problem earlier. On output like this:
You see exits leading west and east.
It becomes concatenated. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Apr 24, 2004 3:34 pm |
Ah, another level of complexity.
#TR {You see exits leading (*)} {#VAR squintlist {%replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ", and", ","), ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", "|"), " ", "")}}
#COND {({north|east|south|west|and}*).} {#VAR squintlist {@{squintlist}%replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( "%1", ", and", ","), ",", "|"), "(open", ""), "(closed", ""), "door)", ""), ".", ""), " and", "|"), " ", "")}} {Within|Param=1} |
|
|
|
user0101 Apprentice
Joined: 01 Aug 2003 Posts: 100 Location: USA
|
Posted: Sat Apr 24, 2004 6:52 pm |
It works perfectly, thank you.
|
|
|
|
|
|
|
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
|
|