|
Ghedemonas Novice
Joined: 15 Aug 2007 Posts: 39
|
Posted: Sat Jan 03, 2009 12:57 am
Automapper Comparison |
Hi,
I'm trying to make a script that compares if the exits in the current room have been changed and to inform me which changes have been made. It's very rough and basic atm ...
I store my roomexits in the variable @Mapper.Roomexits.
Unfortunatelly I encountered several problems and I'd appreciate a helping hand.
Thanks in advance
Ghedemonas
<alias name="compare" id="5046">
<value>#noop This shows the exits currently saved by my Autmapper - it lacks non-standard exits and sort of the variable does not work
#var Mapper.Compare_Savedexits %roomexit
#var Mapper.Compare_Savedexits %replace( @Mapper.Compare_Savedexits, "|", ",")
#var Mapper.Compare_Savedexits %replace( @Mapper.Compare_Savedexits, "h", "nw")
#var Mapper.Compare_Savedexits %replace( @Mapper.Compare_Savedexits, "j", "ne")
#var Mapper.Compare_Savedexits %replace( @Mapper.Compare_Savedexits, "k", "sw")
#var Mapper.Compare_Savedexits %replace( @Mapper.Compare_Savedexits, "l", "se")
#call %sort(@Mapper.Compare_Savedexits)
#show Saved Exits: @Mapper.Compare_Savedexits
#noop This shows the exits captured by my #tag exit-trigger - sort of the variable does not work
#var Mapper.Compare_Roomexits @Mapper.Roomexits
#call %sort(@Mapper.Compare_Roomexits)
#show Mapper.Compare_Roomexits: @Mapper.Compare_Roomexits
#noop Comparison of the 2 strings - what's lacking is a way to show which exits are missing on one or the other variable
#if (@Mapper.Compare_Roomexits=@Mapper.Compare_Savedexits)
{#show Map matches}
{#show map does not match: The exits x, y and z seem to have been added OR The exits x,y and z seem to have been removed}</value>
</alias>
edit 1: fixed some minor errors in script |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Sat Jan 03, 2009 10:24 am |
If you're not using those variables anywhere else (the Compare_Savedexits and Compare_Roomexits), you probably want to make them local variables, it'll just be a little nicer. Also, you're trying to sort a comma separated string, and %sort only works on pipe separated strings (I'm guessing your exits from your trigger are coming in a comma separated list)--it would be way better to replace the commas in your trigger list with pipes instead of replacing the pipes in the saved list with commas.
Code: |
$savedexits = %roomexit()
$savedexits = %replace($savedexits, "h", "nw")
$savedexits = %replace($savedexits, "j", "ne")
$savedexits = %replace($savedexits, "k", "sw")
$savedexits = %replace($savedexits, "l", "se")
$roomexits = %replace(@mapper.roomexits, ",", "|")
#for ($savedexits) {#if (!%ismember(%i,$roomexits)) {#show {Exit not found: %i}}}
#for ($roomexits) {#if (!%ismember(%i,$savedexits)) {#show {New exit: %i}}} |
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Jan 03, 2009 9:13 pm |
Hrm, I guess I will skip digging stuff for this out of my Toolbox package. This will just assume the standard #DIRECTION settings like you have. Also without actual mud output I will probably overwrite this whole thing instead of making it just handle what you need.
Code: |
#CLASS DirCompare
#VAR DirConversions ""
#ADDKEY DirConversions {n="n|north"|e="e|east"|s="s|south"|w="w|west"|h="nw|northwest"|j="ne|northeast"|k="sw|southwest"|l="se|southeast"|u="u|up"|d="d|down"}
#ALIAS CompareExits($ExitList) {$CurRoom=%subregex(%roomexit,%concat("(?<=^|\|)(",%dbkeys(@DirConversions),")(?=\z|\|)"),"%db(@DirConversions,\1)")
$ExitList=%subregex($ExitList,%concat("(?<=^|\|)(",%dbkeys(@DirConversions),")(?=\z|\|)"),"%item(%db\(@DirConversions,\1),1)")
$ExitList=%subregex($ExitList,%concat("(?:^|\|)(",$CurRoom,")(?=\z|\|)"),"(?(^)Found (?LIST:1:$) -- New Exits )")
#SHOW $ExitList}
#CLASS 0 |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Ghedemonas Novice
Joined: 15 Aug 2007 Posts: 39
|
Posted: Sun Jan 04, 2009 12:31 am |
Gamma Ray's script works nicely, it just spoils the non-standards (replacing letters as requested for standard exits) .... I'll Try Vijilante's script tomorrow ...
I'll post some outputs tomorrow - cmud just broke down completely 8)
Thanks for your help! |
|
|
|
Ghedemonas Novice
Joined: 15 Aug 2007 Posts: 39
|
Posted: Sun Jan 04, 2009 10:22 pm |
Here are some examples:
Dark Cave (Abyssal) [d]
Joining Room [n,ne,se,s,w,nw,u]
Small Cavern [se,crack,in]
and so on ....
- Several non-standard exits are hidden and son't appear in the regular name
- It would be great to get the non-standard exits into variables (e.g. local ones Nonstandart 1, 2 3 etc) so that they can be used with other scripts (e.g. compass) |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Mon Jan 05, 2009 1:38 pm |
Code: |
$savedexits = %replaceitem("nw",%ismember("h",%roomexit()),%roomexit())
$savedexits = %replaceitem("ne",%ismember("j",$savedexits),$savedexits)
$savedexits = %replaceitem("nw",%ismember("k",$savedexits),$savedexits)
$savedexits = %replaceitem("se",%ismember("l",$savedexits),$savedexits) |
Try that for the first block in my previous post. For me [3.03a] non-standard exits are showing up in %roomexit(), so you can get them from that. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Jan 05, 2009 11:38 pm |
Nonstandard exits will show up in %roomexit. If you try my script it prpoerly handles nonstandard exits, and can easily be adjusted to produce sperate lists for those that were found and those that are new.
The hidden exits I could be considered by removing the found exits from the %roomexit list. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Ghedemonas Novice
Joined: 15 Aug 2007 Posts: 39
|
Posted: Tue Jan 06, 2009 6:43 pm |
Thanks alot Gamma_ray and Vijilante!
|
|
|
|
|
|
|
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
|
|