Second HUD

by Lummox JR
See how to use BYOND's multiple HUD feature
ID:75908
 
Keywords: demo, hud, skins

A new feature has been added to BYOND starting in version 444. It is now possible to use extra map controls to display HUD objects, instead of being limited to only one map. The main, default map shows the game world and mobs moving around, etc., but you can put HUD elements into other map controls to make your interface more slick.

Here's how the process works: First, in your regular game skin you should already have a map control, and it should be marked as the default. Wherever you like, add a new map control and give it a unique name, like "radar_map". This map should not be set as a default; it will only be used for showing screen objects.

Now to show an object in that map, you'll need to setup your code with the right screen_loc value. If you want to show a HUD object in a secondary map, use the format "[map]:[screen_loc]", like this:

obj
radar_grid
icon = 'radar.dmi'
screen_loc = "radar_map:1,1 to 5,5"

Once the object is added to client.screen, it should be visible in the radar_map control you've created.

The map will try to show all the screen objects you put into it, so in this example radar_map would be 5×5 tiles in size.

The Demo

I've created a simple demo for this called Second HUD. If you download and run the demo you'll see three maps: Two with icons, one with text.

The main map is the big one, and it shows your mob moving around on the playing field. The other two are special HUD-only maps, map2 and map3. Both of these have been filled with a few example objects.

In map2, you'll see that the farthest object to the left has a screen_loc of "map2:1,1", and the topmost is "map2:4,4". But way off to the right, there's an object with "map2:6,0" as its screen_loc. This stretches out the HUD to 6 tiles wide, and 5 tiles high.

In map3, the object furthest to the southwest is at "map3:0,0 to 2,2". Furthest north is "map3:2,3", and furthest east is "map3:3,2", so that makes map3 4×4 tiles in size.

If you hover your mouse cursor over any of the objects in either of those two HUDs, you'll see their name and the screen_loc they were given. That's a little something I put into the demo to make it easier to see what's positioned where. If you were really using this for a radar screen or something though, you could just as easily have a blip with the name "Unidentified target" and make it clickable to select a target. The objs you see in these HUDs are just like any other screen object--by adding the necessary procs you can click them, drag and drop, etc.

As with any new feature the fun comes in seeing what people will do with it, so I can't wait to see what clever concepts people use this for in their own games.

coolio!
The main map only shows the top left corner of the screen, the rest is black.

Both mini maps only update after I maximize or minimize the window. When they lag behind and don't show what the actual map should look like, they still have the right mouseover text.

The text map just shows a bunch of unchanging ÿ's.
I'm kinda curious if this update broke pixel offsets in screen_loc (I haven't checked). That is, would a screen_loc of "map_control:1:16,1:8" work properly? And would a simple "1:16,1:16" still work?
SuperAntx: you have to update to 444. The behavior you are describing is what it looks like in older clients.

Kuruado: pixel offsets are compatible with the new notation. Old games and the old notation should work just fine. Should. You tell us!
Looks like everything's working with 444 installed.

It might be necessary to require players to download 444 for games using this feature. It could be a game-breaking bug.
People can do that manually, SuperAntx.

But this is spectacular. This opens up new ideas and more possibilities!
Looks great. I have a few ideas for this.
This is nice; this is definitely useful for minimaps, radars, etc.

Also, I like the quick release; I can continue working on my library without that pesky pane-child bug (hopefully there won't be a third).
It'd also be cool if you could simple set the other map to display another viewpoint. Say you want to be able to view your mob's perspective as well as someone else's, or another location on the map.
You know, like a second map instead of just another place for HUDs.
I saw this in a demo and i was like what the hell is 6,3 to 5,5 until i stumbled upon this.
Kaiochao wrote:
It'd also be cool if you could simple set the other map to display another viewpoint. Say you want to be able to view your mob's perspective as well as someone else's, or another location on the map.
You know, like a second map instead of just another place for HUDs.

That definitely would be cool, but at the current time it's technically infeasible on a number of levels. Way too much code is geared around one eye per client, and we'd have to have some notation for supporting additional eyes. That could be a someday feature though.
You could, however, use the hud objects to recreate the view point. It'd likely be intensive depending on how close to a real-time update you want.
"It'd likely be intensive depending on how close to a real-time update you want."
Which is why that's exactly what I don't want. I've thought of that already :\
Excellent. :D
Oh, wow, we've got a second map now? Cool beans.
While I will never have much a use for this, this is good. Good work guys!
I thought of at least one interesting use for it, though I've yet to test it: Allowing a host to preview the maps they've loaded.
I was having the same problem as SuperAntx, so I updated to the latest version of BYOND. Now the problem seems worse. Instead of updating after resizing it doesn't update at all.

Black Heart 720 wrote:
I was having the same problem as SuperAntx, so I updated to the latest version of BYOND. Now the problem seems worse. Instead of updating after resizing it doesn't update at all.

http://img199.imageshack.us/img199/8581/hubb.jpg

It's not clear from your picture what problem you're experiencing, but I'm seeing normal behavior on my end in 448. Your comment predates the 448 release though, so I'm guessing you only saw this in 447; give 448 a try.
Page: 1 2