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
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Tue Dec 28, 2010 6:28 am   

can't get a match
 
You notice exits north, and down (an open door). <----- line from the mud

downdoor
#delitem roomexits "down (an open door)."
#additem roomexits down


#if %ismember( "down (an open door).", @roomexits) {downdoor}

#show @roomexits
north| down (an open door).

if I manually try to use the alias DOWNDOOR it doesn't remove the (an open door) part like its suppose to.
i just want down in the list not "down (an open door)."
what am I doing wrong Question
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Tue Dec 28, 2010 1:22 pm   
 
the problem is your assumption that the mapper creates a variable called @roomexits, it doesn't

you might be able to finagle something with the %replace and %roomexit functions though

#ALIAS fixExits {
$exits=%replace(%roomexit, " (an open door)")
#CALL %roomexit(,$exits)
}

This is untested.
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Dec 28, 2010 1:55 pm   
 
Where are you trying to replace this "(an open door)"? That phrase should not be showing up in the mapper, unless you have used #TAG to put that into the room exits list. The autoconfiguration of the mapper should allow it to detect "down" as an exit name, and ignore "(an open door)". In other words, you should not need to worry about this for the mapper. Please explain exactly what you are trying to do, and why.
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Tue Dec 28, 2010 8:37 pm   
 
sorry I should have said that this isnt used with the mapper.
All Im doing is trying to stick the room exits into a list (minus the open door stuff)
so that I can run out in a pinch or push someone out of a room without actually needing
to manually figure out which way is acceptable.
I just hit my push alias and it automatically pushes my opponent in an acceptable direction.
So when I enter a room the trigger picks up the exits and sticks them into a list called roomexits.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Dec 29, 2010 12:22 am   
 
In that case, you should post the actual trigger. Please put it inside code tags.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Wed Dec 29, 2010 2:50 am   
 
my %replace should work, just use your variable instead of %roomexit

roomexits=%replace(@roomexits, " (an open door)")
_________________
Discord: Shalimarwildcat
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Dec 29, 2010 4:26 am   
 
That works thank you.


Very Happy
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Dec 29, 2010 5:14 am   
 
You notice exits north, east, south, southwest (a closed door), and west.

RoomExits = %replace( %1, "and", "," " ")
RoomExits = %replace( @RoomExits, ", ", "|")
RoomExits = %replace( @RoomExits, " , ", "|")
#delitem roomexits
roomexits=%replace(@roomexits, " (an open door).")
roomexits=%replace(@roomexits, " (a closed door).")

It would be very helpful if I could just remove the (closed door) exits from the list altogether.
Also the last direction in the list contains a period, in this example it would be (west.), how do I remove the period?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Dec 29, 2010 1:21 pm   
 
I'm not sure why you have the #delitem in there.
The easiest way to avoid the period at the end is to drop it right in the trigger pattern. Use a pattern of:
Code:

You notice exits (*).

And a trigger value of:
Code:

RoomExits = %replace(%1,", and ","|")
RoomExits = %replace(@RoomExits,", ","|")
RoomExits = %replace(@RoomExits," (an open door)")
#forall @roomexits {
  #if (%ends(@RoomExits," (a closed door)") {#delitem RoomExits %i}
}
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Dec 29, 2010 5:28 pm   
 
i added the:
#forall @roomexits {
#if (%ends(@RoomExits," (a closed door)") {#delitem RoomExits %i}
}

it still doesnt remove the closed doors
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Dec 29, 2010 7:03 pm   
 
Ack...my mistake. It should be:
Code:

#forall @roomexits {
  #if (%ends(%i," (a closed door)") {#delitem RoomExits %i}
}
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Dec 29, 2010 10:46 pm   
 
groovy! works now.
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Jan 29, 2014 5:17 am   
 
Example 1:
Dawn has lit the sky with her streamers of rosy red. You notice exits northeast (a closed door), east (a closed door), southeast (a closed door), south (a closed door), west (a closed door),
and northwest.

Example 2:
Dawn has lit the sky with her streamers of rosy red. You notice exits northeast (a closed door), east (a closed door), southeast (a closed door), south (a closed door), west (a closed door), and northwest.

still using this old code. having a couple problems with word wrap changing depending on what time of day it is. causes pattern matching problems, quite annoying. both of the examples above are likely to cut off the northwest direction. please help.

also is there an easy way to get just the direction in the list in the case of an open door?
it would be nice to keep southeast in place of southeast(an open door), for example. I tried using something similar to:
#forall @roomexits {#if (%ends(%i," (a closed door)")) {#exec %replaceitem(@RoomExits %i}}, but it turned out a disaster. please advise.
thank you.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jan 29, 2014 5:59 pm   
 
1)one trigger with two states
2)one variable to contain your exits data
3)one function to process your exits data (better to have all this code in one place than to write it three times)

Code:
#trigger "tRoomExits" {You notice exits (*)$} {
  #if (%ends(%1,".")) {
    //end-of-line detected
    Roomexits = @FixExits(%1)
  } {
    Roomexits = %1
  }
}
#condition {^(*)$} {
  //this is the second line of exits
  Roomexits = @RoomExits%1
  Roomexits = @FixExits(%1)
} {withinlines|param=1}

#variable Roomexits ""

#function FixExits($exits) {
  $exits = %remove(".",$exits)
  $exits = %replace($exits," and "," ")
  $exits = %replace($exits,", ","|")
  #loop 1,%numitems($exits) {
    #switch (%match(%item($exits,%i),"(%w) ~(an open (%w)~)",$dir,$door)) {
        $exits = %replaceitem($dir,%i,$exits)
      }
      (%match(%item($exits,%i),"(%w) ~(a closed (%w)~)",$dir,$door)) {
        //for changing an exit with a closed door
      }
  }
}
_________________
EDIT: I didn't like my old signature
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Wed Jan 29, 2014 7:49 pm   
 
wow that looks awesome, and im not going to pretend to know how to debug this (i dont know where to start)
these are the first two errors i got when i added the code:
ERROR: Syntax error in Function: FixExits : illegal token: (%match(%item($exits,%i),"(%w) ~(a closed (%w)~)",$dir,$door)) {
ERROR: Trigger "^(*)$" fired but did not compile
after the first time this is what it showed:
ERROR: Syntax error in Function: FixExits : illegal token: s = @RoomExits%1
ERROR: Trigger "^(*)$" fired but did not compile
I made sure to disable/delete any old code I had on the matter.
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Thu Jan 30, 2014 3:47 am   
 
ok the function fixexits was only missing a space it seems, but the second state of the trigger is still giving the same error, ive looked for basic spacing and typo type problems and have got nowhere.
ill keep looking, does anyone else see the problem, im using windows 8 and Cmud pro 3.34
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Jan 30, 2014 11:38 pm   
 
I just checked syntax in my own copy of CMud (win7, 3.34pro), and no problems there. Not sure about anything win8 related, so I'm guessing you probably just copied a little extra to the clipboard. Copy everything in the code box I gave, click on the command line, press CTRL-V, then press ENTER. Those three settings will be created at the root level of your main window, and you can move them to some other class if you wish.
_________________
EDIT: I didn't like my old signature
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