Better slash commands, and console printing#4
Better slash commands, and console printing#4lilyball wants to merge 3 commits intowildstarnasa:masterfrom
Conversation
Change /lua to evaluate and print an expression. With no args, it toggles the console. Add /dump to evaluate and inspect an expression. Currently depth-limited to 1. Remove the KeyDown events from the console, as they were causing e.g. ' to unexpectedly print.
Define a print() function for the duration of execution of code in the console. Change = to act as though print() were used, including handling multiple return values. Change inspect to behave similarly to /dump. Update /dump to print metatables for userdata.
|
Silly me, I posted from the wrong github account. The message again: I might actually pop in and take a look at these push requests. There are a couple of issues I've noticed just from skimming. |
There was a problem hiding this comment.
Ugh, sorry about the whitespace changes. Houston is not a very good editor (granted, I'm thrilled it exists at all, but its text editing behavior leaves a lot to be desired). I can clean this up if you want.
|
I mean, just quickly off the top -
|
They're local functions. All the methods start with a capital letter.
Because it's a PITA to handle multiple results from a generic function. You could use The alternative is to write a single helper function that looks like function collectResults(...)
local t = { ... }
t.n = select('#', ...)
return t
endand that way you can then work with a table representation of the results that actually contains the count as well, but that's not really any better (especially because you can't e.g. iterate over the table with |
|
Take a look at drafto_LuaUtils.lua. There is a Pack(...) method already. |
|
I see. I had not looked at drafto_LuaUtils.lua. And you think stuffing it into a table like that is better than the nested function approach? |
|
The nested functions struck me as quite strange. So yes, I think packing into a table is better ;) EDIT: Wrong github account again, darnit. This is draftomatic >.< |
|
Nested functions aren't really that unusual, but I get that you just may not be used to that style. As it's your project, I will go ahead and update it to use |
Instead of using a nested varargs function, use LuaUtils:Pack() to produce a table for the varargs.
|
@draftomatic Updated to use |
|
Sorry for the long delay, I was expecting @draftomatic to get back to this but I guess he's busy. @kballard I haven't had much chance to look at this or how it would need to be changed to be compatible with the current version. As a note I won't be able to respond until 9/2/14 as I'm travelling until then. |
Improve the slash commands, so
/luawill evaluate expressions, and/dumpwill inspect them.Update the console support to define a
print()for expressions to print to the console (only while evaluating code in the console), and makeinspectwork like/dump.