How would I go about displaying information in an interface label to multiple users?
As an example. Lets say I have a high score and I want to display it to all players in the game. Can this be done through a single interface control?
ts
ID:159200
Apr 21 2009, 1:04 pm
|
|
Apr 21 2009, 1:11 pm
|
|
The way I've done it is to use a for() loop. It'd probably be useful if the first argument in winset() could take lists of people, along with individuals.
|
In response to Kaiochao
|
|
In other words, remember the first arg of winset is going to be which client is getting updated.
Thus: winset (src,"lblHighScore","text=\"[world.highscore]\"") Everybody has their own copies of the interface so you don't need to worry about lblHighScore conflicting with eachother's. However, you'll need to change that "src" to reflect each client object to be updated, running winset one at a time for each. Understanding variable scope becomes rather important here. [Edited to reflect the needed inclusion of text= into the winset arg. The surrounding \" are only really needed in case there's going to be spaces stored in the highscore variable.] |
In response to Geldonyetich
|
|
Geldonyetich wrote:
In other words, remember the first arg of winset is going to be which client is getting updated.
winset (src,"lblHighScore",world.highscore)
Everybody has their own copies of the interface so you don't need to worry about lblHighScore conflicting with eachother's. However, you'll need to change that "src" to reflect each client object to be updated, running winset one at a time for each. That seemed like a very excessive and unnecessary explanation when you could just say this... for(var/client/C) BTW: You would need to include text="" not just the variable (i think) otherwise you'd be trying to set a flag that doesn't exist.... |
I tried to do something similar to this. Basically how I set it out was like this:
client/proc And then I ran that whenever score would change or a client logged in. |
In response to Demon_F0rce
|
|
I also use the output() proc to set text in labels (and anything else with a text parameter). You can update an entire list of people at once and you won't have to worry about bad client errors.
|
In response to AJX
|
|
AJX wrote:
That seemed like a very excessive and unnecessary explanation when you could just say this... That's me, I like to dwell on the big picture excessively and unnecessarily. ;) Really, I think it's a good approach when trying to educate somebody because you never know exactly how they're going to look at something, or who's going to read the message, so you want to cover as many perspectives as possible. BTW: You would need to include text="" not just the variable (i think) otherwise you'd be trying to set a flag that doesn't exist.... Very true, good catch. |
In response to Geldonyetich
|
|
Geldonyetich wrote:
However, you'll need to change that "src" to reflect each client object to be updated, running winset one at a time for each. Eh...I don't think you understand entirely. You don't HAVE to put src there, it can be anything that fits its type requirement (client). Furthermore changing src manually is usually ill advisable... |
In response to AJX
|
|
AJX wrote:
Geldonyetich wrote: I'm thinking along the lines of if you have a list of specific clients you want to set the interface controls on, and that would require the "src" be replaced with the appropriate clients as you're running through the list. Unless you've a specific client proc implementation... seems a bit backwards to do it that way, but actually, it's not. There's really no wrong answer here as long as we both understand that first arg refers to a client. I'm not sure how swapping out src would be ill advisable - does BYOND tend to break if you provide other clients or use winset from outside of the client object? |
In response to Geldonyetich
|
|
Geldonyetich wrote:
AJX wrote: I don't think you got what I meant. I didn't say swapping out src for a different variable was bad, thats good. I was saying that setting src=something other than src was is bad programming practice. src is meant to refer to the datum that the proc is being called on. |
In response to AJX
|
|
AJX wrote:
I don't think you got what I meant. I didn't say swapping out src for a different variable was bad, thats good. I was saying that setting src=something other than src was is bad programming practice. src is meant to refer to the datum that the proc is being called on. I'm not sure where you're picking up I'm trying to change the value of src. What I meant was that you'd change the first arg of winset to something (another client) other than src, not that you'd try to change src. Seems a strange thing to interpret I meant. So far as I can tell, the only place "src =" ever happens in BYOND following a verb set, and then it's a special syntax related to verb visibility. I've never seen "my self-reference variable = something else" in any language I've used. I'm kinda surprised src = "Awesome" doesn't trigger a compiler error. Don't sweat it - it's as Karl Popper said, “It is impossible to speak in such a way that you cannot be misunderstood.” Judging by the frequently of butting heads over misunderstandings I do on forums, I'm misunderstood more frequently than most. I can't tell whether that means I'm a genius or a terrible communicator. |
In response to Geldonyetich
|
|
Geldonyetich wrote:
AJX wrote: Yea so basically I just completely misunderstood what you were saying. Ignore meh. -.-' |
In response to Geldonyetich
|
|
Geldonyetich wrote:
I'm not sure how swapping out src would be ill advisable - does BYOND tend to break if you provide other clients ("provide other clients"?) or use winset from outside of the client object? To clarify, generally where you put your instructions (ie winset()) doesn't change what you can or can't do in this sense - you can call client-related stuff from anywhere, not only client procs, same for Most-Everything™ else. As with Most-Everything™ in life, there are, of course, specific exceptions (though they're still of the minority); some proc calls, for varying reasons, might do [sometimes completely] different things depending on where you put them (e.g. ..()), and some may only be used in one place (e.g. stat() can only go in Stat()). EDIT: Also, just for the record, Most-Everything™ that does something to a player and takes a 'player reference' can either accept a /client reference or a player /mob reference. Moreover, whenever using the << output operator, in addition to the above, the recipient of it can also be a list of clients or mobs (mixed list probably works too). Could indeed be nice as well as consistent if the win*() interface-family procs could also take such a list. |
In response to AJX
|
|
Thanks to everyone who made suggestions. Using the client loop is working out.
Thanks, ts |