[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]  getting wildcard value into variable

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: getting wildcard value into variable
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
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 Burzmali   (10 posts)  [Biography] bio
Date Sun 24 Dec 2006 10:01 AM (UTC)  quote  ]
Message
Thanks again. I actually managed to get the first part figured out but the ability to combine strings and variables had eluded me.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Sun 24 Dec 2006 02:26 AM (UTC)  quote  ]
Message
Say Nick just levelled. That line will then read:


SetVariable ("lasttolevel", Nick)


However the variable Nick is nil. You really want to quote it:


SetVariable ("lasttolevel", "%2")


And further on you want:


Send ("say keep on truckin " .. justleveled .. ". Gratz!")


That concatenates a variable with some literal strings.

- Nick Gammon

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

Posted by Burzmali   (10 posts)  [Biography] bio
Date Sat 23 Dec 2006 08:23 PM (UTC)  quote  ]
Message
I am trying to capture a name from a trigger and then decide which action to take based on the name. The trigger match is the following:

^(.*?)The black stone guides(.*?)into gaining level (.*?)\!$

my attempt at a script is the following:

SetVariable ("lasttolevel", %2)
local justleveled = GetVariable ("lasttolevel")
if justleveled == "Burzmali" then
SetVariable ("clevel", %3)
else
Send ("say keep on truckin justleveled. Gratz!")
end

I am hoping the value of justleveled will be output by the say command not "justleveled" but i haven't got that far yet. I am getting the error:

[string "Trigger: "]:1: bad argument #2 to 'SetVariable' (string expected, got nil)
stack traceback:
[C]: in function 'SetVariable'
[string "Trigger: "]:1: in main chunk

what am i missing?
[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,203 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]