|
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Wed Oct 20, 2010 3:28 am
[3.31] [SOLVED] Help debug my script |
I have this alias, it adds a portal to the mapper and tells the mapper how to use it, the port alias works as needed if the db is correct.
the addport alias used to work.. here is the alias
Code: |
<alias name="addport" id="129">
<value><![CDATA[#if (!%len( $Bag))
{
#if (%len( $Portal)) {
addport $Keyword $Portal %db(@PortalData,"Default Bag")
} {
#if (%len( $Keyword)) {
addport %replace(%replace(%zoneName( )," ",""),"'","") $Keyword %db(@PortalData, "Default Bag")
} {
#say @ansiPrefix("Portal")%ansi(11)"AddPort <Keyword> "%char(34)"<Portal Names>"%char(34)" "%char(34)"<#.Bag Names>"%char(34)" [Level] [Chaos Portal]~(244173~)is your portalbag"
}
}
} {
#addkey Portals {$Keyword} {$Portal|%if(%pos(.,$Bag),%left($Bag,%pos(.,$Bag)-1),1)|%char(34)%if(%pos(.,$Bag),%right($Bag,%pos(.,$Bag)),$Bag)%char(34)|%if(%len( $Level),$Level,1)|%if(%len($Chaos),$Chaos,0)|1|%roomkey()}
#portal {port $Keyword}
#say @ansiPrefix("Portal")@ansiHighlight("Portal Added", 11)%ansi(12)" ("@ansiHighlight(%zoneName(),15)%ansi(12)")"
}]]></value>
<arglist>Keyword, Portal, Bag, Level, Chaos</arglist>
<notes>Add A Portal To The Mapper</notes>
</alias>
|
here is what happens when I do
Quote: |
addport acad2 "aylorian academy portal" "1.lug" 1 |
Code: |
aylorian academy portal|1||lug"|1|0|1|13857 |
it is supposed to look like this
Code: |
aylorian academy portal|1|lug|1|0|1|33847 |
Any suggestions? The last number isnt important. its the room number its the 'bag' 1.lug
I believe it has something to do with the '.' in it but I cant seem to debug it.. |
|
Last edited by harley on Sun Oct 24, 2010 8:39 pm; edited 1 time in total |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Oct 20, 2010 3:43 pm |
The %if function necessarily returns a string, so explicitly adding quotes around it actually produces something like
How it ends up processed may or may not be a bug, I'll let Zugg make the final call on that.
Changing your addkey line to the following should correct the problem.
Code: |
#addkey Portals {$Keyword} {$Portal|%if(%pos(.,$Bag),%left($Bag,%pos(.,$Bag)-1),1)|%if(%pos(.,$Bag),%right($Bag,%pos(.,$Bag)),$Bag)|%if(%len( $Level),$Level,1)|%if(%len($Chaos),$Chaos,0)|1|%roomkey() |
Some general programming advice. You could while technically accurate, is somewhat convoluted. It makes it more difficult to debug and more prone to errors. Oftentimes you miss other efficiencies. In many cases I, and I'm sure many others, do not respond as quickly to a posting with complex code because of the time investment usually necessary to figure what it's trying to do. |
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Oct 20, 2010 5:18 pm |
Please post your CMUD questions in the General CMUD Discussion Forum and not this Beta Forum.
|
|
|
|
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Thu Oct 21, 2010 12:39 am |
I wish I wrote this, it would make more sense to debug it if I knew what was going on.
Thanks for your help Tech |
|
|
|
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Sun Oct 24, 2010 8:39 pm |
fyi, this worked perfectly. Thanks
|
|
|
|
|
|
|
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
|
|