musicmud-2.1.6/data/
musicmud-2.1.6/data/help/
musicmud-2.1.6/data/policy/
musicmud-2.1.6/data/wild/
musicmud-2.1.6/data/world/
musicmud-2.1.6/doc/
musicmud-2.1.6/src/ident/
musicmud-2.1.6/src/lua/
musicmud-2.1.6/src/lua/include/
musicmud-2.1.6/src/lua/src/lib/
musicmud-2.1.6/src/lua/src/lua/
musicmud-2.1.6/src/lua/src/luac/
local argc=getn(arg)
local congeal=function(start)
  local s=""

  if %argc<start or start>getn(%arg) then return "" end
  if %argc==start then return %arg[start] end
  
  for i=start,%argc-1 do  
    s=s..%arg[i].." "
  end

  s=s..%arg[%argc]
  return s
end

if argc<1 then
  send(pl,"Syntax: ^Wmyact list^n ^b[^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact do ^b<^Baction^b> <^Btarget^b>^n")
  send(pl,"    or: ^Wmyact show ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact dump ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact get ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact erase ^b<^Baction^b> <^Btype^b>^n")
  send(pl,"    or: ^Wmyact add ^b<^Baction^b> <^Btype^b> <^Bstring^b>^n")
  send(pl,"    or: ^Wmyact get ^b<^Baction^b> <^Bsource^b>^n")
  send(pl,"Where ^Btype^n is one of ^Wunt^n, ^Wtarg^n, ^Wmult^n, ^Wtext^n, ^Wttext^n, ^Wprop^n, or ^Wobj^n, and ^Baction ^nis the name of a personalised action.")
  send(pl,"^BPlayer^n is an optional argument, use it to peruse another player's actions.")
  return
end

if arg[1]~="do" and arg[1]~="erase" and arg[1]~="add" and arg[1]~="show" and arg[1]~="dump" and arg[1]~="list" and arg[1]~="get" then
  send(pl,"First argument should be ^Wdo^n, ^Werase^n, ^Wshow^n, ^Wdump^n, ^Wlist^, ^Wget^n, or ^Wadd^n.")
  return
end

if arg[1]=="list" then
  local actl={}
  local lact={}
  local s=""
  local aen=0
  local anum=0
  local plr=pl

  if arg[2] then
    plr=matchplayer(pl,arg[2])
    if !plr then
      send(pl,"Invalid target for list.")
      return
    end
  end

  local atab=getprops(plr,"myact.")

  for i,v in atab do
    aen=strfind(i,"%.[%a]+$")
    s=strsub(i,7,aen-1)
    if !lact[s] then 
      lact[s]=1
      actl[anum]=s
      anum=anum+1
    end
  end

  if plr==pl then send(pl,"You have defined the following actions:")
  else send(pl,acts(pl,"%a has defined the following actions:",plr)) end

  startpager(pl)

  for i,v in actl do
    local opt=""
    if atab["myact."..v..".u"] then opt=opt..", untargetted" end
    if atab["myact."..v..".t"] then opt=opt..", targetted" end
    if atab["myact."..v..".m"] then opt=opt..", multi-target" end
    if atab["myact."..v..".o"] then opt=opt..", object targetted" end
    if atab["myact."..v..".p"] then opt=opt..", targetted with prop" end
    if atab["myact."..v..".x"] then opt=opt..", text" end
    if atab["myact."..v..".s"] then opt=opt..", targetted text" end

    opt=strsub(opt,3)

    send(pl," "..v.." ("..opt..")")
  end

  return
end

if argc<2 then
  send(pl,"Syntax: ^Wmyact do ^b<^Baction^b> <^Btarget^b>^n")
  send(pl,"    or: ^Wmyact show ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact dump ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact get ^b<^Baction^b> [^Bplayer^b]^n")
  send(pl,"    or: ^Wmyact erase ^b<^Baction^b> <^Btype^b>^n")
  send(pl,"    or: ^Wmyact add ^b<^Baction^b> <^Btype^b> <^Bstring^b>^n")
  send(pl,"Where ^Btype^n is one of ^Wunt^n, ^Wtarg^n, ^Wmult^n, ^Wtext^n, ^Wttext^n, ^Wprop^n, or ^Wobj^n, and ^Baction ^nis the name of a personalised action.")
  return
end

