Duke4.net Forums: Two questions about statusbar coding - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Two questions about statusbar coding

User is offline   NightFright 

  • The Truth is in here

#1

I'm trying to code a replacement for the mini HUD (screensize 4, no EDuke32 HUD). Two issues remain:

1) [UNSOLVED] At the moment it is not affected by the statusbarscale variable, i.e. it always remains at 100% size.

It starts like this:
onevent EVENT_DISPLAYSBAR
    ifvare userdef[].screen_size 4 
        ifvare userdef[].althud 0
        {
	    // Remove default HUD
            set RETURN -1

            [...]
        }
endevent


Which modifications would be required to make scaling work?

------------------------------------------

2) [SOLVED] The calculation for the inventory item percentage is somewhat off compared to the original, most likely due to rounding inaccuracies when dividing the inventory amount value.

Example (Steroids):
getp[].steroids_amount INVPCT 
div INVPCT 4
digitalnumber THREEBYFIVE 98 190 INVPCT 0 0 272 0 0 xdim ydim


If done like this, the modded display would always be slightly lagging behind the original one. Is there any way to make the conversion more accurate? (In the end it's just a display issue since the original, unconverted value remains the same, it's just about the percentage not matching vanilla.)
0

User is offline   Danukem 

  • Duke Plus Developer

#2

View PostNightFright, on 19 March 2024 - 01:31 AM, said:

Example (Steroids):
getp[].steroids_amount INVPCT 
div INVPCT 4
digitalnumber THREEBYFIVE 98 190 INVPCT 0 0 272 0 0 xdim ydim


If done like this, the modded display would always be slightly lagging behind the original one. Is there any way to make the conversion more accurate? (In the end it's just a display issue since the original, unconverted value remains the same, it's just about the percentage not matching vanilla.)



Can't you just add 1 if the number is odd?

getp[].steroids_amount INVPCT 
div INVPCT 4, ifvarand INVPCT 1 add INVPCT 1
digitalnumber THREEBYFIVE 98 190 INVPCT 0 0 272 0 0 xdim ydim

0

User is offline   NightFright 

  • The Truth is in here

#3

That will rather skip every odd value and just print even numbers (mostly), i.e. 98, 96 etc.

*UPDATE*
Found the solution. Instead of "div" (which is "divrd", i.e. round down) I have to use "divr" (0.5 equals 1).
So that only leaves the statusbar scaling issue.
0

User is offline   NightFright 

  • The Truth is in here

#4

Here is the full statusbar code. Maybe it will help to figure out how to implement scaling functionality. It's the only thing I'm missing.

Spoiler

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options