Author Topic: Bag of Sending setup function  (Read 4532 times)

0 Members and 1 Guest are viewing this topic.

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Bag of Sending setup function
« on: October 21, 2010, 05:38:52 PM »
0
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)

Tags: