Improvements to console printing in ZScript

Moderator: GZDoom Developers

User avatar
Marrub
 
 
Posts: 1162
Joined: Tue Feb 26, 2013 2:48 pm
Discord: agw.systems#7777
Twitch ID: marrubdaskuleion
Github ID: marrub--
Graphics Processor: ATI/AMD with Vulkan Support

Improvements to console printing in ZScript

Post by Marrub »

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.
User avatar
Marisa the Magician
 
 
Posts: 3804
Joined: Fri Feb 08, 2008 9:15 am
Discord: Marisa the Magician#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Improvements to console printing in ZScript

Post by Marisa the Magician »

Duplicate, but tbh I prefer your way of talking about it.
User avatar
AFADoomer
Posts: 1242
Joined: Tue Jul 15, 2003 4:18 pm

Re: Improvements to console printing in ZScript

Post by AFADoomer »

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");
User avatar
Marisa the Magician
 
 
Posts: 3804
Joined: Fri Feb 08, 2008 9:15 am
Discord: Marisa the Magician#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Improvements to console printing in ZScript

Post by Marisa the Magician »

This can be closed now, we have PrintfEx.
User avatar
kevansevans
Spotlight Team
Posts: 400
Joined: Tue Oct 05, 2010 12:04 am
Github ID: kevansevans
Graphics Processor: nVidia with Vulkan support

Re: Improvements to console printing in ZScript

Post by kevansevans »

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.

Return to “Closed Feature Suggestions”