Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Fri Oct 30, 2009 11:50 pm   

[3.11] Suggestion: Statement nesting format
 
Right now when you have nested if/while/loop statements each with only one command in them you end up with something like this when you format it.

Code:
#if (%db( @damage_counter, left_leg) > 1 or %db( @damage_counter, right_leg) > 1) {enemy_restoration %-1} {#if (!%db( @damage_counter, left_leg) and !%db( @damage_counter, right_leg)) {enemy_restoration %-1} {enemy_nonresto %-1}}


This is a bit ugly and hard to read, what I'd like to see an option for formatting like this:

Code:
#if (%db( @damage_counter, left_leg) > 1 or %db( @damage_counter, right_leg) > 1) {
  enemy_restoration %-1
  } {
  #if (!%db( @damage_counter, left_leg) and !%db( @damage_counter, right_leg)) {
    enemy_restoration %-1
    } {
    enemy_nonresto %-1
    }
  }


Right now to accomplish this you have to stick #noops in your script:
Code:

#if (%db( @damage_counter, left_leg) > 1 or %db( @damage_counter, right_leg) > 1) {
  #noop
  enemy_restoration %-1
  } {
  #noop
  #if (!%db( @damage_counter, left_leg) and !%db( @damage_counter, right_leg)) {
    #noop
    enemy_restoration %-1
    } {
    #noop
    enemy_nonresto %-1
    }
  }
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Oct 31, 2009 12:09 am   
 
I'll add that to the to-do list, but CMUD is doing this because when there is only a single statement within a {} block, it keeps it on one line, which is what you want most of the time. I can't just add an option to always expand {} to multiple lines, since that would make simple scripts look silly. And at the time the parser is reformatting the script, it really doesn't have any idea how many levels it is nested. If I can figure out how to keep track of the nesting level in the parser, then maybe I'll be able to do something.

Of course, there's nothing stopping you from simply formatting the script the way you want it. CMUD isn't going to change your formatting unless you use the Reformat command manually. So this really is a pretty minor issue.
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Sat Oct 31, 2009 10:39 am   
 
Zugg wrote:
I'll add that to the to-do list, but CMUD is doing this because when there is only a single statement within a {} block, it keeps it on one line, which is what you want most of the time.


I was actually thinking the option would do it to all #if, #loop, #while, ect statements regardless of if they were nested or not. Seems like the simplest way to implement it as well, not that I can really comment on such a thing. I remember Zmud had a decent amount of options when it came to script formatting, I'd love to see some of that come back. Thanks for the suggestion feedback!
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Oct 31, 2009 2:22 pm   
 
I usually use a '//' on a second line to force it to expand it out. So I have '//' all over the place. I definitely would love seeing some more enhanced intelligence on the part of the parser with regards to this.
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Thu Dec 17, 2009 9:33 pm   
 
anything been done with this? i agree, that expanding it automatically would be a GREAT help. but when initially writing the nested command, it might be easier to write it out in block style, to ensure you have all the brackets and punctuation correctly. but i would like to see this feature as well. =]
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Dec 18, 2009 1:10 am   
 
I, too, would like an option to have everything expanded. Even for simple one liner scripts, I think it looks better/not at all silly.
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Sat May 08, 2010 1:22 am   
 
Still wondering if this is anywhere on your radar. I'd really love to see this, as an option, in the next public release.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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