Conditional graphics in TADS 3

Hello… I could probably find this out if I combed through enough documentation or library code, but…

What is the simple and concise way for TADS game code to check if the user’s interpreter supports graphics, and to display the graphic if so, and to display a text representation if not?
My game is not at all graphic-oriented, but there are two spots where an illustration would be better for the clue/puzzle situation, and I’d like to implement it in the hopes that most users will be able to see it. There will be a text backup for those that can’t…

1 Like

You do that through the systemInfo() function (it’s in the <tadsio.h> header.) Take a look at this file and the various SysInfo definitions you can use. To check if the game is running in an HTML TADS interpeter, you’d check:

systemInfo(SysInfoInterpClass) == SysInfoIClassHTML

This is usually enough, but technically, you would need to check for specific support for your image format. To see if JPEG and PNG images are supported, you’d use:


However, I don’t think you need to do that. It’s safe to assume that if an interpreter supports HTML TADS, then it supports both graphics formats. However, the user might have disabled graphics in the interpreter settings. You can query that with:


So you should probably write a function for this, like:

function terpDoesGraphics()
    return systemInfo(SysInfoInterpClass) == SysInfoIClassHTML && systemInfo(SysInfoPrefImages);

It’s best to not store this as some global hasGraphics flag at game start. Preferences can change, and also people might play and save the game in a non-html terp and then load the save in an html terp. So it’s best to call this function every time at the point where you need to decide whether to show an image or its textual representation.

1 Like

I appreciate the input!