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".
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:
setBOS()
print(charges,BagoSend)