ID:1809871
 
(See the best response by LordAndrew.)
Code:
mob/verb/Pause()
src.pause = !pause
for(var/obj/Slimes/Blueslime/O in world)
O.pause = !O.pause
for(var/obj/Cloud/V in world)
V.froz = !V.froz
var/list/TY = typesof(new /obj/Blink)
var/A = TY[0]
var/E = TY[1]
var/P = TY[2]
var/S = TY[3]
var/U = TY[4]
P.screen_loc = "10, 4"
A.screen_loc = "10, 5"
U.screen_loc = "10, 6"
S.screen_loc = "10, 7"
E.screen_loc = "10, 8"
src.client.screen += P


Problem description:

Am struggling hard with lists. >:|

The point of that snippet of code? To put a gathering of my objects into a small list, so I can add and remove them from my screen at will.

Along with this, the code is supposed to gather each and every individual object, add them into their own personal var, so I can edit the screen_loc at run time. I do this since I intend to reuse the object in other parts of the huds, and would need to change the screen loc constantly.

loading Slime Catchers System.dme
Z-- Debug.dm:19:error: P.screen_loc: undefined var
Z-- Debug.dm:20:error: A.screen_loc: undefined var
Z-- Debug.dm:21:error: U.screen_loc: undefined var
Z-- Debug.dm:22:error: S.screen_loc: undefined var
Z-- Debug.dm:23:error: E.screen_loc: undefined var
Z-- Debug.dm:14:warning: A: variable defined but not used
Z-- Debug.dm:15:warning: E: variable defined but not used
Z-- Debug.dm:17:warning: S: variable defined but not used
Z-- Debug.dm:18:warning: U: variable defined but not used
Slime Catchers System.dmb - 5 errors, 4 warnings


Errors:
Just so you can see what the compiler tells me.

Anywho, how I the world do I fix this? Probably an easy fix too.
Best response
There are actually several issues with your snippet that would only manifest at runtime.

var/list/TY = typesof(new /obj/Blink)

This line is definitely not accomplishing what you're trying to do. It looks like you want to populate a list with five Blink objects, but instead you're saying that TY is equal to the type-path of /obj/Blink.

(Also, you do not need new in typesof()).

Next, DM is a one-based language, which means indices begin at 1 instead of 0. var/A = TY[0] would result in an out of bounds error at runtime.

Lastly, your main issue is that you have not type-casted any of the letter variables P, A, etc. They're simply variables with no type associated with them, which is why you're receiving the undefined variable errors. You'd want to do...

var obj/Blink/A = TY[1] // and so forth.

// A more in-depth example.
obj/letter

mob/verb/Letters()
// Allocate a new, empty array with a length of 5.
var letters[5]

// Starting at index 1 and going up to 5, create a new instance of /obj/letter.
for (var/i = 1 to 5)
letters[i] = new /obj/letter

// Store each letter instance in a named variable.
var obj/letter/p = letters[1]
var obj/letter/a = letters[2]
// u, s, e.

p.screen_loc = "1,1"
a.screen_loc = "1,2"
// u, s, e.

/*
Instead of adding each individual letter to the screen, you can simply
add the letters list at once. This is because the variables p, a, etc
are references to the objects already in the list.
*/

src.client.screen += letters
. . .This is great learning material.

Also, I'll probably test it in a bit, but I suppose it'll be smart to just ask it here.

In your example, if I left the '[]' by letters blank, would that make the list potentially limitless? And if I added something else to the list that current was marked with a length of five, would the length automatically increase?
Probably best to check the reference (F1 in Dream Maker) and read up on how things work:
http://www.byond.com/docs/ref/info.html#/list

It should also be noted that all lists in DM never have a strict size. They can be changed at any time. This is valid in DM:
var/list/l = new/list(10)
l += 0 // now has 11 cells
@Gt: Yes and no. The number being provided in the initialization of the list inside those brackets is the initial size of the list. All lists in DM have a dynamic size and as such can grow or shrink when needed.
Having a separate type path defined for each and every potential screen letter is a design flaw. You simply will never need that. Instead, just set the relevant vars at runtime.

mob/verb/Pause()
src.pause = !pause
for(var/obj/Slimes/Blueslime/O in world)
O.pause = !O.pause
for(var/obj/Cloud/V in world)
V.froz = !V.froz
CreateBlinkText("PAUSE")

mob/proc/CreateBlinkText(txt)
if(!client || !length(txt)) return
var/obj/Blink/B
var/i, j, l=length(txt)
for(i=1, i<=l, ++i)
B = new
B.icon_state = copytext(txt, i, i+1)
j = i - (l+1)/2
B.screen_loc = "10, CENTER[j ? (j>0 ? "+[j]" : j) : ""]"
client.screen += B

Now that vertical blinky text effect can be used for other things as well. At the very least, you want to stay out of the trap of having a million different subtypes that aren't needed.
Bump.

Been trying on and off with this, utilizing Andrew's example. Only difference is this part

    for (var/i = 1 to 5)
letters[i] = new /obj/Blink/AA


I just add an additional child-type or w/e, it's called, since that's how my system is used. The problem? The keys actually display. Yet it only shows a single letter, even when I store each different obj into the list.

(I took this long due to procrastination, and I don't want to seem like a mooch. :C)
In response to Gtgoku55
You aren't using any arguments when you create the obj, how are you even finding out which icon state to set the letters icon file to?
The objs only have one icon_state.
In response to Gtgoku55
I don't understand. Are you not using screen based text with a customized font .dmi?
I love you, Fishman. That was the problem, apparently I'd have to note the icon_state as well. WHY THE HECK DIDNT I T%RY THAT BEFORE?

(I had figured since the objects already had a state set, that wouldn't be necessary. My mistake.)