-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better print
function
#2691
Better print
function
#2691
Conversation
Removed that 256 limit on number of arguments passed. I doubt anyone will go over it but that limit was pointless now that you can print more than 256 chars. toString methods that are called now have their initial opcosts added upon being used inside print(...) print(...) has base cost of 40 ops now.
To avoid ugly unquoted string, and default angle/vector output
@@ -414,7 +414,7 @@ e2function vector angle:up() | |||
end | |||
|
|||
e2function string toString(angle a) | |||
return ("[%s,%s,%s]"):format(a[1],a[2],a[3]) | |||
return ("ang(%d,%d,%d)"):format(a[1], a[2], a[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be %f
e2function string toString(vector v) | ||
return ("[%s,%s,%s]"):format(v[1],v[2],v[3]) | ||
return ("vec(%.2f,%.2f,%.2f)"):format(v[1], v[2], v[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking precision away might not be favorable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a second argument to the function for a rounding decimal place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought two digits of precision was fine, if they want incredible precision they could just print the individual digits.
Alternatively could use %g
.
And print already had this output, this is just replacing toString's output with it.
Possible option to have a global print function? |
Need a rewritten version of https://github.com/Vurv78/VExtensions/blob/master/lua/entities/gmod_wire_expression2/core/custom/sv_printglobal.lua and would need to be opt-in |
instead of opt-in because most people can't even edit an e2 line, what about a command similar to wire_holograms_block_client? and print globals show the user sending in console. |
Would absolutely need to be opt in serverside or would be so nerfed it would be practically unusable, with a long cooldown, preventing more than like 5 lines, adding [E2] before every message, etc Clientside can be opt out yes printDriver already has a disclaimer system for the first time it's used on a person so likely that would need to happen here too |
I think it looks fine. I think this will still net overflow people if they print too much though. |
Assuming you're talking about the repo I linked and not this, considering the limit is only ~4x higher by default now |
I mean its not rate limited so doing a bunch of prints will overflow the buffer eventually. |
Prints do have a burst cooldown, can always tweak it a bit if needed |
Ah I forgot about the cooldown. Does the cooldown throw? I always hated that it made debugging confusing sometimes because it would fail to print due to it. |
Yeah I asked in the discord and iirc feedback was that it'd be really bad for debugging having to wrap everything in try catch. Although with these larger limits it shouldn't be as common. |
wire_expression2_print_max_length
(Default 1,000)wire_expression2_print_max_length
(Default 10,000)print
now uses the e2 types (rather than lua type) of the argument to locate anytoString
methods for the type, if any are found, they will be used to display the value.print
now cuts off with E2Lib.limitString (which shows a trailing ... if it was cut off)toString(r:)
andtoString(r)
, which show asarray(1, 2, 3)
toString
methods to return as the new print() format was (vec()
/ang()
)print
no longer has a limit of 256 arguments (although nobody will ever make use of this)print
costs more ops the longer the combined stringRFC:
table
'stoString
method to be streamlined with array, vec, ang? Code is really gross so I didn't want to mess with it.