[Solved][ZS] Get the Loaded iWad

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.
Contact:

[Solved][ZS] Get the Loaded iWad

Post by Sarah »

Searched a fair bit and I'm not seeing an easy solution, so I need to do some math based on the dimensions of the mouse cursor, problem is I need to know which cursor the player is using. If the cursor is explicitly set, then vid_cursor holds a string that I can use to find the cursor graphic and all is well. The problem is the default setting, this auto-chooses by the game that's loaded, which means vid_cursor returns a garbage string that won't help me find a graphic, but it could be used to kick off my own zscript search for the right graphic if I can figure out which iwad the player has loaded. And that's where I'm stuck.

tldr? How do I get which iwad the player has loaded from zscript? I need to know if they have loaded Doom or Doom2 or Hexen, or Chex, etc. Thanks!


Edit: I do apologize for solving my own problems after posting a fair bit. So I found workaround that is frankly...yucky.
I use a console command to pull double duty. It is executed from the Options Menu and sets a cvar based on some abuse of IfGame() in the menudef, and opens the menu that needs the cvar set. CVar set, it can be retrieved from ZScript. I guess not too bad but I still think there's got to be a better way.
Last edited by Sarah on Wed May 06, 2020 1:34 pm, edited 1 time in total.
User avatar
3saster
Posts: 199
Joined: Fri May 11, 2018 2:39 pm
Location: Canada

Re: [ZS] Get the Loaded iWad - Workaround Found

Post by 3saster »

Nero wrote: Edit: I do apologize for solving my own problems after posting a fair bit. So I found workaround that is frankly...yucky.
I use a console command to pull double duty. It is executed from the Options Menu and sets a cvar based on some abuse of IfGame() in the menudef, and opens the menu that needs the cvar set. CVar set, it can be retrieved from ZScript. I guess not too bad but I still think there's got to be a better way.
Ugh, that is yucky! Thankfully, there are some easy ways in ZScript to check what IWAD you have loaded. The first, and easiest, is to check the bits of gameinfo.gametype against the gametype. That mask specifies which major game type is being loaded (Doom, Heretic, Hexen, Chex, or Strife). The second way is to use Wads.CheckNumForName to check for the presence of certain lumps to determine the IWAD (you can see which lumps GZDoom normally checks for recognized IWADs here, in the
MustContain field). Something related worth looking at is lump filtering, which will only load certain assets if the correct IWAD is loaded.

Examples of how to use to ZScript to check the IWAD (or potentially even the WAD) is here. IsChex shows the first method I described, while the other ones (except isLZDoom) demonstrate the second way.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [ZS] Get the Loaded iWad - Workaround Found

Post by Gez »

I think the proper way to do that would be to have a way to get the cursor graphic directly, not to guess what it is depending on user settings and IWAD and rely on a hardcoded table of height and width for known cursors...
User avatar
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.
Contact:

Re: [ZS] Get the Loaded iWad - Workaround Found

Post by Sarah »

Oh I do get the cursor graphic directly. I need to know the graphic's height and width for maths. The real problem is where I get the graphic name from, it's defined in the base menudef as part of the Mouse Options menu. The CVar vid_cursor is a string that will be set to the graphic name, if, and it's a big stinky if, the player has directly set a cursor. The default option sets the string to "none". Now getting the CVar value from zscript is useless, so better solution - dump the CVar, figure out what iwad is loaded for yourself and just hard code the cursor names, they probably aren't going to change.

*Correction - use the hardcoded names if the cvar is garbage since a valid cvar means the player has set a specific cursor.

So another tldr; 3saster, thanks that's precisely what I needed!
Post Reply

Return to “Scripting”