Utility Object #20
21 verbs · 14 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
parse_prop_ref | this none this | rwxd | #20 | 31 |
cap*italize | this none this | rwxd | #20 | 5 |
triml*eft | this none this | rwxd | #20 | 5 |
list_to_str*ing | this none this | rwxd | #20 | 27 |
trimr*ight | this none this | rwxd | #20 | 4 |
parse_verb_ref | this none this | rwxd | #20 | 31 |
sort | this none this | rwxd | #20 | 27 |
match | this none this | rwxd | #20 | 41 |
parse_dot_ref | this none this | rwxd | #20 | 11 |
padl*eft | this none this | rwxd | #20 | 13 |
padr*ight | this none this | rwxd | #20 | 13 |
dhms | this none this | rwxd | #20 | 10 |
_uptime | this none this | rwxd | #20 | 4 |
ftime | this none this | rwxd | #20 | 36 |
dhms_str | this none this | rwxd | #20 | 13 |
longest*_length | this none this | rwxd | #20 | 11 |
string_to_list | this none this | rwxd | #20 | 13 |
rem*ove | this none this | rwxd | #20 | 10 |
string_to_frag*ment | this none this | rwxd | #20 | 18 |
match_dollar_ref | this none this | rwxd | #20 | 17 |
height_str | this none this | rwxd | #20 | 4 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
description | #1 | rw | #10 | <clear> |
aliases | #1 | rw | #10 | <clear> |
home | #1 | rw | #10 | <clear> |
short_desc | #1 | rw | #10 | <clear> |
core | #1 | rw | #10 | 1 |
handedness | #1 | rw | #10 | <clear> |
base_enc | #1 | rw | #10 | <clear> |
base_weight | #1 | rw | #10 | <clear> |
capacity | #1 | rw | #10 | <clear> |
max_fit | #1 | rw | #10 | <clear> |
pprep | #1 | rw | #10 | <clear> |
gprep | #1 | rw | #10 | <clear> |
generic_name | #1 | rw | #10 | <clear> |
age | #1 | rw | #10 | <clear> |
Ancestry
Ancestors (nearest first): #1 Root Class
Children: none
Call graph
Source
parse_prop_ref
Referenced by
- #8:edit line 7:
$utils:parse_prop_ref - #9:rmp*rop line 48:
$utils:parse_prop_ref - #10:addp*rop line 21:
$utils:parse_prop_ref
Source
1" #20:parse_prop_ref this none this"; 2prop_ref = args[1]; 3dot = index(prop_ref, "."); 4if (!dot) 5if (prop_ref[1] != "$") 6return 0; 7else 8return {"#0", prop_ref[2..$]}; 9endif 10else 11object = prop_ref[1..dot - 1]; 12prop = prop_ref[dot + 1..$]; 13if (!(object && prop)) 14return 0; 15elseif (object[1] != "$") 16return {object, prop}; 17else 18sysprop = object[2..$]; 19if (!$has_prop(sysprop)) 20return 0; 21else 22object = #0.(sysprop); 23if (typeof(object) != OBJ) 24return 0; 25else 26object = tostr(object); 27return {object, prop}; 28endif 29endif 30endif 31endif
cap*italize
Referenced by
none
Source
1" #20:capitalize(STR) this none this "; 2if ((string = args[1]) && (i = index("abcdefghijklmnopqrstuvwxyz", string[1], 1))) 3string[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i]; 4endif 5return string;
triml*eft
Referenced by
none
Source
1"$utils:triml*eft this none this"; 2"copied from LambdaMOO"; 3{string, ?what = " "} = args; 4index = match(string, tostr("[^", what, "]%|$")); 5return string[index[1]..$];
list_to_str*ing
Referenced by
none
Source
1"$utils:list_to_str*ing this none this"; 2{thelist, ?separator = "", ?conj = ""} = args; 3if (thelist == {}) 4return ""; 5else 6if (length(thelist) == 1) 7return tostr(thelist[1]); 8else 9if (separator == "") 10return tostr(@thelist); 11else 12if (conj) 13if (length(thelist) == 2) 14result = (((tostr(thelist[1]) + " ") + conj) + " ") + tostr(thelist[2]); 15return result; 16else 17thelist[$] = (conj + " ") + tostr(thelist[$]); 18endif 19endif 20result = tostr(thelist[1]); 21for item in (listdelete(thelist, 1)) 22result = tostr(result, separator, item); 23endfor 24return result; 25endif 26endif 27endif
trimr*ight
Referenced by
none
Source
1"$utils:trimr*ight this none this"; 2"Copied from LambdaMOO"; 3{string, ?what = " "} = args; 4return string[1..rmatch(string, tostr("[^", what, "]%|^"))[2]];
parse_verb_ref
Referenced by
- #9:addverb line 28:
$utils:parse_verb_ref - #9:show*verb line 7:
$utils:parse_verb_ref - #9:args line 5:
$utils:parse_verb_ref - #9:args line 16:
$utils:parse_verb_ref
Source
1"$utils:parse_verb_ref this none this"; 2verb_ref = args[1]; 3colon = index(verb_ref, ":"); 4if (!colon) 5if (verb_ref[1] != "$") 6return 0; 7else 8return {"#0", verb_ref[2..$]}; 9endif 10else 11object = verb_ref[1..colon - 1]; 12verbname = verb_ref[colon + 1..$]; 13if (!(object && verbname)) 14return 0; 15elseif (object[1] != "$") 16return {object, verbname}; 17else 18prop_name = object[2..$]; 19if (!$has_prop(prop_name)) 20return 0; 21else 22object = #0.(prop_name); 23if (typeof(object) != OBJ) 24return 0; 25else 26object = tostr(object); 27return {object, verbname}; 28endif 29endif 30endif 31endif
sort
Referenced by
- #3:sc*ore line 67:
$utils:sort - #3:sc*ore line 82:
$utils:sort - #3:admins line 21:
$utils:sort - #5:testsort line 7:
$utils:sort - #8:props line 18:
$utils:sort - #9:verbs line 10:
#20:sort - #9:grep line 4:
#20:sort - #9:which line 7:
$utils:sort - #10:missing line 14:
$utils:sort - #20:sort line 24:
$utils:sort - #20:sort line 25:
$utils:sort
Source
1"quick sort algorithm"; 2sortlist = args[1]; 3if (length(sortlist) <= 1) 4return sortlist; 5elseif (length(sortlist) == 2) 6return (sortlist[1] < sortlist[2]) ? {sortlist[1], sortlist[2]} | {sortlist[2], sortlist[1]}; 7else 8"partition into left and right"; 9left = {}; 10right = {}; 11pivotlist = {}; 12pivotindex = random(length(sortlist)); 13pivotitem = sortlist[pivotindex]; 14for each in (sortlist) 15if (each < pivotitem) 16left = {@left, each}; 17elseif (each > pivotitem) 18right = {@right, each}; 19else 20pivotlist = {@pivotlist, each}; 21endif 22endfor 23"sort each side"; 24sortedleft = $utils:sort(left); 25sortedright = $utils:sort(right); 26return {@sortedleft, @pivotlist, @sortedright}; 27endif
match
Referenced by
- #0:do_login_command line 30:
$utils:match - #3:mes*sage line 17:
$utils:match - #3:info*rmation line 18:
$utils:match - #3:cast line 22:
$utils:match - #3:_speak line 4:
$utils:match - #6:passwd line 5:
$utils:match - #6:intro*duce line 7:
$utils:match
Source
1"#20:match(str, objlist, ?exact, ?nameonly) - returns a list of objs from args[2] that"; 2"are named or aliased to args[1]. args[3] if true forces a full match. args[4] will"; 3"if true match only to object's name"; 4"if no match, returns empty list."; 5{token, objlist, ?exact = 0, ?nameonly = 0} = args; 6count = 0; 7count_and_item = $utils:parse_dot_ref(token); 8if (count_and_item) 9{count, item} = count_and_item; 10endif 11if (count > 0) 12token = item; 13endif 14matchlist = {}; 15for each in (objlist) 16if (!(each in matchlist)) 17doesmatch = 0; 18if (nameonly) 19names = {each.name}; 20else 21names = {each.name, @each.aliases}; 22endif 23for name in (names) 24if (exact) 25doesmatch = doesmatch || (token == name); 26else 27doesmatch = doesmatch || (index(name, token) == 1); 28endif 29endfor 30if (doesmatch) 31matchlist = {@matchlist, each}; 32endif 33endif 34endfor 35if (count == 0) 36return matchlist; 37elseif (count <= length(matchlist)) 38return {matchlist[count]}; 39else 40return {}; 41endif
parse_dot_ref
Referenced by
- #3:match line 11:
$utils:parse_dot_ref - #10:match line 26:
$utils:parse_dot_ref - #20:match line 7:
$utils:parse_dot_ref
Source
1"$utils:parse_dot_ref(str) returns {int count, str}"; 2"used for dot matching... 2.sword, etc."; 3{prop_ref} = args; 4dot = index(prop_ref, "."); 5if (dot > 1) 6NUM = prop_ref[1..dot - 1]; 7token = prop_ref[dot + 1..$]; 8return {tonum(NUM), token}; 9else 10return 0; 11endif
padl*eft
Referenced by
none
Source
1"$utils:padleft(str token, int length, str char)"; 2{token, len, ?char = " "} = args; 3token = tostr(token); 4needed = len - length(token); 5times = 1 + (needed / length(char)); 6for x in [1..times] 7token = char + token; 8endfor 9newlen = length(token); 10if (newlen != len) 11token = token[(newlen - len) + 1..newlen]; 12endif 13return token;
padr*ight
Referenced by
none
Source
1"$utils:padright(str token, int length, str char)"; 2{token, len, ?char = " "} = args; 3token = tostr(token); 4needed = len - length(token); 5times = 1 + (needed / length(char)); 6for x in [1..times] 7token = token + char; 8endfor 9newlen = length(token); 10if (newlen != len) 11token = token[1..len]; 12endif 13return token;
dhms
Referenced by
- #3:info*rmation line 48:
$utils:dhms - #3:admins line 35:
$utils:dhms - #20:_uptime line 2:
$utils:dhms
Source
1"$utils:dhms(seconds)"; 2"returns {days, hours, minutes, seconds}"; 3{seconds} = args; 4days = seconds / 86400; 5seconds = seconds % 86400; 6hours = seconds / 3600; 7seconds = seconds % 3600; 8minutes = seconds / 60; 9seconds = seconds % 60; 10return {days, hours, minutes, seconds};
_uptime
Referenced by
Source
1"$utils:_uptime() this none this"; 2times = $utils:dhms(time() - $start_time); 3uptime_str = $utils:dhms_str(times); 4return uptime_str;
ftime
Referenced by
- #3:who line 49:
$utils:ftime - #3:who line 51:
$utils:ftime - #3:set_disconnect_info line 8:
$utils:ftime - #10:time line 2:
$utils:ftime
Source
1"$utils:ftime this none this"; 2"format any string in ctime format"; 3ctime = args[1]; 4_day = ctime[1..3]; 5_mo = ctime[5..7]; 6_hour = ctime[12..13]; 7daynum = ctime[9..10]; 8min = ctime[15..16]; 9daysav = ctime[26..28]; 10day = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}[_day in {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}]; 11mo = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}[_mo in {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}]; 12"switch to standard time format"; 13if (tonum(_hour) > 11) 14hour = tonum(_hour) - 12; 15ampm = "pm"; 16else 17hour = tonum(_hour); 18ampm = "am"; 19endif 20hour = tostr(hour); 21if (hour == "0") 22hour = "12"; 23endif 24"set ordinal notation"; 25x = daynum in {" 1", "21", "31", " 2", "22", " 3", "23"}; 26if (x) 27ord = {"st", "st", "st", "nd", "nd", "rd", "rd"}[x]; 28else 29ord = "th"; 30endif 31"eliminate extra spaces"; 32if (daynum[1] == " ") 33daynum = daynum[2]; 34endif 35new_string = (((((((((((day + ", ") + mo) + " ") + daynum) + ord) + ", ") + hour) + ":") + min) + ampm) + " ") + daysav; 36return new_string;
dhms_str
Referenced by
- #3:info*rmation line 48:
$utils:dhms_str - #3:admins line 35:
$utils:dhms_str - #20:_uptime line 3:
$utils:dhms_str
Source
1"$utils:dhms_str() this none this"; 2times = args[1]; 3days = times[1]; 4daystr = (days == 1) ? " day, " | " days, "; 5day_var = (days == 0) ? "" | (tostr(days) + daystr); 6hours = times[2]; 7hourstr = (hours == 1) ? " hour, " | " hours, "; 8hour_var = ((days == 0) && (hours == 0)) ? "" | (tostr(hours) + hourstr); 9mins = times[3]; 10minstr = (mins == 1) ? " minute." | " minutes."; 11min_var = tostr(mins) + minstr; 12final_str = (day_var + hour_var) + min_var; 13return final_str;
longest*_length
Referenced by
none
Source
1"$utils:longest*_length this none this"; 2"If more than one is longest, returns length of first."; 3thelist = args[1]; 4longest = 0; 5for x in (thelist) 6xlen = length(x); 7if (xlen > longest) 8longest = xlen; 9endif 10endfor 11return longest;
string_to_list
Referenced by
- #4:test line 2:
$utils:string_to_list - #20:string_to_frag*ment line 2:
$utils:string_to_list
Source
1"$utils:string_to_list this none this"; 2string = args[1]; 3newlist = {}; 4if (length(string)) 5while (ref = index(string, " ")) 6newlist = {@newlist, string[1..ref - 1]}; 7string = string[ref + 1..$]; 8endwhile 9newlist = {@newlist, string}; 10endif 11"Clear out any doubled spaces that ended up in the list."; 12newlist = $utils:remove(newlist, "", 1); 13return newlist;
rem*ove
Referenced by
none
Source
1"$utils:remove this none this"; 2{thelist, what, ?all = 0} = args; 3if (all) 4while (what in thelist) 5thelist = setremove(thelist, what); 6endwhile 7else 8thelist = setremove(thelist, what); 9endif 10return thelist;
string_to_frag*ment
Referenced by
none
Source
1"$utils:string_to_frag*ment this none this"; 2words = $utils:string_to_list(args[1]); 3len = length(words); 4first = random(len); 5rest = len - first; 6if (!rest) 7frag = words[first]; 8else 9newlist = {}; 10more = random(rest + 1) - 1; 11count = first; 12while (count <= (first + more)) 13newlist = {@newlist, words[count]}; 14count = count + 1; 15endwhile 16frag = $utils:list_to_string(newlist, " "); 17endif 18return frag;
match_dollar_ref
Referenced by
- #10:match line 15:
$utils:match_dollar_ref
Source
1"$utils:match_dollar_ref this none this"; 2"matches a $ref to the object it evals to"; 3dollar_ref = args[1]; 4if (dollar_ref[1] != "$") 5return 0; 6else 7try 8xobj = #0.(dollar_ref[2..$]); 9if (typeof(xobj) == OBJ) 10return xobj; 11else 12return 0; 13endif 14except (ANY) 15return 0; 16endtry 17endif
height_str
Referenced by
- #60:describe_to line 30:
$utils:height_str - #60:describe_to line 30:
$utils:height_str
Source
1"$utils:height_str this none this"; 2{height} = args; 3height_str = ((tostr(height / 12) + "' ") + tostr(height % 12)) + "\""; 4return height_str;