( @wild ) $include $lib/alynna lvar param $def }t }cat prog "?" flag? if tellhere else tellme then : main param ! 0 var! test 0 var! yes 0 var! oname 0 var! quiet 0 var! loud 0 var! retarget param @ not if { "@dolist / @wild -- by Alynna (C) 2008, GPLv3" " " "Function:" " Execute a command multiple times for different objects." " The mark ## is replaced with the found dbrefs. At least 2 barred arguments are required." "Syntax:" " @dolist |[|[|<#test|#yes|#name|#quiet>[|]]]" " Command: The command to be executed, for example: @chown ##=me [REQUIRED]" " Search argument: The wildcard pattern to use to match. See man smatch to see what wildcards are OK [Default: *]" " Flags: The flags of the objects to be matched. [Default: all]" " Options: [Default: None]" " #test -- Shows you what would be executed, but does not execute." " #yes -- Executes all statements without confirmation. Be careful." " #name -- Replace ## mark with the name of the object instead of the dbref." " #quiet -- Do not output anything at all (except the output of the commands executed)." " #loud -- Output the target and command before executing the command. Spammy." " #force -- Wiz only: Forces the target object to execute the command." " Target: The owner of the objects to be searched. [Default: yourself]" " #all -- Wiz only: Target the entire MUCK" "Example:" " @dolist @set ##=species:fox|Kitsu*|P|#yes|#all" " Change everyone's species who's name starts with 'Kitsu', to the species 'fox'." }array me @ 1 array_make array_ansi_notify exit then param @ "|" explode_array var! args args @ 0 [] dup not if pop "" then var! cmd args @ 1 [] dup not if pop "*" then var! search args @ 2 [] dup not if pop "" then var! flags args @ 3 [] dup not if pop "" then var! opts args @ 4 [] dup not if pop "me" then var! target target @ "#all" smatch if me @ mlevel 5 <= if { "You must be a W2 to specify #ALL as a target" }t exit else #-1 target ! then else me @ mlevel 5 <= if me @ target ! else target @ match target ! target @ int 0 < if { "Target not found. If you wanted to specify everyone, use #ALL." }t exit then then then opts @ "*#test*" smatch if 1 test ! then opts @ "*#yes*" smatch if 1 yes ! then opts @ "*#name*" smatch if 1 oname ! then opts @ "*#quiet*" smatch if 1 quiet ! then opts @ "*#loud*" smatch if 1 loud ! then opts @ "*#force*" smatch if me @ mlevel 5 >= if 1 retarget ! then then target @ search @ flags @ find_array quiet @ not if dup array_count tostr " item(s) found.." strcat { swap { "^BLUE^<^YELLOW^@Wild^BLUE^> ^ ^Result for Search[" search @ "], Flags[" flags @ "], Target[" target @ "] .. " }cat swap }t then foreach var! tgtref oname @ if cmd @ { tgtref @ name }cat "##" subst else cmd @ { "#" tgtref @ int }cat "##" subst then var! tgtcmd test @ if { "TEST " tgtref @ ansi_unparseobj "^ ^> " tgtcmd @ }t else loud @ yes @ not or if { "EXEC " tgtref @ ansi_unparseobj "^ ^> " tgtcmd @ yes @ not if " -- Y)es, N)o, A)ll, Q)uit?" then }t then yes @ not if read else "y" then var! x x @ "y*" smatch if retarget @ if tgtref @ else me @ then tgtcmd @ force then x @ "a*" smatch if retarget @ if tgtref @ else me @ then tgtcmd @ force 1 yes ! then x @ "q*" smatch if quiet @ not if { "^BLUE^<^YELLOW^@Wild^BLUE^> ^ ^And, done." }t then exit then then repeat quiet @ not if { "^BLUE^<^YELLOW^@Wild^BLUE^> ^ ^And, done." }t then ;