Improvements to console printing in ZScript

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Improvements to console printing in ZScript

Re: Improvements to console printing in ZScript

by kevansevans » Mon Jul 25, 2022 2:25 pm

While we're on the topic, can we also add a simplified version of the console.printf function to just print or trace? And maybe even support for multiple arguments, IE print(a, b, c)? Just sort of annoying having to type so much for a basic debug feature.

Re: Improvements to console printing in ZScript

by Marisa the Magician » Mon Jul 25, 2022 2:16 pm

This can be closed now, we have PrintfEx.

Re: Improvements to console printing in ZScript

by AFADoomer » Sat Jun 05, 2021 10:04 am

I submitted a pull request along the lines of Marrub's original suggestion for this here.

Summary:
- Split print flags into separate enumerator from print levels
- Added Console.PrintString ZScript function that takes print level and flags as the first two parameters, then standard printf-style input after that

Use:

Code: Select all

Console.PrintString(PRINT_HIGH, PRINTF_NOLOG, "Printing to screen and console without adding to log file");

Re: Improvements to console printing in ZScript

by Marisa the Magician » Thu Mar 05, 2020 2:02 am

Duplicate, but tbh I prefer your way of talking about it.

Improvements to console printing in ZScript

by Marrub » Thu Mar 05, 2020 12:15 am

Currently the only API for printing is Console.Printf:

Code: Select all

	native static vararg void Printf(string fmt, ...);
But, there are some features of the console that aren't accessible yet. Things like:
  • Print levels (PRINT_LOW to PRINT_BOLD)
  • No-notify mode (PRINT_NONOTIFY)
  • No-log mode (PRINT_NOLOG)
Print levels are very useful since mods often need to print out errors or warnings about their inputs. For instance if "Some Mod" had a CVar format that was parsed into several variables, and the user gave garbage input, it would be useful to print the warning as an actual warning.

No-notify mode is particularly useful because currently the only way to use it is by using HudMessage. Yes, really. It IS exposed, but only through HUDMSG_LOG, and nowhere else in the entire engine. (Save for some very particular edge cases that wouldn't be useful in the same situations.)

No-log mode is not particularly useful for mods so it could be omitted, however an example case against omission might be that you have some debugging data that only makes sense to be given at runtime.

It's probably not a good idea to expose these as-is to ZScript since they have the same flags-inside-description issue that A_PlaySound had. However, they are very useful features. My proposal is, then:
  • Move PrintLevel's flags into a separate parameter internally. This could for instance be done by adding another function like "PrintfFlags".
  • Expose Printf's level and flag parameters, probably through a new function in Console, like Console.PrintLn or whatever sounds nicest.

Top