[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Simple math question

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Simple math question
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 15 Sep 2010 11:18 PM (UTC)  quote  ]
Message

<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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Siris   (17 posts)  [Biography] bio
Date Wed 15 Sep 2010 06:55 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Tue 14 Sep 2010 06:37 PM (UTC)  quote  ]
Message
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", ",", ""))

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Henry Tanner   Finland  (23 posts)  [Biography] bio
Date Tue 14 Sep 2010 04:29 PM (UTC)  quote  ]
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!
[Go to top] top

Posted by Siris   (17 posts)  [Biography] bio
Date Tue 14 Sep 2010 03:50 PM (UTC)  quote  ]
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.
[Go to top] 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.


1,460 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]