I'd be happy to. I tried to make all the mods I've made reasonably well commented and stuff to help others learn or use them (and being MIT licensed, do basically whatever they want with it). But the X-Raydar stuff covers so many weird corner cases that it's kinda massive :/
tl;dr
- A marker with the J4FRadarUi class/script coordinates stuff. It sets up the custom HUD, and radar-detectable objects communicate their status to it.
- Items with some variation of the J4FRadarAbstractTarget class decide whether to tell the J4FRadarUi coordinator that they exist or not (through J4FRadarDetected and similar messages). These scripts are assigned to creatures and items through MetaProperties. Different classes have different logic in their BlessItem function, like books and switches hiding themselves after the player uses them once.
- The J4FRadarOverlayHandlerBase class draws things on screen like a custom HUD.
- The radar toggle item tells the J4FRadarUi coordinator to toggle on and off with J4FRadarToggle messages. The radar's basically always "active", just not always drawing indicators.
The normal use of custom HUD/UI stuff is more like creating a UI element for a message log, another UI element for a mana bar, and so on. They'd always be at the same spot on the screen and mean the same thing, like the vanilla light gem and healthbar.
I abuse that to create 32 UI elements (my MAX_POI_RENDERED), which are shown, hidden, or moved around on every frame. If there are more than 32 detected items in view, the others just don't get shown. I sort by the closest items first, since they matter more.
I change the UI element to different sizes and colors of rings, depending on the distance and indicator type. It's similar to how a custom UI could represent a mana pool as a fuzzy blue orb that shrinks down to nothing, or a status indicator switching from green to red. Just a bunch of static png files.
The game has GetObjectScreenBounds() to get four corners of something on screen (or fails if it's off screen). This could be used to make Deus-Ex-style indicators on the four corners of an object. I just average them out to get the center point.
Deciding what objects to check GetObjectScreenBounds() for can be complicated, but it doesn't have to be near as complicated as this mod. An FM author could slap a MetaProperty directly on what they want to be detected. I have to scan every single object in a level, because people do sneaky things like use a junk object as a key. Basically all that scanning process does is assign MetaProperties I couldn't do with DML alone.
One thing I wish worked differently is when something's near the edge of the screen. You may notice those indicator circles get squished. That's NewDark deciding to resize the image instead of cut off parts of it.
Why do I wish there was no squishing? Because it'd make for a great keyhole-peeping mod! It's possible to do a basic one right now, but it won't move as your angle of view moves. Like the scouting-orb lens overlay, basically. To give a sense of peering through the two sides of a keyhole, it'd be better if there were two keyhole images that overlap. If one of those were a UI element sliding around your screen as you turn your head, it could squeeze the field of view to a sliver if you turned your head too far. Alas, it just gets smooshed and looks weird instead. And the scaling of UI elements to different monitor sizes also complicates things a bit. Maybe someday.... I think it'd be possible to trigger keyhole behavior by being crouched near a door for long enough, and to leave keyhole view if turning your head too far or someone opens it! But given the visual experience wasn't what I wanted, I never went far enough to confirm anything beyond the ability to attach my point-of-view camera to a door :/
Anyway, I'm rambling now. The idea of a quantity-limited, time-limited potion for these radar effects is totally doable. If that's the only change that was desired, it'd be a matter of having some object send a J4FRadarToggle message when it's used, start a timer, and send another J4FRadarToggle message when it expires. At that point, it'd probably be better to implement new J4FRadarToggleOn and J4FRadarToggleOff messages specifically, so that if someone happens to drink two Detect Gold potions at the same time they wouldn't cancel each other out.
Lots of things are doable with enough effort, though. A blood radar that detects living (but not undead) creatures when you've equipped a vampiric sword, and only up to a certain range, and only when on low heath. Tweak the J4FRadarCreatureTarget's BlessItem function enough, and that might be good enough.