ID:182438
 
Directly copied from my latest blog post:

Here is a rarely known secret (well, maybe not much of a secret) involving HUDs:
world
maxx = 10
maxy = 10
maxz = 1

obj
icon = 'Test.dmi'

client
var
list
test = new()
test2 = new()
New()
..()
var/obj/O = new()
test += O
O.screen_loc = "4,4"
O = new()
test += O
O.screen_loc = "4,5"
O = new()
test2 += O
O.screen_loc = "1,1"
screen = test
sleep(10)
screen = test2
sleep(10)
screen = test


Does the code work? Find out for yourself (may need to supply your own test icon) and see a changing screen. :P

Those who were experienced with DM I bet know this secret. Screen variable has already known as a list type for clients, but works just like a good old normal list with specialties. While others may have already known about it, I'm willing to share it with ya for those who want it.
... I don't get it. Are you saying client.screen is a list? Because that's already documented.
In response to DivineO'peanut
Yeah, that part is documented. I wonder how many know you can attach another list to client.screen though. :P

Usually, people just add objects to the screen list. However, still curious if anyone uses another list and then sets the screen list to that list.
In response to Bandock
That's pretty interesting, but when I think about it, there's no reason it shouldn't be possible... client.screen is probably just a normal list, used internally by BYOND. It isn't handled differently or anything.
Well, sorry to burst your bubble, but this is no kind of 'secret', or amazing achievement. You could barely even call it a trick, because this is actually documented behavior with some of the built-in lists. And obviously, you don't need to create an inefficient client/var for it, you can use any appropriate atom list.
In response to DivineO'peanut
DivineO'peanut wrote:
client.screen is probably just a normal list, used internally by BYOND. It isn't handled differently or anything.

You can actually do different sorts of things with BYOND's built in lists (all of which IIRC have some special behavior and none are 'regular'), even those more obscurish list vars such as overlays and contents can be messed around with. I actually experimented with what kinds of things you can do with them all at one point and posted the results, but apparently that post has been pruned. =\
In response to Kaioken
I haven't made use of overlays in a long time. However, I still use screen for controlling HUDs and more lately, interfaces. :P
In response to Kaioken
<code>overlays</code> and <code>contents</code>, like most built-in lists, are handled differently, but I'm positive client.screen is a normal list that is simply used internally by BYOND (probably when drawing the screen). How exactly is it different from any other list?
In response to DivineO'peanut
Since when is contents handled differently? It doesn't mention it in the reference, and the only built in lists I've found to work differently are overlays and underlays.
In response to Nickr5
Nickr5 wrote:
Since when is contents handled differently? It doesn't mention it in the reference, and the only built in lists I've found to work differently are overlays and underlays.

You cant add any non-atoms to contents (ie: text strings or numbers) and the list automaticaly clears out any nulls
In response to Falacy
Also, if you add a turf to mob or obj contents, it doesn't let you add them.
In response to DivineO'peanut
DivineO'peanut wrote:
<code>overlays</code> and <code>contents</code>, like most built-in lists, are handled differently, but I'm positive client.screen is a normal list that is simply used internally by BYOND (probably when drawing the screen).

It's weird that you say that, since the fact those vars are special is pretty common knowledge. IIRC, there isn't a built-in list var that isn't.

How exactly is it different from any other list?

This is quite obvious, and you've said part of it yourself. Whenever the screen var is modified, a refresh of the drawn objects on the client occurs automatically (similar thing with overlays/underlays, of course). Also, with overlays/underlays and screen, you can set the variable to null then still handle it like a list (ie set to null and add an item to it later) with no problems, it's handled internally - no errors like you'd have with a normal list var. Also, the built-in lists don't accept mixed types (more accurately, datatypes not meant to be used) - you can't add a non-atom to contents, or screen, for example.
Of course, there are other things, like those lists not supporting all the functions, perhaps the more advanced procs such as Swap() and Insert() - but this kind of stuff I don't know by heart as it tends to differ from list to list, and since I've pretty much researched this already I don't feel like doing it again. I thought ancient posts were archived though and not pruned, so maybe I can dig that post up.

EDIT: As for contents' special behavior, I've forgot to mention it's also internally tied into the movement system, of course. And adding/removing a proper atom to/from a contents list automatically handles moving of it, but not recommended because it's less robust, and also less clean than just setting loc to begin with.
In response to Kaioken
It's weird that you say that, since the fact those vars are special is pretty common knowledge. IIRC, there isn't a built-in list var that isn't.

Er, I said they were handled differently, what's weird about that? :P

Anyway, while I'm still not sure that every built-in list var is special, I admit I overlooked what you pointed out. I don't use client.screen a lot(I rarely ever code in DM when I'm not helping people in the forums here), so I never encountered these things. Thanks for clarifying.
In response to DivineO'peanut
DivineO'peanut wrote:
Er, I said they were handled differently, what's weird about that? :P

Well, you said they're normal lists, but they're not quite. >_>
What you're allowed to do also differs between the different lists; I've found my old post that details this: http://www.byond.com/developer/ forum/?id=523828&view=1#523828

Anyway, while I'm still not sure that every built-in list var is special,

I think I've listed all of them in the above post, but it's possible I missed some and only most are special, I suppose (I didn't include underlays, because that should be exactly the same as overlays).

I don't use client.screen a lot(I rarely ever code in DM when I'm not helping people in the forums here), so I never encountered these things. Thanks for clarifying.

No problem. I'm quite similar myself, actually.