ACSUtils - a library for ZDoom/Zandronum scripting

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!
Dj Skaarj
Posts: 2
Joined: Mon Aug 08, 2016 1:08 pm

ACSUtils - a library for ZDoom/Zandronum scripting

Post by Dj Skaarj »

Spoiler:
ACSUtils is a library for ZDoom and Zandronum scripting that contains over 256 functions. I made it because I found myself copying the same missing functions between projects over and over again.

ACSUtils includes a complete replacement for HudMessage with support for scaling and 3D HudMessages.

ACSUtils supports the latest released versions of ZDoom, GZDoom, and Zandronum.

Documentation: http://acsutils.strangled.net/doku.php?id=start
GitHub: https://github.com/Korshun/acsutils
Download: https://github.com/Korshun/acsutils/releases


If you think that a function can be useful for other projects, suggest it for inclusion in ACSUtils.
Last edited by Dj Skaarj on Sun Aug 28, 2016 10:04 am, edited 3 times in total.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: ACS Utils 1.2

Post by wildweasel »

Dj Skaarj wrote:My friend Korshun told me to post this because his account has been manually deactivated for some reason and he can't log in.
Welcome to the forums. If you're in touch with Korshun, let him know I've fixed his account and he should be able to log in now. Sorry about that - fallout from an attempted hijacking of the forums.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: ACSUtils 1.2

Post by Nash »

Leaving my comment in here to check this out when I have time. Thanks for sharing!
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: ACSUtils 1.2

Post by The Zombie Killer »

Took a quick look, here are some issues I found:
  • the presence of GetCVarFixed will break compatibility with gdcc-acc, which is basically a non-shit ACS compiler (structs, automatic fixed point handling, etc). It'd have to be renamed to something else
  • This is wrong:

    Code: Select all

    function bool StrIsAscii(str s)
    {
    	int len = StrLen(s);
    	for (int i = 0; i < len; i++)
    	{
    		str char = GetChar(s, i);
    		if (char < ASCII_START || char > ASCII_END)
    			return false;
    	}
    	return true;
    }
    the "char" variable should be of type "int". This also breaks compatibility with gdcc-acc
TechnoDoomed1
Posts: 89
Joined: Fri Jul 29, 2016 12:36 pm
Location: Spain

Re: ACSUtils 1.2

Post by TechnoDoomed1 »

Pretty useful stuff all round. However, I noticed that there's no logarithmic function in the math section, something that is also lacking in default ACS as well (as far as I know, feel free to correct me if I'm wrong). Since I'm a math student, I'm considering writting a possible solution myself, although the ZDoom Wikia already has one.

It would also be appreciated if there was a function that allowed easy synchronization between octic-based events and tic-based events. Really, whose idea was to make a second last for 35 frames and then make a further subdivision that was not a divisor of said number?!
Dj Skaarj
Posts: 2
Joined: Mon Aug 08, 2016 1:08 pm

Re: ACSUtils 1.2

Post by Dj Skaarj »

@The Zombie Killer
The Zombie Killer wrote:the presence of GetCVarFixed will break compatibility with gdcc-acc, which is basically a non-shit ACS compiler (structs, automatic fixed point handling, etc). It'd have to be renamed to something else
Thanks for the notification. The function was renamed to "a_GetCVarFixed()", its name in the official documentation was fixed too.
The Zombie Killer wrote:the "char" variable should be of type "int". This also breaks compatibility with gdcc-acc
Heh, that was definitely a typo. Anyway, I've fixed it.

@TechnoDoomed1
Thanks for the reply! We'll do something about it.

Feedback is always welcome. We'll be doing our best to improve the quality of the library.
Last edited by Dj Skaarj on Tue Aug 09, 2016 8:45 am, edited 1 time in total.
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACSUtils 1.2

Post by Korshun »

TechnoDoomed1 wrote:Pretty useful stuff all round. However, I noticed that there's no logarithmic function in the math section, something that is also lacking in default ACS as well (as far as I know, feel free to correct me if I'm wrong). Since I'm a math student, I'm considering writting a possible solution myself, although the ZDoom Wikia already has one.
You are welcome to do so, and I will include it into ACSUtils! Thank you!
TechnoDoomed1 wrote:It would also be appreciated if there was a function that allowed easy synchronization between octic-based events and tic-based events. Really, whose idea was to make a second last for 35 frames and then make a further subdivision that was not a divisor of said number?!
Yeah this stuff is ridiculous. I remember seeing a function to do exactly that somewhere, but didn't think it was important enough to steal (maybe because I am not a mapper). I can find it again.
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACSUtils 1.2

Post by Korshun »

ACSUtils 1.2.1 released with the fixes for GDCC that The Zombie Killer requested.

changelog
TechnoDoomed1
Posts: 89
Joined: Fri Jul 29, 2016 12:36 pm
Location: Spain

Re: ACSUtils 1.2

Post by TechnoDoomed1 »

I coded a log algorithm, but my current implementation only works on fixed-point numbers. This means that to use on integers you have to convert them to fixed numbers first. If the other way around is preffered, just tell me, or feel free to change the code accordingly.
Spoiler: Logarithms
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACSUtils 1.2

Post by Korshun »

