![](templates/Classic/images/spacer.gif) |
Leitia Adept
![](images/avatars/180146993747bbbc58c3bfa.gif)
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sat Jun 12, 2010 7:17 am
Deep Nesting |
Hi, anyone have any thoughts about complicated nests like this? Seems fine, Just the number of closing brackets is intimidating
Code: |
#class Pouring|Datagroup
#sh debug enter Nextsp
#if (%ismember( "to", @PRH_NextOrders)) {
#addkey PotionAI Client %proper( %item( @PRH_NextOrders, %eval( %ismember( "to", @PRH_NextOrders) + 1)))
#sh %format( " &-16s", Client name: @PotionAI.client)
#co @prh_crinfo
#sh ""
#delnitem PRH_NextOrders %eval( %ismember( "to", @PRH_NextOrders) + 1)
#delitem PRH_NextOrders "to"
}
#if (%ismember( "stop", @PRH_NextOrders)) {
#sh "STOPPED"
#addkey PotionAI pause 1
#co @prh_crinfo
#if (@PRH_Filled = @PRH_CurBrews) {#sh ~debug would be PRH_Interrupt}
#if (%numitems( @PRH_QODB) or %numitems( @OrderDB)) {#sh ~debug would be PRH_Interrupt}
#if (@PRH_Filled != @PRH_CurBrews) {#sh ~debug would be PRH_Interrupt}
#delitem PRH_NextOrder "stop"
}
#forall @PRH_NextOrders {#if (%i = "ffo") {
#delkey PotionAI WhichDB
#sh Swtiching Focus: Using Financial Database
} {#if (%i = "ehh") {
#addkey PotionAI WhichDB 1
#sh Swtiching Focus: Using Ephemeral Database
} {#if (%isnumber( %i)) {
callshort %i
#var vpouring1 @prh_vshort1
#sh %format( " &-16s", Filling @vpouring1.)
#co @prh_crinfo
#sh ""
#unvar prh_vshort1
} {#if (%match( %lower( %i), "(vial%d)", vpouring1)) {
#sh %format( " &-16s", Filling @vpouring1.)
#co @prh_crinfo
#sh ""
} {#if (%lower( %i) = "vial") {
#var vpouring1 Vial
#sh %format( " &-16s", Filling generic @vpouring1.)
#co @prh_crinfo
#sh ""
} {#if ( %i = "statdb") {#exec PRH_AllStat db} {#if ( %i = "track") {#exec PRH_AllStat track} {#if ( %i = "stat") {#exec PRH_AllStat} {#if (%i = "last") {
#if (%numitems( @PRH_Doover) > 0) {
#sh Work Order regressed to %item( @PRH_DoOver, %numitems( @PRH_DoOver))
#co @prh_crinfo
#var PRH_IKeys %push( %item( @PRH_DoOver, %numitems( @PRH_DoOver)), @PRH_IKeys)
#var PRH_DoOver %delnitem( @PRH_DoOver, %numitems( @PRH_DoOver))
}
} {#if (%i = "repot") {
#var PRH_IKeys ""
#loopdb @RiftCost {#addi PRH_IKeys %key}
#if (%ismember( @PRH_IKeys, "gold")) {#var PRH_IKeys %additem( gold, @PRH_IKeys)}
#unvar PRH_DoOver
} {#if (!%null( %i)) {#var PRH_Xpot %i}}}}}}}}}}}}
#unvar PRH_NEXTORDERS
#if (!%null( @PRH_Xpot)) {SetPot}
#if (%numitems( @PotionAI.fix)) {
#if (%ismember( "forceret", @PotionAI.fix)) {
#if (%null( @PotionAI.AutoReturn)) {
#sh ""
#sh {Work Order exceeds vial capacity. Return presently set to hold vials.}
#co @prh_crwarn
#sh {FORCING AUTO RETURN... done.}
#co @prh_crwarn
#sh ""
#addkey PotionAI AutoReturn X
#if (%numitems( @PotionAI.fix) > 1) {#addkey PotionAI fix %delitem( "forceret", @PotionAI.fix)} {#delkey PotionAI fix}
}
}
#if (%ismember( "noclient", @PotionAI.fix)) {
#sh ""
#sh {Return order set to 'After Filling'. No Client.}
#co @prh_crwarn
#sh {Please Enter 'NEXT to Whomever.}
#co @prh_crwarn
#sh ""
#if (%numitems( @PotionAI.fix) > 1) {#addkey PotionAI fix %delitem( "noclient", @PotionAI.fix)} {#delkey PotionAI fix}
}
}
#sh debug exit Nextsp
#class 0 |
|
|
|
![](templates/Classic/images/spacer.gif) |
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Jun 12, 2010 1:34 pm |
I try to write my code with C style indentation and bracketing. Makes bracket matching a lot easier to keep track of ;) (I write mostly in C and PHP anyways.. so its habit)
Like this:
Code: |
#IF (@var = 1)
{
#IF (@var2 = 2)
{
#COMMAND OF SOME KIND
}
} |
Of course, the darned editor doesn't always keep this... since simple things get collapsed to a single line ;) |
|
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
![](templates/Classic/images/spacer.gif) |
Leitia Adept
![](images/avatars/180146993747bbbc58c3bfa.gif)
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sun Jun 13, 2010 10:15 pm |
My Bad.
That is easy to look at. I use notepad++ if I need to work on a file like this, it matches brackets. Actually if I had your knowledge I could make notepad++ convert the whole thing to some more understandable fashion.
Getting the code bracketed is not so much a worry. I was wondering if there an instability with deep nests; I have a program that makes dialogs and only allows like 9 levels of nests. That is why I was curious.
I'll say though, inserting a new conditional in a deep nest is not editor friendly even if it is properly formatted. I usually paste the original in a backup in case I get that scary, plain, not compiled script. Then I can try to appease the editor with spacing.
Still thanks. ![Razz](images/smiles/icon_razz.gif) |
|
|
![](templates/Classic/images/spacer.gif) |
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Mon Jun 14, 2010 1:52 am |
Leitia wrote: |
My Bad.
That is easy to look at. I use notepad++ if I need to work on a file like this, it matches brackets. Actually if I had your knowledge I could make notepad++ convert the whole thing to some more understandable fashion.
Getting the code bracketed is not so much a worry. I was wondering if there an instability with deep nests; I have a program that makes dialogs and only allows like 9 levels of nests. That is why I was curious. |
I have an extremely detailed group healer mulebot trigger set for one mud I used to play that has really deep nesting conditionals. I've never had any troubles with it.
Quote: |
I'll say though, inserting a new conditional in a deep nest is not editor friendly even if it is properly formatted. I usually paste the original in a backup in case I get that scary, plain, not compiled script. Then I can try to appease the editor with spacing.
Still thanks. ![Razz](images/smiles/icon_razz.gif) |
Don't remind me! I always keep backups of my scripts. Every revision I make backups :) Only the big ones of course, like the aforementioned healer mulebot :) |
|
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
![](templates/Classic/images/spacer.gif) |
Zugg MASTER
![](images/avatars/164475849040f41c23b22fe.gif)
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jun 14, 2010 4:39 pm |
zMUD does not properly handle full nesting like this. zMUD was originally written to have all scripts on one line, so zMUD will try to convert your script to a single line internally, which can cause problems. You really need to use CMUD for stuff like this since CMUD was designed to handle multiline scripts.
|
|
|
![](templates/Classic/images/spacer.gif) |
Leitia Adept
![](images/avatars/180146993747bbbc58c3bfa.gif)
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Thu Jul 01, 2010 6:35 am |
Thanks, I did put down the project due to irl changes, but if I return to it I can use single line conditionals, then set the XPot name thing with a variable. Not that there is any call for this script, except it's fun.
I would bring my old works to CMud, but my Pavilion was sketch out of the box, I would need an OS or something that ignores HP. What a burn. Don't blame me, I am happy to have a broken pavillion, even. I would use it with XP, though this and that. |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|