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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Winger
Beginner


Joined: 23 May 2004
Posts: 14

PostPosted: Thu May 27, 2004 2:53 am   

Simply a mess.
 
Greetings. You all must be piss tired of me by now. However, I'm hoping someone has a way of simplifying a huge mess of functions I've made in several areas, that I think might be slowing the computer, or Zmud down. Even if it isn't, simplifying it would generally be helpful. If you can help, please do. Copied straight out of the Combat Class script.


#ALIAS char {
Combat/curchar = %1
#FORALL @Combat/charlist {
#IF (%i != @Combat/curchar) {
#CLASS %concat( %i, "Class") 0
#VAR %concat( "Combat/", %concat( %i, "c")) 0
#CLASS %concat( "Smoking/", %concat( %i, "ClassS")) 0
} {
#CLASS %concat( %i, "Class") 1
#VAR %concat( "Combat/", %concat( %i, "c")) 1
#CLASS %concat( "Smoking/", %concat( %i, "ClassS")) 1
}
}
}
#ALIAS addchar {
#ADDITEM Combat/charlist %1
#VAR %concat( "Combat/", %concat( %1, "Settings")) {0|0}
#CLASS %concat( "Smoking/", %concat( %1, "ClassS")) disable
#VAR %concat( "Smoking/", %concat( %1, "ClassS/pelm")) "None"
#VAR %concat( "Smoking/", %concat( %1, "ClassS/pval")) "None"
#VAR %concat( "Smoking/", %concat( %1, "ClassS/psku")) "None"
}
#ALIAS setfocus {#VAR %concat( "Combat/", %concat( @curchar, "Settings")) %replaceitem( %1, 1, %concat( "Combat/", %concat( @curchar, "Settings")))}
#ALIAS setinsomnia {#VAR %concat( "Combat/", %concat( @curchar, "Settings")) %replaceitem( %1, 2, %concat( "Combat/", %concat( @curchar, "Settings")))}
#ALIAS charsettings {
#ECHO Elm pipe: %concat( "@Smoking/", %concat( @curchar, "ClassS/pelm")) Skullcap pipe: %concat( "@Smoking/", %concat( @curchar, "ClassS/psku")) Valerian pipe: %concat( "@Smoking/", %concat( @curchar, "ClassS/pval"))
#ECHO Focus: %if( %item( %concat( "@Combat/", %concat( @curchar, "Settings")), 1)=1, Yes, No) Focus: %if( %item( %concat( "@Combat/", %concat( @curchar, "Settings")), 2)=1, Yes, No)
}
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Thu May 27, 2004 9:19 am   
 
The main change I would recommend is using a database, that would help to avoid the %concat() function somewhat and make your code readable.

I am also of the opinion that you can avoid most of this by managing your scripts properly. You might want to have different initialization scripts with variables for each character instead of trying to put everything into one.

What you've pasted over here seems to be just the initialization routine unless I'm missing something. This makes it difficult to comment unless you play the same MUD, and I don't think I do.

...just my 2c.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu May 27, 2004 5:54 pm   
 
First, drop the use of the %concat function. This will make your scripts much easier to read and understand. You can almost always concatenate strings directly. The function should only be used in those rare instances where direct concatenation doesn't work. Variable names can be embedded into strings by surrounding the variable name with {}.

Second, you shouldn't need a new class with a whole new set of triggers, aliases, and variables for every character you fight. Unless you delete all these settings at the end of each battle, you are likely to end up with a settings file which is many times the size it needs to be. After all, just because you needed triggers for fighting Gerwin yesterday doesn't mean you still need those triggers today when he's not even online.

Instead of a new class of settings for every opponent, you should just have one set of triggers and aliases which alter their targets based on variables which show who you are currently fighting.

Third, you are obviously on one of the Iron Realms games or somewhere similar, so you would probably benefit from a search of zMUD General Discussion (this forum) and Finished MUD Scripts for other topics covering Iron Realms scripts. Some keywords you could try are: Iron Realms, Achaea, Aetolia, Imperian, Avalon.

In my next post, I'll address the specifics of your script.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu May 27, 2004 7:01 pm   
 
Actually, now that I've analyzed your script it appears that you have several different characters and you are attempting to keep all your settings in a single file which is used by all of them, but has different settings for each one. It would be better to use individual settings files for each character, especially if they are in different guilds.

To create individual settings files, select one of the characters but don't Connect. Instead, use the Edit button and go to the Files tab. Click the folder icon next to the Primary box. Right-click on the current filename and Copy. Click in an open space and Paste. Rename the copy to something appropriate (Winger.mud or Achaea2.mud, for instance), then select it as your Primary file. This will give you a new file for this character but it will still have all your old settings so you don't have to redo everything.

However, here's a simplified version of your script:
#ALIAS char {
Combat/curchar = %1
#FORALL @Combat/charlist {
#IF (%i != @Combat/curchar) {
#CLASS %{i}Class 0
#VAR Combat/%{i}c 0
#CLASS Smoking/%{i}ClassS 0
} {
#CLASS %{i}Class 1
#VAR Combat/%{i}c 1
#CLASS Smoking/%{i}ClassS 1
}
}
}
#ALIAS addchar {
#ADDITEM Combat/charlist %1
#VAR Combat/%{1}Settings {0|0}
#CLASS Smoking/%{1}ClassS disable
#VAR Smoking/%{1}ClassS/pelm "None"
#VAR Smoking/%{1}ClassS/pval "None"
#VAR Smoking/%{1}ClassS/psku "None"
}
#ALIAS setfocus {#VAR Combat/@{curchar}Settings %replaceitem( %1, 1, @Combat/@{curchar}Settings)}
#ALIAS setinsomnia {#VAR Combat/@{curchar}Settings %replaceitem( %1, 2, @Combat/@{curchar}Settings)}
#ALIAS charsettings {
#ECHO Elm pipe: @Smoking/@{curchar}ClassS/pelm Skullcap pipe: @Smoking/@{curchar}ClassS/psku Valerian pipe: @Smoking/@{curchar}ClassS/pval
#ECHO Focus: %if( %item( @Combat/@{curchar}Settings, 1), Yes, No) Focus: %if( %item( @Combat/@{curchar}Settings, 2), Yes, No)
}
Reply with quote
Winger
Beginner


Joined: 23 May 2004
Posts: 14

PostPosted: Fri May 28, 2004 2:32 am   
 
Thank you! I'm glad you took the time to both analyse and fix the coding, as well as provide a different method of acheiving my goal. I'll make sure to look it over and decide on which is the most suitable. Also, yes, you were 100% correct in your assumption that is is IronRealms. Very skillful assessment
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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