Quick Coding Questions
Comments
-
Sobriquet said:Could someone explain the significance of the letters in: "for i,v in pairs" Or when k,v is mentioned?
for k in pairs (blah) doCurrent scripts: GoldTracker 1.2, mData 1.1
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.0 -
Trevize said: forumsSobriquet said:Could someone explain the significance of the letters in: "for i,v in pairs" Or when k,v is mentioned?
for k in pairs (blah) do
for _,v in ipairs(tbl) do ...1 -
Eld said:Trevize said: forumsSobriquet said:Could someone explain the significance of the letters in: "for i,v in pairs" Or when k,v is mentioned?
for k in pairs (blah) do
for _,v in ipairs(tbl) do ...
Huh. Neat.0 -
-
Amranu said:ipairs gives you the entry number and the key, pairs gives you the key name and value.
Basically ipairs should be used on a table acting as an array, eg { "Blah1", "Blah2" } whereas pairs should be used on a dictionary/hash format eg { ["Blah"] = "Blah", ["Blah2"] = "Blah2" }
Huh. Neat.0 -
Ahmet said:Amranu said:ipairs gives you the entry number and the key, pairs gives you the key name and value.
Basically ipairs should be used on a table acting as an array, eg { "Blah1", "Blah2" } whereas pairs should be used on a dictionary/hash format eg { ["Blah"] = "Blah", ["Blah2"] = "Blah2" }Current scripts: GoldTracker 1.2, mData 1.1
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.1 -
Is denyCurrentSend not included in any of the online Mudlet wiki documentation? All I've found is a reference to it on the details for the sysDataSendRequest event, but nothing about the actual function itself.
Which brings me to my actual question: Is there an event raised when a command is denied?
0 -
No. To quote the wiki:
Note: if you'll be making use of denyCurrentSend(), you really should notify the user that you denied their command - unexperienced ones might conclude that your script or Mudlet is buggy if they don't see visual feedback. Do not mis-use this and use it as keylogger either
But you can overwrite denyCurrentSend to fire an event like this:
local origCurrentSend = denyCurrentSend
denyCurrentSend = function(what)
raiseEvent("sysDenyCurrentSendEvent", what)
origCurrentSend()
endThis new denyCurrentSend can then also be given the actual command that was denied (which in urn ands it as an argument to he event handlers)
My Bashing script: http://achaeabashingScript.github.io/Bashing/
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof1 -
I cant seem to capture the rage number gained from the prompt..can anyone give me the correct perl reg format?
I want to create a Rage Gauge0 -
Kind of depends on exactly what your prompt is set to; with custom prompts in-game there's a ton of potential options. Rage itself should just be a number, so you'd need (\d+) for that part of the prompt, but you'd also need the pattern to match the rest. That said, you can get Rage from GMCP, something like this:
function getRage() for _, stat in ipairs(gmcp.Char.Vitals.charstats) do if string.starts(stat, "Rage") then return tonumber(string.match(stat, "(%d+)")) end end
0 -
@Keneanung Forgot to reply at the time, but thanks. Unfortunately I'd need it for scripts I haven't written myself/don't want to start making changes to; if it was just a case of my own code I could raise the event at the same time as calling denyCurrentSend.
0 -
I'm not sure about implementation details, but if you subscribed to the sysDataSendRequest and checked somehow, if the event of above overwriting was fired in conjunction with the current event (ie directly after each other), you may be able to find out...My Bashing script: http://achaeabashingScript.github.io/Bashing/
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof0 -
Is anyone else having a problem where Wundersys is putting up mass/rebounding/hold breath upon switching profiles (from basic to combat) and classes (from dragon to serpent)? I've noticed that it puts those three on basic defup/keep up, but does not show on the WSHOW DEFUP/KEEPUP tables.0
-
Those three have their own thing with masson/rebon/br aliases.
0 -
Antonius said:
Kind of depends on exactly what your prompt is set to; with custom prompts in-game there's a ton of potential options. Rage itself should just be a number, so you'd need (\d+) for that part of the prompt, but you'd also need the pattern to match the rest. That said, you can get Rage from GMCP, something like this:
function getRage() for _, stat in ipairs(gmcp.Char.Vitals.charstats) do if string.starts(stat, "Rage") then return tonumber(string.match(stat, "(%d+)")) end end
Current scripts: GoldTracker 1.2, mData 1.1
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.0 -
The index could change at any time. Using a for loop is slower, but safer.
retired0 -
That works as long as the order of charstats doesn't change, or at least the position of the Rage entry doesn't. We've already seen with the addition of Rage there's no guarantee it won't change.
1 -
True. I suppose it could, but it hasn't in a very long time.Current scripts: GoldTracker 1.2, mData 1.1
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.0 -
I just use:
brage = tonumber(string.match(gmcp.Char.Vitals.charstats[2], "Rage: (%d+)"))
Index won't change, unless IRE physically changes it themselves, which is highly unlikely. (possible, but not very likely). Also kind of moot to say it's slower, given that it'll only be processed about 0.0001s (if that) slower than the above example.0 -
Kiet said:Those three have their own thing with masson/rebon/br aliases.1
-
@Dairon Yeah, I have that same problem but you might find better answers/support posting in the wsys thread. I handle the same way you do for now, just toggling them back off whenever I switch.
I have some nub questions about saving tables in external files:
Can you save more than one table per file (Seems like you can't)
Is this an intense process? Would it be terribly harmful if I had one function that saved all of my tables (Probably 4ish)?
0 -
You can put all your tables in another table and save that. On loading, you will need to restore each into their original place manually thoughMy Bashing script: http://achaeabashingScript.github.io/Bashing/
GMCP documentation: https://github.com/keneanung/GMCPAdditions
svof github site: https://github.com/svof/svof and documentation at https://svof.github.io/svof1 -
Medi said:
I have some nub questions about saving tables in external files:
Can you save more than one table per file (Seems like you can't)
Is this an intense process? Would it be terribly harmful if I had one function that saved all of my tables (Probably 4ish)?
Me and Soludra, goofing off, even found a way in MUSHclient to serialize functions. (I'm FadedParadox, he's Twisol) http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=9512 - I haven't done that in Mudlet yet though, storing functions is more of a fun exercise than actually useful.
Current scripts: GoldTracker 1.2, mData 1.1
Site: https://github.com/trevize-achaea/scripts/releases
Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.1 -
Is it possible to put an echolink into a party chat? For instance a room number
And how?0 -
Gamden said:Is it possible to put an echolink into a party chat? For instance a room number
And how?0 -
I was hoping to find a way to find the string.length of the line ABOVE the current one.
Is it possible to do this by moveCursor?
moveCursor(0, getLineNumber()-1)
-- somehow select the string and then do
llength = string.len(matches[1])
deselect()
moveCursorEnd()
0 -
Maybe like this:
moveCursor(0, getLineNumber() - 1)
local length = #getCurrentLine()
moveCursorEnd()
-- Do stuff with the 'length' variable hereretired0 -
That fixed it, thanks!0
Categories
- 6K All Categories
- 3K Everything Achaea
- 1.5K North of Thera
- 21 Archives of the Terraformer
- 241 The Matsuhama Arena
- 873 The Golden Dais of Creation
- 283 The Scarlattan Theatre
- 144 The Blank Canvas
- 1.9K Getting Help
- 391 General Questions
- 247 Quick Class Questions
- 1.3K Tech Support
- 298 Client Help
- 456 Curing Systems and Scripts
- 829 Off-Topic
- 250 The Wander Inn
- 579 The Universal Membrane
- 281 Class Discussions
- 281 Individual Class Sections
- 20 Alchemist
- 8 Apostate
- 29 Blademaster
- 9 Depthswalker
- 12 Druid
- 4 Infernal
- 20 Jester
- 19 Magi
- 30 Monk
- 9 Occultist
- 7 Paladin
- 7 Priest
- 28 Runewarden
- 18 Sentinel
- 24 Serpent
- 19 Shaman
- 9 Sylvan