Wow! Thank you for the functions.
TechnoDoomed1 wrote:I coded a log algorithm, but my current implementation only works on fixed-point numbers. This means that to use on integers you have to convert them to fixed numbers first.
Math functions should accept whatever type is best for them. No auto conversions should be present. And I guess that a separate implementation should be used for integers, just like with zan_Sqrt and zan_FixedSqrt.
TechnoDoomed1 wrote:or feel free to change the code accordingly.
There are a few things that may be changed:

1. Should ACSUtils use your function names or follow the standard set by C?
2. FixedNum, come on, YET ANOTHER of those. Not that I blame you for using it, but ACSUtils already has itof added by Monsterovich for the same reasons as yours. I will replace it with itof or just plain conversion.

I will include the functions into the next release. We should decide on the naming.
TechnoDoomed1
Posts: 89
Joined: Fri Jul 29, 2016 12:36 pm
Location: Spain

Re: ACSUtils 1.2

Post by TechnoDoomed1 »

Fine enough, though following C naming convention is going to be hard as far as log is concerned (that's already the name of a function in ACS, and function names are not case-sensitive to allow differentiation between the two). The convention of log_2 versus log2 depends on your whim, I care little for the naming really. Just knowing that my feedback or even code was helpful is enough, I'm not nitpicky. :wink:

I indeed agree that a function should accept data as generic as possible, but the problem is that both integers and fixed numbers are really the same type, you just make an arbitrary decision of considering them full integers or interpreting them as half integer, half fraction. Allowing for fixed numbers seemed like the most generic solution, since it can represent a wider amount of numbers (reals vs integers), although it's more limited in range. True floating point arithmetic would be best here, maybe even using Gauss' AGM formula to calculate the log() since it's quicker, but alas it's not possible in ACS.

As far as the implementation of yet another int to fixed number function when there's already one... sorry. Although I revised the docs to assess ACSUtils' usefulness for using it myself in the future, I've never used it yet.


PS:If you are not in a hurry, since it's almost midnight on my timezone, I'll try to do the integer version tomorrow. Shouldn't be too hard, really.
Spoiler:
It's the log2 version for integers. Basically identical to the other one, but allows for integer numbers larger than 32768. The changes from here on to the rest of the functions is trivial. Inform me of any kind of problem or issue you find, as I finished it half asleep.
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACSUtils 1.2

Post by Korshun »

TechnoDoomed1 wrote:Fine enough, though following C naming convention is going to be hard as far as log is concerned (that's already the name of a function in ACS
I forgot that there is that Log used for logging :) , but since log in C is natural logarithm, we can use ln for that and rename the rest to match C (if we will decide to do so).
TechnoDoomed1 wrote:I indeed agree that a function should accept data as generic as possible, but the problem is that both integers and fixed numbers are really the same type, you just make an arbitrary decision of considering them full integers or interpreting them as half integer, half fraction.
You are absolutely right, but 32-bit int and 16.16 fixed are the most common data types in ACS, and support for them is built into ACC. Yes, we are missing out on other fixed-point formats, but these two types will be used the most.
TechnoDoomed1 wrote:True floating point arithmetic would be best here, maybe even using Gauss' AGM formula to calculate the log() since it's quicker, but alas it's not possible in ACS.
It's possible implement software floating-point arithmetic in ACS. It just needs the following functions:
Spoiler:
But I am totally not not sure that there is any demand for it.
TechnoDoomed1 wrote:As far as the implementation of yet another int to fixed number function when there's already one... sorry. Although I revised the docs to assess ACSUtils' usefulness for using it myself in the future, I've never used it yet.
That said, your name is more readable, as I just mistyped "itof" as "atof" when writing the previous post, and that would result in a huge bug, as ACSUtils provides "atof", which parses a string into a fixed-point number.
TechnoDoomed1 wrote:PS:If you are not in a hurry, since it's almost midnight on my timezone, I'll try to do the integer version tomorrow. Shouldn't be too hard, really.
Thank you for the integer version, but there was no need to be in a hurry.
TechnoDoomed1
Posts: 89
Joined: Fri Jul 29, 2016 12:36 pm
Location: Spain

Re: ACSUtils 1.2

Post by TechnoDoomed1 »

No worries.
BTW, I was checking the docs and found that IntDiv could use an improvement as per the team's instructions.
acsutils documentation wrote:IntDiv doesn't work with parameters over 32767 or under -32768, it's just a shorthand for FixedDiv(a«16, b«16) right now.
Contributions to enable IntDiv to work with any integers as long as their ratio is less than 32767 are welcome.
Let me know what you think:
Spoiler: Extended IntDiv
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACSUtils 1.2

Post by Korshun »

This is great! IntDiv is now a really cool function!
Will include all the math into ACSUtils 1.2.2! (right after other ACSUtils devs voice their opinion about the naming of logarithm functions, a not-so-good reason to delay it, I know)

EDIT: I have found the octic synchronization function: http://zdoom.org/wiki/Syncspeed, do I just include it?
TechnoDoomed1
Posts: 89
Joined: Fri Jul 29, 2016 12:36 pm
Location: Spain

Re: ACSUtils 1.2

Post by TechnoDoomed1 »

Seems like a good idea.

Though to be fair I find it a little convoluted to replace a measly cross-multiplication. Still useful, though.
Post Reply

Return to “Resources”