local au=getstr(pl,"myact."..arg[2]..".u")
local at=getstr(pl,"myact."..arg[2]..".t")
local am=getstr(pl,"myact."..arg[2]..".m")
local ao=getstr(pl,"myact."..arg[2]..".o")
local ap=getstr(pl,"myact."..arg[2]..".p")
local app=getstr(pl,"myact."..arg[2]..".pp")
local ax=getstr(pl,"myact."..arg[2]..".x")
local as=getstr(pl,"myact."..arg[2]..".s")
local axe=getstr(pl,"myact."..arg[2]..".xe")
local ase=getstr(pl,"myact."..arg[2]..".se")

if arg[1]=="do" then
  if not (au or at or am or ao or ap or ax or as) then
    send(pl,"You have not defined a personal action called ^W"..arg[2].."^n.")
    return
  end

  if getflag(pl,flag.Sleeping) then
    act(pl,"%1 %[rolls/roll] over and %[drools/drool] in %4 sleep.")
    return
  end

  local ttab={}
  for i=3,argc do
    ttab[i-2]=arg[i]
  end

  local wtab=match(pl,ttab)

  if am then
    local tcount=0
    ttab={}

    for i,v in wtab do
      --send(pl,getstr(v,"name"))
      if person(v) then
        tcount=tcount+1
        ttab[tcount]=v
        set(v,"!myact.mtarget",1)
      end
    end

    if tcount<1 then
      send(pl,"You must supply players or mobiles as targets.")
      return
    end

    local tstr=""
    for i=1,tcount do
      local tname=getstr(ttab[i],"name")
      if tname then
        tstr=tstr..tname
        if i==tcount-1 then tstr=tstr.." and "
        elseif i~=tcount then tstr=tstr..", " end
      end
    end

    local gstring=gsub(am,"%%t",tstr)

    for i,v in children(owner(pl)) do
      if person(v) and v~=pl then 
        if !getint(v,"!myact.mtarget") then send(v,acts(pl,gstring))
        else
          tstr=getstr(v,"name")
          local npat=gsub(tstr,"%^","%%^")
          tstr=gsub(gstring,npat,"%%a")
          send(v,acts2(v,pl,tstr,v))
          unset(v,"!myact.mtarget")
        end
      end
    end

    send(pl,acts2(pl,pl,gstring))
    return
  end

  local ptab={}
  local atg=nil
  local prp=nil

  if app then 
    ptab=matchprep(pl,ttab,app) 

    if app=="with" then
      if getn(wtab)>1 then
        send(pl,"Please supply a single target.")
        return
      end
      if getn(ptab)>1 then
        send(pl,"Please supply a single prop.")
        return
      end
      atg=wtab[1]
      prp=ptab[1]
    else
      if getn(ptab)>1 then
        send(pl,"Please supply a single target.")
        return
      end
      if getn(wtab)>1 then
        send(pl,"Please supply a single prop.")
        return
      end
      atg=ptab[1]
      prp=wtab[1]
    end
    if argc<4 and arg[4]==app then
      if app=="with" then send(pl,"With what?")
      else send(pl,capitalise(app).." who?") end
      return
    end
    if !(atg or prp) and arg[4]==app then
      if !atg then
        if app=="with" then send(pl,"Cannot identify target "..arg[3]..".")
        else send(pl,"Cannot identify target "..arg[5]..".") end
        return
      end
      if !prp then
        if app=="with" then send(pl,"Cannot identify prop "..arg[3]..".")
        else send(pl,"Cannot identify prop "..arg[5]..".") end
        return
      end
    end
    if argc>4 and arg[4]~=app then
      if app==with then send(pl,"Expected: ^W"..arg[2].." ^b<^Bwho^b> ^Wwith ^b<^Bwhat^b>^n")
      else send(pl,"Expected: ^W"..arg[2].." ^b<^Bwhat^b> ^W"..app.." ^b<^Bwho^b>^n") end
      return
    end
    if atg and prp then
      if !person(atg) then
        send(pl,"Target must be a person.")
        return
      end
      if person(prp) then
        send(pl,"Prop must be an object.")
        return
      end
    end
  else
    atg=wtab[1]
  end

  if arg[3] and !atg then 
    atg=get(arg[3])
    if !atg then atg=matchplayer(pl,arg[3]) end
  end
  if arg[5] and !prp then prp=get(arg[5]) end

  if !arg[3] then
    if !au then
      send(pl,"You don't have an untargetted version of ^W"..arg[2].."^n.")
      return
    end

    act(pl,au)
    return
  end

  local plr=atg
  atg=arg[3]

  local atl=strlen(atg)
  local spl=matchplayer(pl,strsub(atg,1,atl-1))
  local puc=strsub(arg[3],atl)

  if ax and (!as or !(spl and puc=='>')) then
    local t=congeal(3)
    if t=="" then
      send(pl,axe)
      return
    end

    act(pl,ax,nil,nil,drunkify(pl,t))
    return
  end

  if !(plr) then
    atg=match(pl,{atg})
    atg=atg[1]
  else atg=plr end
  
  if !atg then
    if !ase then
      send(pl,"That isn't a valid target.")
      return
    elseif ase and !(spl and puc=='>') then
      send(pl,ase)
      return
    end
  end

  if atg then plr=atg else plr=spl end

  if pl==plr then
    send(pl,"You can't do that to yourself.")
    return
  end

  if getflag(pl,flag.Aloof) then
    send(pl,"You can't use targetted actions when you are aloof.")
    return
  end

  if getflag(plr,flag.Aloof) then
    send(pl,"You can't do that to an aloof target.")
    return
  end

  if as then
    if !spl or !(person(spl) and puc=='>') then
      send(pl,"Targetted text actions expect arguments of the form ^Wtarget> text^n.")
      return
    end

    local t=congeal(4)
    if t=="" then
      send(pl,axe)
      return
    end

    act(pl,as,spl,nil,drunkify(pl,t))
    return
  end

  if person(atg) then
    if !at and !as and !ap then
      send(pl,"You don't have a targetted version of ^W"..arg[2].."^n.")
      return
    end

    if getint(pl,"invis")>privs(plr) then
      send(pl,"You aren't visible to "..getstr(plr,"name"))
      return
    end

    if prp then
      if !ap then
        send(pl,"You don't have a targetted version of ^W"..arg[2].."^n that supports props.")
        return
      end

      act(pl,ap,atg,prp)
    else 
      if !at then
        send(pl,"You don't have a targetted version of ^W"..arg[2].."^n.")
        return
      end

      act(pl,at,atg)
    end
    return
  else
    if !ao then
      send(pl,"You don't have an object targetted version of ^W"..arg[2].."^n.")
      return
    end

    act(pl,ao,atg)
    return
  end

  return
