ID:157184
 
Grids are very confusing and I don't know what to put in quotes to make this work...

mob
proc
Add_Delay(D)
src.delay += D
var/column_count = 1
for(var/mob/m in battle_datum.Players)
if(!m.client) continue
winset(m,"playerdata","cells=0")
winset(m,"playerdata","columns=[battle_datum.Players.len]")
m << output("[src] data: 1,[column_count]","playerdata")
m << output("Current Delay - [src.delay]: 2,[column_count]","playerdata")
column_count ++


I wish there was a more simplistic way to work with them.
What are you trying to do?

BTW, this is what you are telling DM:
- For ever /mob looped
- Erase grid
- Output mob to grid

There's one thing wrong with that...

Easiest way:
winset grid cells to 0x0
for(loop)
output looped variable

Note the lack of winset in the loop. After you empty the grid and output something to it, it'll automatically refit
In response to GhostAnime
GhostAnime wrote:
What are you trying to do?


I'm looking to create a grid that looks like so:


EDIT: Apparently ASCII art doesn't work.

Basically like this though:


Player Names - Player delay

George - 45
Pleemoop -43


So everything after the dash is in the second row, with each column showing a name of player.




This seems quite hard to do...

In response to Speedro
Did you look up the skin reference to see how the output to the grid actually works?
Ref << output("Message output to grid", "[Grid ID]:[column],[row]")


So you if you want to output to the second column of row X (ex: player count looped): Y << output(Z, "Grid:2,[X]")

While we're at it, if you have a grid where something is potentially removed, it is best to null the grid before outputting in it, so it contains the correct items:
winset(X,"grid","cells=0x0")


Skeleton of what should be done:
Wipe grid
Define variable to keep count (X)
Loop through list
- output name to column 1, X
- output delay to column 2, X
In response to GhostAnime
Thanks.


Still have no idea what I'm doing though

mob
proc
Add_Delay(D)
src.delay += D
var/row = 1
for(var/mob/m in battle_datum.Players)
if(!m.client) continue
winset(m,"playerdata","cells=0x0")
m << output("PLAYER","playerdata: 1,1")
m << output("DELAY","playerdata: 2,1")

for(var/mob/x in battle_datum.Players)
row ++
m << output("[x]","playerdata: 1,[row]")
m << output("[x.delay]","playerdata: 2,[row]")
In response to Speedro
Speedro wrote:
Thanks.


Still have no idea what I'm doing though

Your code is being called from a mob/ but it is affecting other people...

This is how I would do it:

mob/proc/DoMahGrid()
var/list/L=battle_datum.Players
if(!L||!L.len) //If the list doesnt exist or is empty
world<<"\red Error: This list is blank or doesn't exist."
return 0
var/mob/M
for(var/i=1,i<=L.len,i++) //Loops through every entry in the list
M=L[i] //Set Mob = whichever spot in the list we are at
src<<output(M.name,"MyGrid:1,[i]") //This outputs the mob's name to the first column
src<<output(M.delay,"MyGrid:2,[i]") //And this their delay, to the 2nd column

battle_datum/proc/DoAllDasGrids()
for(var/mob/M in Players)
M.DoMahGrid()
In response to AJX
Simplest way

var/X=1
winset(src,"Grid","cell=0x0")
for(var/mob/M in world)
src<<output("[M]","Grid:1,[X]")
src<<output("W/e","Grid:2,[X]")
X+=1


I dislike giving out answears like this, but for this problem in particular, I think it will help you improve more by seing a code that actually work then how to make yours work

@AJX
If there are 10 people on and you update that list, if someone log out(i.e shortning the number of players logged in), it will bug the grid leaving players that arent logged in anymore still on the list or even have people that are logged in showing twice
In response to Abrax
Abrax wrote:
Simplest way

> 
> var/X=1
> winset(src,"Grid","cell=0x0")
> for(var/mob/M in world)
> src<<output("[M]","Grid:1,[X]")
> src<<output("W/e","Grid:2,[X]")
> X+=1
>
>

I dislike giving out answears like this, but for this problem in particular, I think it will help you improve more by seing a code that actually work then how to make yours work

@AJX
If there are 10 people on and you update that list, if someone log out(i.e shortning the number of players logged in), it will bug the grid leaving players that arent logged in anymore still on the list or even have people that are logged in showing twice.

You should probably note that the only change that was necessary was adding winset(src,"Grid","cell=0x0"), and explain that it sets the grid to being blank before you add the information.