 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sat Jan 19, 2008 9:13 pm
fast formula for maxing strings |
Hi. I am using a script I dislike because it is really slow. I think that is because I am continually writing strings and such. I was wondering if anyone has a fast script to do maxed strings. I have a vague belief that a string can be maxed before writing a variable but suppose that is a page of bitwise, which is beyond me at this point. Would love to look one over. This is my speed and with buttons flickering it is a lightshow.
#var prh_curvlist "" {_nodef} {Pouring|DataGroup}
#var prh_maxlist "" {_nodef} {Pouring|DataGroup}
#var prh_curmax "" {_nodef} {Pouring|DataGroup}
#var prh_mamaduck "" {_nodef} {Pouring|DataGroup}
#forall %1 {#var prh_curvlist %additem( %item( %db( @BaseVialsAll, %i), @MaxSwitch), @prh_curvlist)}
#var prh_curvlist %dups( @prh_curvlist)
#if (@PotionAI.max = "min") {
#loop %numitems( @prh_curvlist) {
#var prh_maxlist %additem( %min( %replace( @prh_curvlist, "|", ",")), @prh_maxlist)
#var prh_curvlist %delitem( %min( %replace( @prh_curvlist, "|", ",")), @prh_curvlist)
}
} {
#loop %numitems( @prh_curvlist) {
#var prh_maxlist %additem( %max( %replace( @prh_curvlist, "|", ",")), @prh_maxlist)
#var prh_curvlist %delitem( %max( %replace( @prh_curvlist, "|", ",")), @prh_curvlist)
}
}
#until (%numitems( @prh_maxlist) < 1) {
#var prh_curmax %pop( prh_maxlist)
#forall %1 {#if (%item( %db( @BaseVialsAll, %i), @Maxswitch) = @prh_curmax) {#addi prh_mamaduck %i}}
}
#unvar prh_curvlist {Pouring|DataGroup}
#unvar prh_maxlist {Pouring|DataGroup}
#unvar prh_curmax {Pouring|DataGroup}
well, maybe in time I can improve that, until then, thanks for any help. |
|
|
 |
Dharkael Enchanter

Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Tue Jan 29, 2008 1:04 am |
Just what are you trying to get done in this script?
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Tue Jan 29, 2008 2:03 pm Oh Hi |
Actually this one is used to max and min age and quantities on potion vials, it is sufficient, just I had wondered if there was a quicker way
|
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Tue Jan 29, 2008 2:33 pm |
So... You are in Achaea or some similar mud and your potions have an age as well as a sip count and you are trying to sort them so you know when you need to refill or pour into another vial?
A sample of input and output data, as well as a procedure for using the code is generally given when you ask for advice on code like this.
At this point I can only guess that this is an alias and that you pass in a string list. Is it a recursive alias?
Finally you are asking about maxing a string. This is very vague language. Do you mean you want to find the maximum value in a string list? Do you mean that you want to fill a variable to its maximum limit?
Or is there some strange command or procedure on your mud commonly referred to as maxing a string? [At least we have some hint from your reply but we really do need the information that I asked for]
Yes, sometimes when I or one of the other posters is very bored we run through the code until we get a good idea of how it MUST work but that is rare.
When one of the scripting kings like Dharkael is asking questions you probably need to give more info. He btw usually goes out of his way to write something cool if something strikes his interest... |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Tue Jan 29, 2008 7:51 pm |
I see, I did not realize I was being vague. By a maxed string I meant each element sorted by ascending or descending value, independent of what purpose, simply numerically.
I am not deep into computer programming, and recursive logic has crossed my path termed such only once before, I think it applied to a file list I needed including subdirectories. I Wikied recursion and see there are recursive functions, and math, and I am very sure, this is what I was looking for when I asked if anyone could max a string without writing a variable. More or less, I was trying to say that, anyway. Still I meant each element in the string, and considered that a holy grail of personal ideals, to write a function that could internally calculate an indefinite string of values from least to most or vice versa, without variables. I was curious.
Practically, I am good just using the above script, I did complain that it wrote variables, when I saw that impossibly complicated string manipulations and math seem to process values more quickly and smoothly then easily read and attractive scripts that have all kind of meaningful variables. I prefer variables, but I want speed. I am managing well I think despite my silly limitations.
Thank you both. I have to run. The script above is an alias which is given a vial list which it then calls either vial age or vial sips from a nasty (but central) database of string values. I use it half a dozen times for displays, warning stats, and to manage practically the automatic pouring of aged potions into newer vials without digression (that a word?) . I am playing Achaea.
Happy to answer any questions if I have not been clear. Thanks again. |
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Tue Jan 29, 2008 10:08 pm |
Dharkael's
#var sortedlist %replace(%mss(%concat("[",%expandlist(@slist,","),"]",".sort(function(A,B){return (Number(A)<Number(B))? -1:(Number(A)==Number(B))?0:1})"),"JScript"),",","|")
that is really amazing.
thanks, though it was not intended for me |
|
|
 |
Dharkael Enchanter

Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Wed Jan 30, 2008 4:09 am |
It was put out there for anyone and everyone.
Glad it worked out.
to change the sort order from ascending to descending is quite simple as well.
Ascending
#var sortedlist %replace(%mss(%concat("[",%expandlist(@slist,","),"]",".sort(function(A,B){return (Number(A)<Number(B))? -1:(Number(A)==Number(B))?0:1})"),"JScript"),",","|")
Descending
#var sortedlist %replace(%mss(%concat("[",%expandlist(@slist,","),"]",".sort(function(A,B){return (Number(A)>Number(B))? -1:(Number(A)==Number(B))?0:1})"),"JScript"),",","|") |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
 |
Leitia Adept

Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Fri Feb 01, 2008 12:46 am awe and joy |
seriously, I had some kind of terrific wonder that lasted 5 minutes over this, wicked giggles and glee, took like a second to process a whole DB with writing keys.
there it goes again...
i love you |
|
|
 |
|
|
|
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
|
|