@prog randomline.muf 1 9999 d 1 i ( randomline.muf - pick a random line from a list. Usage: link an exit to this program. By default, the list is stored in _list1:, _list2:, etc, properties on the dbref the exit is attached to. You can change the property prefix with a property _prefix: on the exit [its value must be the prefix string]; you can change the dbref with a property _holder: on the exit [its value must be the dbref number, without the #]. This program caches the count of the list in a property _list#: [or whatever prefix was specified] on the dbref. It updates this property automatically. If the list contains no lines, nothing is printed. Unless the exit is owned by a royal or wiz, the holder dbref must be owned by the same player as the exit. The triggering exit is located with trig; messages are sent to "me" match. ) $def holder-prop "_holder" $def prefix-prop "_prefix" $def default-prefix "_list" : say "me" match swap notify ; : prefix-str (trigger -- str) dup prefix-prop prop-exists? if prefix-prop getpropstr else pop default-prefix then ; : recompute-list-count (holder pfx -- holder pfx count) 1 begin ( holder pfx n ) over over intostr strcat 4 pick swap prop-exists? while 1 + loop 1 - dup 1 < if pop over over "#" strcat remove_prop 0 exit then 3 pick 3 pick "#" strcat 3 pick intostr addprop ; : get-list-count (holder pfx -- holder pfx count) over over "#" strcat getpropstr atoi ( holder pfx n ) dup if over over 1 + intostr strcat 4 pick swap prop-exists? not if exit then then pop recompute-list-count ; : main pop trig holder-prop prop-exists? if trig holder-prop getpropstr atoi dbref else trig location then dup ok? if dup owner trig owner dbcmp if 0 else trig owner true-royalty? not then else 1 then if pop "Permission denied." say exit then ( holder ) trig prefix-str ( holder pfx ) get-list-count ( holder pfx count ) dup 1 < if pop pop pop exit then random swap % 1 + intostr strcat over over prop-exists? not if pop trig prefix-str recompute-list-count random swap % 1 + intostr strcat then getpropstr say ; . c q