end

if arg[1]=="show" then
  local plr=pl

  if arg[3] then
    plr=matchplayer(pl,arg[3])
    if !plr then
      send(pl,"Invalid target for show.")
      return
    end
    au=getstr(plr,"myact."..arg[2]..".u")
    at=getstr(plr,"myact."..arg[2]..".t")
    am=getstr(plr,"myact."..arg[2]..".m")
    ao=getstr(plr,"myact."..arg[2]..".o")
    ap=getstr(plr,"myact."..arg[2]..".p")
    ax=getstr(plr,"myact."..arg[2]..".x")
    as=getstr(plr,"myact."..arg[2]..".s")
  end
    
  if not (au or at or am or ao or ap or ax or as) then
    if plr==pl then send(pl,"You have not defined a personal action called ^W"..arg[2].."^n.")
    else send(pl,acts(pl,"%a has not defined a personal action called ^W"..arg[2].."^n.",plr)) end
    return
  end

  if au then send(pl,"Untargetted       : "..acts(plr,au)) end
  if at then send(pl,"Targetted         : "..acts(plr,at)) end
  if am then 
    local s=gsub(am,"%%t","[all targets]")
    send(pl,"Multi-target      : "..acts(pl,s))
  end
  if ao then send(pl,"Object targetted  : "..acts(plr,ao)) end
  if ap then send(pl,"Targetted w/prop  : "..acts(plr,ap)) end
  if ax then
    local s=gsub(ax,"%%s","[some text]")
    send(pl,"Text              : "..acts(pl,s))
  end
  if as then 
    local s=gsub(as,"%%s","[some text]")
    send(pl,"Targetted text    : "..acts(pl,s))
  end

  return
end

