Resource icon

[Open Assets] Custom HUD Library 2.1

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
This file provides ways for custom HUDs to properly interact with each other without conflicts. If you're writing a HUD addon and you use this, then every other HUD addon also using this will be compatible with yours!



FOR USERS

This add-on does nothing when added on its own, since it's mostly for developers. However, if you're using multiple add-ons that are using this library, you can use the console command customhud_setitem [item name] [mod identifier] to set which version of a HUD item to use.

For example, if the mod "sa1hud" and the mod "scrungohud" both define "bossmeter", you can use customhud_setitem bossmeter scrungohud to make the game use the one from "scrungohud" instead of "sa1hud".

Or, if you prefer the base game's version of a HUD item, you can use keyword "vanilla" to change it back. For example, customhud_setitem lives vanilla will go back to the original version of the lives counter.



FOR DEVELOPERS

The main usage of this library is the customhud.SetupItem function, which can be used to hook into a new system which will properly resolve mod conflicts, allowing users to mix-and-match multiple mods that want to change the same aspects of the HUD.

Let's take an example of replacing the timer HUD. Instead of using hud.disable("time") to hide the vanilla timer and then hud.add(my_mods_timer) to insert a new HUD hook, you would use customhud.SetupItem("time" "my_mod_name", my_mods_timer) to set a new hook specifically targeting the timer. Now if the user adds your mod on top of another mod that also wanted to edit the timer, then it will use yours instead of creating two timers!

Additionally, the function can be used to create entirely new HUD items. customhud.SetupItem("bossmeter" "my_mod_name", my_mods_boss_meter, "game", 0) will add a custom HUD item called "bossmeter", which can then be also overwritten by other mods to prevent two or more bossmeters from happening!

See here for more in-depth documentation, as well as other features of the library: https://wiki.srb2.org/wiki/User:TehRealSalt/Custom_HUD_Library

While this is an Open Asset so that you don't need to get permission to reuse, please avoid making any changes to the file. If you need changes, or have other ideas for improvements, please let me know so that the file may be updated for everyone.



The following is a list of other add-ons that use this library. Let me know if you've released an add-on which uses this, and I'll add you to this list!
Author
TehRealSalt
Downloads
387
Views
3,016
Extension type
lua
File size
15.2 KB
MD5 Hash
94a18ca979dbede4c7a011ab080506df
First release
Last update
Rating
4.00 star(s) 1 ratings

More resources from TehRealSalt

Share this resource

Latest reviews

Welcome to releases!
Upvote 0
Back
Top