ID:164981
 
I'm sure the tutorials pages are littered with guides to this sort of thing but i haven't found any yet. How do i put things on the screen? I think it's called the hud or hub or something, i'm not really sure. Also if it's a client.eye type i've never been that good with clients, so that would explain it! Thanks.
Yes, search for 'HUD', and look up client.screen in the DM Reference.
In response to Kaioken
Well, i get that it's a client.screen, and i get the "X,Y" bit, but how do i actually put an object on the client.screen?
In response to Adam753
obj/WhiteScreen
icon='white.dmi'
screen_loc = "1,1 to EAST,NORTH" //Making one WhiteScreen object cover all of the clients' screen, especially if it's adjustable

var/list/misc=list("white") //setting up a list of stuff to create things in which can be used to show anything to anybody without creating more than needed objects

world/New()
misc["white"]=new/obj/WhiteScreen //Makes a new instance of the object and placing it in the list, so we can use it to other people without creating any more instances since one is enough

Admin/verb/Blinding_Shock()
world << "You go blind now!"
for(var/client/C) //This defaults to for(var/client/C in world)
C.screen+=misc["white"] //You add the WhiteScreen object to the player

Admin/verb/Releasing_Fear()
world << "You can see, hear, touch, play and be anything you want to be..."
for(var/client/C)
C.screen-=misc["white"]


Correct me if I am wrong please, I know I probably messed up something since it's been a long time since I opened DM <_<

- GhostAnime
In response to GhostAnime
Its fine, except-

GhostAnime wrote:
screen_loc = "1,1 to EAST,NORTH"

I'm not sure, but that might be invalid syntax. I use "SOUTHEAST to NORTHWEST".

var/list/misc=list("white") //setting up a list of stuff to create things in which can be used to show anything to anybody without creating more than needed objects

Well, you can just use a regular list here instead. If you want you can #define the index numbers so you don't have to remember them, which has the same effect of using the associative list.

world/New()
misc["white"]=new/obj/WhiteScreen //Makes a new instance of the object and placing it in the list, so we can use it to other people without creating any more instances since one is enough

This part is fine, but you can use 'new'/initialize objects
"at compile-time", so no need for a world/New() override for that.

for(var/client/C) //This defaults to for(var/client/C in world)

Actually, it doesn't. IIRC the DM Ref does say that, but if you do var/client/C in world that won't actually work. The reason is that is the same as doing var/client/C in world.contents, and world.contents contains only atoms. Rather, omitting the 'in' seems to simply loop threw all those objects that exist.


for(var/client/C)
C.screen-=misc["white"]
Well, yeah, this is also fine, but you can make it more efficient. It takes some extra time to look-up an item in a list, so instead of doing that each iteration, you're better off doing it only once:
var/obj/white_O = misc["white"]
for(var/client/C) C.screen -= white_o
In response to GhostAnime
Hmm, that works awesome! I'll just post what i've got so you guys can pick holes in it.
var/list/score=list("onscreen")
world
view="20x20"
New()
score["hundred"]=new/obj/score/hundred
score["ten"]=new/obj/score/ten
score["one"]=new/obj/score/one
mob
Login()
usr.loc=locate(11,11,1)
for(var/client/C in oview(0)) //only the usr that logged in
C.screen+=score["hundred"] //put the hundreds on C's screen
C.screen+=score["ten"] //and the tens
C.screen+=score["one"] //and the ones
obj
score
icon='score.dmi'
icon_state="0"
hundred
screen_loc="1,20" //the hundreds column is at 1,20
ten
screen_loc="2,20" //the tens is at 2,20
one
screen_loc="3,20" //and the ones are at 3,20

Yes? I keep score with a 1 counter, a 10 counter and a 100 counter.
EDIT oh yeah, i just realised, how would i change the icon state of something onscreen?
In response to Adam753
As a note, please refer to Kaio's post below if you haven't done so (which, btw, thanks for the corrections Kaio).

You simply have to locate the object and change it's icon_state:
var/obj/o = locate(/obj/score/hundred) in client.screen
if(!o)return //Safety check, always remember to do saftey checks where plausible
o.icon_state="2"


Just remember, since you have the object stored in one place which everyone is having a reference to, I _THINK_ if you change the icon_state or do anything to the object, it'll affect everyone and not just the one person him/herself (which is not a good thing for something like a health hud). To make it individual, you would probably have to make a new instance of the object in which each individual client would have their own instance... but I am not sure to be honest <_<

- GhostAnime
In response to GhostAnime
OH, yeah. thanks!
In response to GhostAnime
GhostAnime wrote:
Just remember, since you have the object stored in one place which everyone is having a reference to, I _THINK_ if you change the icon_state or do anything to the object, it'll affect everyone and not just the one person him/herself (which is not a good thing for something like a health hud).

Yeah, IIRC screen objects update realtime. Which is convenient, well, yeah, except for player-specific stuff such as stat bars.

To make it individual, you would probably have to make a new > instance of the object in which each individual client would > have their own instance... but I am not sure to be honest <_<

True, but I guess you could make global objs for that as well. ie if the bar can have 5 states, have only 5 global bar objs, each with a different icon_state. Then when updating the bar, remove the current obj and add the respective one to that player's client.screen.
I think it could work well, though I haven't something like that. That way, if you have 1-5 players, well, you've wasted objects :P but if you have 20 you've saved them because all in all you have just 5 objs.