Just to promote the clan again(I think), for anyone that knows how to code Lua and is good with mudlet, or even new users, or people with questions about it. The Mudlet clan is available to anyone who wishes to join. There are already a decent amount of people that know what they're doing, and people still learning. But the clan is here for mudlet chat, so join up if ya want.
Edit: Anyone with the mudlet clan in their honours can invite.
@Iniar do you know if this script actually works for voting on TMS? It says "Successful!" and all, but a dump of the traffic is markedly different from what I get when I successfully vote through the webpage process of voting. The response in particular is completely different from the response on the webpage. (The script goes right back to the 'click here to enter' page, whereas the weblink uses a 301 redirect to the main page). I also notice a few other differences (the "oldhash" value not being passed, GET vs POST). I'd hate for people to be using this thinking they were voting, but their votes not being counted.
@Nyoka, that line is generated by the game when, among other things, you send the "voted" command (which the script does right after the "Successful!" message). The game can no more tell that TMS registered your vote than I can. My understanding of TMS is that they don't want people to know if their vote counted to avoid people (and games) from gaming their system.
@Iniar it looks like the script needs the "oldhash" line to work. With the script as modified above, the "voteDone.html" file is the vote webpage, not the TMS homepage or a redirect. When you add the "oldhash" it turns into a blank page, which I think is correct as the actual page being served is a redirect, and I don't think Mudlet follows the redirect. Here's what I have for the updated function with the "local votestring" modified and the "local oldhash" added:
function downloaded_file(_, filename)
if filename:match("votePage", 1, true) then
cecho("<white>.")
io.input(filename)
local s = io.read("*all")
-- local pzzzqaaz = string.match(s,'<input name="pzzzqaaz" type="hidden" value="(%x+)">')
local oldhash = string.match(s, '<input name="oldhash" type="hidden" value="(%x+)">')
cecho("<white>.")
local testid = string.match(s,'<input name="testid" type="hidden" value="(%x+)">')
cecho("<white>.")
local votehash = string.match(s,'<input type="hidden" name="votehash" value="(%x+)">')
cecho("<white>.")
local mudid = string.match(s,'<input type="hidden" name="mudid" value="(%d+)">')
cecho("<white>.")
local votestring = "http://www.topmudsites.com/vote.php?do=in" .."&oldhash=" ..oldhash .. "&testid=" .. testid .. "&mudid=" .. mudid .. "&votehash=" .. votehash
cecho("<white>.")
downloadFile(getMudletHomeDir().."/voteDone.html", votestring)
elseif filename:match("voteDone", 1, true) then
cecho("<lime_green>Successful!<white>)\n")
send("voted", false)
end
end
The LuaSocket library is a good choice for web transactions that include redirects. It allows full HTTP functionality in socket.http, and lets you do things like check the HTTP code. It also lets you specify POST vs GET, in cases where it matters.
LuaSocket is not included in Mudlet's default install, but can be added by placing the required files in Mudlet's load path.
To install Lua modules, just drop DLLs into any of the package.cpath locations or .lua files into the package.path locations, then load them via require. Or, drop them anywhere you want, modify package.cpath/package.path, and require.
@Eoghan -- although LuaSocket would be the smart way to go, if it will work without so many more people will make use of it, which is why I avoid dependencies like the plague. Still, I might make one just to be able to make sure the votes are being counted.
@Iniar -- You can do a data dump a few ways. The most robust would be to use a tool such as wireshark, but that is certainly not user friendly. An easier way to see what the data should be is to use Google Chrome and go to Tools->Developer Tools and then click on the "Network" tab. Then go through the vote process and you will see all the data being passed back and forth between your browser and the website. For the mudlet version, you can see some information by opening the votePage.html and voteDone.html files in your mudlet home directory. (Do "lua display(getMudletHomeDir())" to see the path, though I suspect for you on a Mac that it is ~/.config/mudlet/profiles/Imperian). votePage.html is the page sent by TMS when you start the process, and voteDone.html is the page that is returned when you vote. I believe voteDone.html should be blank as all that you get for that page is headers without content.
Okay. I’m having trouble coding a simple system to refill my
pipes. Everything seems to be working except for the trigger that’s supposed to
countdown my puffs. It simply won’t do the subtraction. I used, for
example, pipelist.linseedpuffs =
tonumber(matches[2]) to capture my numerical variables, and I've checked all my variables to insure they are getting captured correctly. I’m all but certain the problem lies below. I could be wrong, but this seems the best place to start.
Here is my perl regex trigger…
^Autocuring: smoke pipe with (\w+)$
NOTE: I also tried the following…
^You take a long drag off your pipe, filling your lungs with
(\w+) smoke.$
I'm using a package for Achaea to separate chat windows. It mostly works, I just had to tweak a few of the regex expressions to match Imperian's style. It's copying all says/tells/etc properly to the new window, as long as they're a single line.
How would I make it work with multi-line says/tells? I've tried googling a solution and nothing seems to work. An example of one such expression I'm using is:
Your best bet is to change your server side linewrap to 0. Imperian will send any tell or say as one line to Mudlet. Mudlet will regex this one line and then wrap it so it displays as a multi line.
As a followup to what @Cassius said, if you did not initialize the HealthP variable somewhere, it will be set to the value of 'nil', which is different from the value of true or false. So you might need to add something like If HealthP == nil or HealthP == false then ....
if HealthP == true send("autocuring priority mana") HealthP = false
else send("autocuring priority health") HealthP == true end
Doing it this way ensures that the alias will always do something, because if it fails that first test it will fall directly into the else segment with no further tests. This means that if you are in the else segment because you accidentally set HealthP to a value of "potato" for some reason, it will set HealthP to a proper value and get the setup working again.
Flipping the mana/health order is just so that the 'default' behavior is health priority; if HealthP == "potato", it will set priority to health.
"On the battlefield I am a god. I love war. The steel, the smell, the corpses. I wish there were more. On the first day I drove the Northmen back alone at the ford. Alone! On the second I carried the bridge! Me! Yesterday I climbed the Heroes! I love war! I… I wish it wasn’t over."
Yeah, I know the feeling...especially when I'm doing something for a one shot data gather that i'll rarely ever use again. I just throw in a bunch unitialized stuff that will get dropped when I log off...Though there are suppose to be ways to save variables in there current state on log out...I always found it to be buggy though...Granted that was like two years ago too.
Comments
SHADOWPLANT MAIDENHAIR EATEN
WHY?!?!?!
local votestring = "http://www.topmudsites.com/vote.php?" .. "&do=in" .. "&pzzzqaaz=" .. pzzzqaaz .. "&mudid=" .. mudid .. "&votehash=" .. votehash
local votestring = "http://www.topmudsites.com/vote.php?" .. "&do=in" .. "&testid=" .. testid .. "&mudid=" .. mudid .. "&votehash=" .. votehash
We think you're the best, NAME! Thanks for inspiring us every day!
I also get the same line when I use the script through an alias...
Okay. I’m having trouble coding a simple system to refill my pipes. Everything seems to be working except for the trigger that’s supposed to countdown my puffs. It simply won’t do the subtraction. I used, for example, pipelist.linseedpuffs = tonumber(matches[2]) to capture my numerical variables, and I've checked all my variables to insure they are getting captured correctly. I’m all but certain the problem lies below. I could be wrong, but this seems the best place to start.
Here is my perl regex trigger…
^Autocuring: smoke pipe with (\w+)$
NOTE: I also tried the following…
^You take a long drag off your pipe, filling your lungs with (\w+) smoke.$
And here is my code that is not working…
puff = matches[2]
if puff == linseed then
pipelist.linseedpuffs = pipelist.linseedpuffs – 1
elseif puff == lovage then
pipelist.lovagepuffs = pipelist.lovagepuffs – 1
else pipelist.laurelpuffs = pipelist.laurelpuffs – 1
end
if (pipelist.linseedpuffs < 1) or (pipelist.lovagepuffs < 1) or (pipelist.laurelpuffs < 1) then
expandAlias("packpipes")
end
if HealthP == false then
send("autocuring priority health")
cecho("\n<medium_violet_red>Health Priority!")
HealthP = true
elseif HealthP == true then
send("autocuring priority mana")
cecho("\n<orange_red>Mana Priority!")
HealthP = false
end
I'd flip it around and just do it like this:
if HealthP == true
send("autocuring priority mana")
HealthP = false
else
send("autocuring priority health")
HealthP == true
end
Doing it this way ensures that the alias will always do something, because if it fails that first test it will fall directly into the else segment with no further tests. This means that if you are in the else segment because you accidentally set HealthP to a value of "potato" for some reason, it will set HealthP to a proper value and get the setup working again.
Flipping the mana/health order is just so that the 'default' behavior is health priority; if HealthP == "potato", it will set priority to health.
"On the battlefield I am a god. I love war. The steel, the smell, the corpses. I wish there were more. On the first day I drove the Northmen back alone at the ford. Alone! On the second I carried the bridge! Me! Yesterday I climbed the Heroes! I love war! I… I wish it wasn’t over."
if not prioStuff then
send("autocuring priority health")
prioStuff = true
else
send("autocuring priority mana")
prioStuff = false
end
No need to initialise variables!