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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Hemdall
Wanderer


Joined: 30 Nov 2006
Posts: 50

PostPosted: Mon Dec 20, 2010 2:25 am   

How improve a script?
 
Hello,
I'm a bit concerned about efficiency one of my scripts (haven't done any benchmark test because I don't know how I could do that). I will be grateful for any suggestion how possibly I could improve a code. Firstly I got 32 gauge buttons where the caption is string from database variable. Every time I check health i destroy this variable and it is recreated when specific trigger fires on. Records in this variable are names of the team members and their actual health (thats why I destroy it when I check health). I would like to know if caption of button is updated every time trigger fires on and the specific variable has changed or only when position of the specific record in this variable has changed. What impact will have using #sort every time variable changes considering it might have 20+ records already?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Dec 20, 2010 3:01 am   
 
Every gauge which depends on any value in that button will be updated whenever any value in that button is updated. You're concern is well-founded--this will be extremely inefficient. Also, I believe that once you use #sort, the variable will have an internal toggle set which will keep the variable sorted until you turn the toggle off or the variable is destroyed.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Dec 20, 2010 11:42 pm   
 
The caption of all 32 buttons are updated whenever at least one caption in the variable is changed. This because buttons do not see beyond the top level of a variable reference (that is, the button will see @varname but not .key) when determining if any variable references were modified.

As far as other points of efficiency:

1)choose to modify a value instead of destroying the setting and recreating it later.
2)disable what you can when you are sure you do not need it
_________________
EDIT: I didn't like my old signature
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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