ID:433986
 
Keywords: panel, separate, stat
(See the best response by Albro1.)
How do I put different info on another stat panel? I'm not seeing anything in the reference.

I want to separate a tab onto this other panel, cause ull kinda need to have this certain one up all the time.
Best response
You can't. You'll need to use an alternative, such as Grids, or combine some panes into a Tab control.
Aw, that kinda stinks, it would be nice to have 2 stat panels.

But aaaaaanyway, I've been working on a way to show enemies on the grid, but I'm kinda having trouble with this.
    var
list/Evil_Enemies_List = list()
proc
GetEnemyData()
var/ENEMIES = 1
while(1)
for(var/mob/ai/E in oview(10,src))
if(E.enemy == 1 && E.breakable == 0)
if(E in !src.Evil_Enemies_List) //Right here I think I messed up
src.Evil_Enemies_List += E
for(var/mob/ai/E in Evil_Enemies_List)
src << output(E,"enemygrid:1,[++ENEMIES]")
src << output(E.HP,"enemygrid:2,[ENEMIES]")
sleep(1)


and I think its with that in the annotes I put. I'm not sure how to write, "if the E is not in the list, include em in!"
if(!(E in list))? I suppose it would work.
In response to PkMax
Don't forget to remove dead/out of range enemies from your list. I think a deleted enemy will actually leave a null entry in your list (and thus a blank space in your grid), so you'll want to remove those too. Then you'll want to resize the grid to the actual number of enemies to cut off any old entries when your list shrinks.

I would suggest this ordering:
1) loop through enemies already in list, remove any dead/out of range/null entries
2) loop through oview() and add any new valid enemies
3) use winset() to set the size of the grid based on your new enemy list length
4) loop through the enemy list and output them to the grid

Also, updating the list each tick is *way* too often. I would suggest once per second.
Okay, I've got a good idea of what to do with the enemy grid
    var
list/Evil_Enemies_List = list()
proc
GetEnemyData()
var/ENEMIES = 1
while(1)
winset(src, "enemygrid", "cells=0")
for(var/mob/ai/E in Evil_Enemies_List)
if(!(E in oview(10,src)))
src.Evil_Enemies_List -= E
if(E.down == 1)
src.Evil_Enemies_List -= E
if(!E)
src.Evil_Enemies_List -= E
for(var/mob/ai/E in oview(10,src))
if(E.enemy == 1 && E.breakable == 0)
if(!(E in src.Evil_Enemies_List))
src.Evil_Enemies_List += E
winset(src, "enemygrid", "cells=2x[ENEMIES]")

for(var/mob/ai/E in Evil_Enemies_List)
src << output(E,"enemygrid:1,[++ENEMIES]")
src << output(E.HP,"enemygrid:2,[ENEMIES]")
sleep(10)

But when It clears the grid and puts the list of enemies back up, it like creates another row at the top each time it refreshes, so it like makes a bunch of rows infinitely,

I think im clearing it worong, but It seems to do it ok, except for u know, that row thing i just mentioned.
Try winset()ing the grids cells to 0x0, not just 0.
Thanks for the suggestion albro, I've replace my old winset thingie!

And I have the right way to include them in the list if they are not, thanks Blast!

And to fix my problem, all I had to do was put the ENEMIEEES variable back to 0, cause it kept counting up so it kept putting it in higher lines.

    var
tmp/list/Evil_Enemies_List = list()
proc
GetEnemyData()
var/ENEMIES = 1
while(1)
winset(src, "enemygrid", "cells=0x0")
for(var/mob/ai/E in Evil_Enemies_List)
if(!(E in oview(10,src)))
src.Evil_Enemies_List -= E
if(E.down == 1)
src.Evil_Enemies_List -= E
if(!E)
src.Evil_Enemies_List -= E
for(var/mob/ai/E in oview(10,src))
if(E.enemy == 1 && E.breakable == 0)
if(!(E in src.Evil_Enemies_List))
src.Evil_Enemies_List += E
winset(src, "enemygrid", "cells=2x[ENEMIES]")
ENEMIES = 0
for(var/mob/ai/E in Evil_Enemies_List)
src << output(E,"enemygrid:1,[++ENEMIES]")
src << output(E.HP,"enemygrid:2,[ENEMIES]")
sleep(10)


Every time the grid refreshes, it would flash which gets annoying to look at.

It takes a bit for the grid window to keep updating so it like flashes every time it refreshes which gets annoying.

The HP of the enemy almost changed instantly when damage was done, but I have to make the grid refresh at large intervals, or else it would flash too much.

And I'm not so sure how the stat window did it, but when you were closer to the enemy, and there were multiple enemies, the enemy that was the closest would appear on the top of the list, and farthest enemy at the bottom.

But what I'm trying to say is, It'd be really nice to have 2 stat windows! Is it just not possible?
So, when it refresh the grid "flashes"? You could try:

winset(src, "enemygrid", "cells=2xNumberOfRows")


Change NumberOfRows to the number of rows of your grid.
In response to PkMax
It's flashing because you're setting the grid back down to 0x0. You don't need to do that, just update the final length at the end.

Also, the reason the stat panel probably displayed them ordered by distance is because view() returns them in that order. If you don't want the list order to be preserved across updates and you don't need access to the Evil_Enemies_List, you could simplify your code considerably:

    proc/GetEnemyData()
spawn()
while(1)
var/count = 0
for(var/mob/ai/E in oview(10,src))
if(E.enemy == 1 && E.breakable == 0)
count++
src << output(E,"enemygrid:1,[count]")
src << output(E.HP,"enemygrid:2,[count]")
winset(src, "enemygrid", "cells=2x[count]")
sleep(10)
Ohhh, that makes sense! Thankyou for the help.

But I wanted to address one more thing. Would it really be bad to refresh at a rate of every tick? Cause I have it running at sleep(0.25), and the tick lag in my game is 0.25, and it seems to run ok.

Would it be bad running it with other players or something?
Well, it depends on how much of your bandwidth you want to spend updating that enemy list. I personally think every frame will be overkill, but it's up to you to weigh the costs and benefits.

I would say test it with a couple of people and see how high of a delay you can get away with without making it feel sluggish. You could try the new-ish network profiling feature to see how different delays affect network usage.