ScriptUO

Scripting Resources & Utilities => OpenEUO Scripts => OEUO => OEUO Snippets => Topic started by: Superslayer on October 21, 2010, 05:38:52 PM

Title: Bag of Sending setup function
Post by: Superslayer on October 21, 2010, 05:38:52 PM
This function brings up a target cursor and first checks if the target is actually a bag of sending by looking for the string "Sending" in the bag name.  Will return 'nil' if it does not. Otherwise the script will set variables to the id of the bag, "BagoSend" and number of charges to "charges".

Code: [Select]
function setBOS() 
  UO.TargCurs = true
  while UO.TargCurs == true do
    wait(100)
  end
  lasttargid = UO.LTargetID 
  stra,strb = UO.Property(lasttargid) 
  strmatch = string.find(stra,"Sending")
  if strmatch == nil then
    return(strmatch) -- not a bag of sending, returns nil
  end 
  BagoSend = UO.LTargetID
  strmatch = string.match(strb,"(s:...)")  -- 10 or more charges   
  if strmatch ~= nil then
    charges = (strmatch:match("..$"))
    return(charges .. BagoSend)
  end
  if strmatch == nil then
    strmatch = string.match(strb,"(s:..)")  -- 9 or less charges
    charges = (strmatch:match(".$"))
    return(charges .. BagoSend)
  end
end

test with this:

Code: [Select]
setBOS()
print(charges,BagoSend)