if arg[1]=="dump" then
  local filt=function(str)
    local s=gsub(str,"%^","%^%^")
    s=gsub(s,"%^(%^[%u%l])","%^%1%1")
    s=gsub(s,"&([=%-])","&&%1")
    return s
  end
  local plr=pl

  if arg[3] then
    plr=matchplayer(pl,arg[3])
    if !plr then
      send(pl,"Invalid target for show.")
      return
    end
    au=getstr(plr,"myact."..arg[2]..".u")
    at=getstr(plr,"myact."..arg[2]..".t")
    am=getstr(plr,"myact."..arg[2]..".m")
    ao=getstr(plr,"myact."..arg[2]..".o")
    ap=getstr(plr,"myact."..arg[2]..".p")
    ax=getstr(plr,"myact."..arg[2]..".x")
    as=getstr(plr,"myact."..arg[2]..".s")
  end
    
  if not (au or at or am or ao or ap or ax or as) then
    if plr==pl then send(pl,"You have not defined a personal action called ^W"..arg[2].."^n.")
    else send(pl,acts(pl,"%a has not defined a personal action called ^W"..arg[2].."^n.",plr)) end
    return
  end

  if au then send(pl,"Untargetted       : "..filt(au)) end
  if at then send(pl,"Targetted         : "..filt(at)) end
  if am then send(pl,"Multi-target      : "..filt(am)) end
  if ao then send(pl,"Object targetted  : "..filt(ao)) end
  if ap then send(pl,"Targetted w/prop  : "..filt(ap)) end
  if ax then send(pl,"Text              : "..filt(ax)) end
  if as then send(pl,"Targetted text    : "..filt(as)) end

  return
end

