Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ Simple math question
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Siris
(17 posts) Bio
|
Date
| Tue 14 Sep 2010 03:50 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Henry Tanner
Finland (23 posts) Bio
|
Date
| Reply #1 on Tue 14 Sep 2010 04:29 PM (UTC) |
Message
|
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. |
I got this! | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #2 on Tue 14 Sep 2010 06:37 PM (UTC) |
Message
| The issue is this line:
When the number is 15,500,243, you get:
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", ",", ""))
|
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Siris
(17 posts) Bio
|
Date
| Reply #3 on Wed 15 Sep 2010 06:55 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #4 on Wed 15 Sep 2010 11:18 PM (UTC) |
Message
|
<aliases>
<alias
match="abid"
enabled="y"
send_to="12"
sequence="100"
>
<send>
Send ("Auction Bid ", mybid)
</send>
</alias>
</aliases>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
16,892 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top