[SBARINFO] Ability To Read From Global ACS Variables

Moderator: GZDoom Developers

Post Reply
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

[SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

Details found here:

http://forum.zdoom.org/viewtopic.php?f= ... 67#p329667


I think it would be great if SBARINFO could read from global ACS variables as values for commands such as DrawNumber. Hopefully it's not just me but some projects have data that isn't part of the normal stuff, (health,armor,ammo). My project includes some data that is contained in ACS global variables and to be able to display this on the HUD through SBARINFO would be really nice.

So I'm wondering, would something like this be at all possible?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Graf Zahl »

Yes, this is certainly possible. The global variables are stored in an array called ACS_GlobalVars.
The only restriction would be that they'd have to be accessed by number because their names are not known in compiled form. If they contain strings they have to be looked up for display, of course but technically it's all doable.
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

Well at most we can have, what? About 65 or so of them? And we have to declare them by their number anyway so we can use that as refenece to that particular global. Doesn't sound too bad at all to me. As far as I know, all the globals that I wish to display on the HUD are numbers so that's no problem.
Blzut3
 
 
Posts: 3220
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Blzut3 »

As Slasher said, getting the numbers for global variables won't be hard for mod authors. And since we are talking about drawnumber here I don't think I need to check if it is a string. Likewise if I add something to drawstring the only thing I would need to do is check if the string is in the string table. So the next time I'm working with SBarInfo I'll look into doing this.
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

Blzut3 wrote:As Slasher said, getting the numbers for global variables won't be hard for mod authors. And since we are talking about drawnumber here I don't think I need to check if it is a string. Likewise if I add something to drawstring the only thing I would need to do is check if the string is in the string table. So the next time I'm working with SBarInfo I'll look into doing this.
Excellent. :D I don't know about anyone else's opinion, but I think this would be a really great addition. I would find this incredibly useful. It would eliminate the need to have corresponding inventory items to use for displaying the information.
Blzut3
 
 
Posts: 3220
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Blzut3 »

This still needs to be [Added]'d.
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

Does this still need testing? I'd have tested it as soon as it was made available, but since I rely on http://sourceforge.net/project/showfile ... _id=254169 for my SVN versions of zdoom, I am still stuck with r841 and I don't have access to the latest stuff, which is some really good stuff. I don't know how to compile the latest build myself so I have no choice but to wait until someone gives me access to the latest build.


Other than that, I have stuff ready to go for testing this, but in my present situation I cannot...
Blzut3
 
 
Posts: 3220
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Blzut3 »

As far as I know this has not been tested.

http://blzut3.maniacsvault.net/zdoom.zip Should be the latest revision.
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

I just tested this in r858. I don't think it worked.

This is my SBARINFO lump:

Code: Select all

Height 32;

Statusbar Normal
{
   DrawImage "HUDBASE3",0,168;

   DrawString VFON1,Red,"Health",35,169;
   DrawNumber 4,SMALLFONT,Red,Health,30,179;
   DrawNumber 4,SMALLFONT,Red,GlobalVar 3,30,189;

   DrawString VFON1,Gold,"Level",72,169;
   DrawNumber 3,VFON2,Gold,GlobalVar 0,64,177;
   DrawString VFON1,Blue,"Exp",65,183;
   DrawNumber 7,VFON3,Blue,GlobalVar 1,74,191;
   DrawNumber 7,VFON3,Blue,GlobalVar 2,74,196;

   DrawSelectedInventory AlternateOnEmpty,INDEXFON,145,170
   {
   }
}

Statusbar Inventory
{
   DrawInventoryBar Doom,7,INDEXFON,52,169;
}
And these are the global variables referenced in SBARINFO above:

Code: Select all

global int 0:level[];
global int 1:exp[];
global int 2:expneed[];
global int 3:maxhealth[];
Take note that they are arrays, as they are meant to be different values based on each player. My project is designed to be co-op compatible for up to 8 players.


Anyway when I start the game, they all display as "0" and they don't change at all. Some should be displaying 0 at the very beginning, but they seem to permanently stay that way. I followed the syntax here: http://zdoom.org/wiki/SBARINFO so something is definitely wrong.
Blzut3
 
 
Posts: 3220
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Blzut3 »

Could you try something that isn't an array?
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

Yep. Works perfectly fine with global variables that are not arrays.
Blzut3
 
 
Posts: 3220
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Blzut3 »

Thanks. Would anyone object to having global array printing always act like var[playernumber()]?
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [SBARINFO] Ability To Read From Global ACS Variables

Post by Slasher »

That's exactly how I have them set up in scripts when working with them. Strange things happen when using PlayerNumber() to reference these values while in scripts called by monsters, but this isn't about that. These are called by players only so it should have no problem. So if that's how you want to solve it, I don't foresee any problems.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”