Simple math question

Posted by Siris on Tue 14 Sep 2010 03:50 PM — 5 posts, 23,147 views.

#0
I'm trying to make an auto bid alias to increase the current bid by a minimum bid.

<triggers>
  <trigger
   enabled="y"
   group="AucBot"
   ignore_case="y"
   keep_evaluating="y"
   match="^AUCTION\: .*? bids (.+?) gp on .*?\.$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Note ("%1")--debug
bid=%1
Replace (bid, ",", "", true)
mybid=bid+500
print (mybid)--debug</send>
  </trigger>
</triggers>

However it does this:

AUCTION: Filius bids 1,150,420 gp on a counterfeit manual.
1,150,420
501

AUCTION: Filius bids 50,420 gp on a counterfeit manual.
50,420
550

AUCTION: Filius bids 420 gp on a counterfeit manual.
420
920

I cant seem to get it to function with the "," separator, I can only assume I'm missing something very simple.

I would also like to add an alias that would expand the variable "mybid" to the mud.
Finland #1

test = "13,500,243"

bid = string.gsub (test, ",", "")
bid = tonumber (bid)
Note (bid)
Note (bid+100)


This is not the most elegant way to do it but it should work.

string.gsub kills the ,'s and then tonumber makes it a value instead of a string.
USA #2
The issue is this line:
bid=%1

When the number is 15,500,243, you get:
bid=15,500,243

This is Lua's syntax for multiple assignment. Since you only have one variable on the left side, only the first comma-separated value - the number 15 - is assigned to bid. The others are discarded.

Henry's solution is what I would do here.
bid = tonumber(string.gsub("%1", ",", ""))
#3
Thank you, its working as planned now, however how do I make an alias that expands the variable to the client?
IE:
alias abid
sends Auction Bid (Mybid)
mybid being the variable set by the trigger.
Australia Forum Administrator #4

<aliases>
  <alias
   match="abid"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("Auction Bid ", mybid)

</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.