if arg[1]=="erase" then
  if not (au or at or am or ao or ap or ax or as) then
    send(pl,"You don't have an action called ^W"..arg[2].."^n.")
    return
  end

  if argc<3 then
    unset(pl,"myact."..arg[2]..".u")
    unset(pl,"myact."..arg[2]..".t")
    unset(pl,"myact."..arg[2]..".m")
    unset(pl,"myact."..arg[2]..".o")
    unset(pl,"myact."..arg[2]..".p")
    unset(pl,"myact."..arg[2]..".pp")
    unset(pl,"myact."..arg[2]..".x")
    unset(pl,"myact."..arg[2]..".xe")
    unset(pl,"myact."..arg[2]..".s")
    unset(pl,"myact."..arg[2]..".se")
    send(pl,"Erased personal action ^W"..arg[2].."^n.")
    au=nil
    at=nil
    ao=nil
    am=nil
    as=nil
    ax=nil
    ase=nil
    axe=nil
    ap=nil
    app=nil
  else
    if arg[3]~="unt" and arg[3]~="targ" and arg[3]~="obj" and arg[3]~="prop" and arg[3]~="text" and arg[3]~="ttext" then
      send(pl,"Action type must be ^Wunt^n, ^Wtarg^n, ^Wtext^n, ^Wttext^n, or ^Wobj^n.")
      return
    end

    if arg[3]=="unt" then
      if not au then
        send(pl,"You don't have an untargetted version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".u")
      send(pl,"Erased untargetted version of your personal action ^W"..arg[2].."^n.")
      au=nil
    end
  
    if arg[3]=="targ" then
      if not at then
        send(pl,"You don't have an targetted version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".t")
      send(pl,"Erased targetted version of your personal action ^W"..arg[2].."^n.")
      at=nil
    end
  
    if arg[3]=="mult" then
      if not am then
        send(pl,"You don't have a multi-target version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".m")
      send(pl,"Erased multi-target version of your personal action ^W"..arg[2].."^n.")
      at=nil
    end

    if arg[3]=="obj" then
      if not au then
        send(pl,"You don't have an object targetted version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".u")
      send(pl,"Erased object targetted version of your personal action ^W"..arg[2].."^n.")
      ao=nil
    end

    if arg[3]=="prop" then
      if not au then
        send(pl,"You don't have an targetted version of ^W"..arg[2].."^n that supports props.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".p")
      unset(pl,"myact."..arg[2]..".pp")
      send(pl,"Erased targetted with prop version of your personal action ^W"..arg[2].."^n.")
      ap=nil
      app=nil
    end

    if arg[3]=="text" then
      if not ax then
        send(pl,"You don't have an text version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".x")
      unset(pl,"myact."..arg[2]..".xe")
      send(pl,"Erased text version of your personal action ^W"..arg[2].."^n.")
      ax=nil
    end

    if arg[3]=="ttext" then
      if not ax then
        send(pl,"You don't have an targetted text version of ^W"..arg[2].."^n.")
        return
      end
  
      unset(pl,"myact."..arg[2]..".s")
      unset(pl,"myact."..arg[2]..".se")

      if !getstr(pl,"myact."..arg[2]..".x") then
        unset(pl,"myact."..arg[2]..".xe")
      end

      send(pl,"Erased targetted text version of your personal action ^W"..arg[2].."^n.")
      ax=nil
    end
  end

  if not(ao or ap or au or at or am or ax or as) and getstr(pl,"alias."..arg[2]) then
    interpret(pl,"alias "..arg[2])
  end
  return
end

if arg[1]=="get" then
  if argc<3 then
    send(pl,"You need to supply the name of the person you wish to obtain the action from.")
    return
  end

  local src=matchplayer(pl,arg[3])

  if !src then
    send(pl,"That is not a valid source.")
    return
  end

  local nau=getstr(src,"myact."..arg[2]..".u")
  local nat=getstr(src,"myact."..arg[2]..".t")
  local nam=getstr(src,"myact."..arg[2]..".m")
  local nao=getstr(src,"myact."..arg[2]..".o")
  local nap=getstr(src,"myact."..arg[2]..".p")
  local napp=getstr(src,"myact."..arg[2]..".pp")
  local nax=getstr(src,"myact."..arg[2]..".x")
  local nas=getstr(src,"myact."..arg[2]..".s")
  local naxe=getstr(src,"myact."..arg[2]..".xe")
  local nase=getstr(src,"myact."..arg[2]..".se")

  if !(nau or nat or nam or nao or nap or nax or nas) then
    send(pl,"That person does not have a personal action called ^W"..arg[2].."^n.")
    return
  end

  if (au and at and am and ao and ap) or (ax and as) then
    send(pl,"You already have a fully defined action called ^W"..arg[2].."^n. Erase it if you want to replace it with a new version.")
    return
  end

  if (au or at or am or ao or ap) and (nax or nas) then
    send(pl,"You have already defined ^W"..arg[2].."^n as a standard action. The version you are trying to acquire is a text action. Erase your copy if you want to replace it with the other version.")
    return
  end

  if (ax or as) and (nat or nau or nam or nao or nap) then
    send(pl,"You have already defined ^W"..arg[2].."^n as a text action. The version you are trying to acquire is a standard action. Erase your copy if you want to replace it with the other version.")
    return
  end

  local mod=0

  if (au or at or am or ao or ap or ax or as) then
    send(pl,acts(pl,"Attempting to copy action from %a.",src))
  else
    send(pl,"Creating new action ^W"..arg[2].."^n.")
    mod=10
  end

  if !au and nau then
    send(pl,"Added untargetted version.")
    set(pl,"myact."..arg[2]..".u",nau)
    mod=mod+1
  end

  if !at and nat then
    send(pl,"Added targetted version.")
    set(pl,"myact."..arg[2]..".t",nat)
    mod=mod+1
  end

  if !am and nam then
    send(pl,"Added multi-target version.")
    set(pl,"myact."..arg[2]..".m",nam)
    mod=mod+1
  end

  if !ao and nao then
    send(pl,"Added object targetted version.")
    set(pl,"myact."..arg[2]..".o",nao)
    mod=mod+1
  end

  if !ap and nap then
    send(pl,"Added targetted with prop version.")
    set(pl,"myact."..arg[2]..".p",nap)
    set(pl,"myact."..arg[2]..".pp",napp)
    mod=mod+1
  end

  if !ax and nax and naxe then
    send(pl,"Added untargetted text version.")
    set(pl,"myact."..arg[2]..".x",nax)
    set(pl,"myact."..arg[2]..".xe",naxe)
    mod=mod+1
  end

  if !as and nas and nase and naxe then
    send(pl,"Added targetted text version.")
    set(pl,"myact."..arg[2]..".s",nas)
    set(pl,"myact."..arg[2]..".se",nase)
    set(pl,"myact."..arg[2]..".xe",naxe)
    mod=mod+1
  end

  if mod==0 or mod==10 then
    send(pl,"No new versions of ^W"..arg[2].."^n were added. If you wish to update your action, you will need to erase some parts of it first.")
    return
  end

  if mod>10 then
    local aal=getstr(pl,"alias."..arg[2])

    if aal and aal~="myact do "..arg[2] then
      send(pl,"You already have an alias called ^W"..arg[2].."^n. You will either need to make your own alias, or use the full command \"myact do "..arg[2].."\" in order to invoke this action.")
      return
    end

    if aal=="myact do "..arg[2] then return end
 
    send(pl,"Creating an alias to your new action. Just type "..arg[2].." to use it.")
    interpret(pl,"alias "..arg[2].." myact do "..arg[2])
    return
  end

  send(pl,"Action imported sucessfully.")

  return
end

if argc<3 then
  send(pl,"you need to supply an action type; ^Wunt^n, ^Wtarg^n, ^Wmult^n, ^Wprop^n, ^Wtext^n, ^Wttext^n, or ^Wobj^n.")
  return
end

if arg[3]~="unt" and arg[3]~="targ" and arg[3]~="mult" and arg[3]~="obj" and arg[3]~="prop" and arg[3]~="text" and arg[3]~="ttext" then
  send(pl,"Action type must be ^Wunt^n, ^Wtarg^n, ^Wtext^n, ^Wttext^n, ^Wprop^n, or ^Wobj^n.")
  return
end

if argc<4 then
  send(pl,"You need to supply an action string.")
  return
end

if !strfind(arg[4],"%1",1,1) then
  send(pl,"The action must start with %1.")
  return
end

local newact=nil
if not (au or at or am or ao or ap or ax or as) then newact=1 end


if arg[3]=="unt" then
  if au then
    send(pl,"You already have an untargetted version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (as or ax) then
    send(pl,"You have text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a standard action.")
    return
  end

  au=congeal(4)

  set(pl,"myact."..arg[2]..".u",au)
  send(pl,"Adding untargetted version of ^W"..arg[2].."^n.")
end

if arg[3]=="targ" then
  if at then
    send(pl,"You already have a targetted version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (as or ax) then
    send(pl,"You have text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a standard action.")
    return
  end

  at=congeal(4)

  set(pl,"myact."..arg[2]..".t",at)
  send(pl,"Adding targetted version of ^W"..arg[2].."^n.")
end

if arg[3]=="mult" then
  if at then
    send(pl,"You already have a multi-target version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (as or ax) then
    send(pl,"You have text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a standard action.")
    return
  end

  am=congeal(4)

  set(pl,"myact."..arg[2]..".m",am)
  send(pl,"Adding multi-target version of ^W"..arg[2].."^n.")
end

if arg[3]=="obj" then
  if ao then
    send(pl,"You already have an object targetted version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (as or ax) then
    send(pl,"You have text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a standard action.")
    return
  end

  ao=congeal(4)

  set(pl,"myact."..arg[2]..".o",ao)
  send(pl,"Adding object targetted version of ^W"..arg[2].."^n.")
end

if arg[3]=="prop" then
  if ap then
    send(pl,"You already have an targetted version of ^W"..arg[2].."^n which supports props. You'll need to erase it before you can replace it.")
    return
  end

  if (as or ax) then
    send(pl,"You have text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a standard action.")
    return
  end

  ap=congeal(4)

  set(pl,"myact."..arg[2]..".p",ap)
  send(pl,"Adding targetted with prop version of ^W"..arg[2].."^n.")
end

if arg[3]=="text" then
  if ax then
    send(pl,"You already have an text version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (au or at or am or ao or ap) then
    send(pl,"You have non-text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a text action.")
    return
  end

  ax=congeal(4)

  set(pl,"myact."..arg[2]..".x",ax)
  set(pl,"myact."..arg[2]..".xe","You need to supply some text to ^W"..arg[2].."^n.")
  send(pl,"Adding text version of ^W"..arg[2].."^n.")
end

if arg[3]=="ttext" then
  if as then
    send(pl,"You already have an targetted text version of ^W"..arg[2].."^n. You'll need to erase it before you can replace it.")
    return
  end

  if (au or at or am or ao or ap) then
    send(pl,"You have non-text components in ^W"..arg[2].."^n. You will need to remove those before you can make it a targetted text action.")
    return
  end

  as=congeal(4)

  set(pl,"myact."..arg[2]..".s",as)
  set(pl,"myact."..arg[2]..".xe","You need to supply some text to ^W"..arg[2].."^n.")
  set(pl,"myact."..arg[2]..".se","You need to supply a target to ^W"..arg[2].."^n.")
  send(pl,"Adding targetted text version of ^W"..arg[2].."^n.")
end

if !newact then return end

local aal=getstr(pl,"alias."..arg[2])

if aal and aal~="myact do "..arg[2] then
  send(pl,"You already have an alias called ^W"..arg[2].."^n. You will either need to make your own alias, or use the full command \"myact do "..arg[2].."\" in order to invoke this action.")
  return
end

if aal=="myact do "..arg[2] then return end

send(pl,"Creating an alias to your new action. Just type "..arg[2].." to use it.")
interpret(pl,"alias "..arg[2].." myact do "..arg[2])