Improvements to console printing in ZScript

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Improvements to console printing in ZScript

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

Currently the only API for printing is Console.Printf:

Code: Select allExpand view
   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.
User avatar
Marrub
Xevv Va Rkvyr
 
 
 
Joined: 26 Feb 2013
Discord: Marrub#5455
Twitch ID: marrubdaskuleion
Github ID: marrub--
Operating System: Other Linux 64-bit
Graphics Processor: ATI/AMD with Vulkan Support

Re: Improvements to console printing in ZScript

Postby Marisa Kirisame » Thu Mar 05, 2020 2:02 am

Duplicate, but tbh I prefer your way of talking about it.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Improvements to console printing in ZScript

Postby 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 allExpand view
Console.PrintString(PRINT_HIGH, PRINTF_NOLOG, "Printing to screen and console without adding to log file");
User avatar
AFADoomer
 
Joined: 15 Jul 2003


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests