ID:1951508
 
(See the best response by Lummox JR.)
At some points you have to "wrap" variables. Well, I thought that if you gave them the proper types that you could access their variables with as many periods as you want?

Like how I do here:
src.squad.soldier1.loc

// src is mob/attackable/player
// src has var/Squad/squad
// Squad has var/Soldier/soldier1
// Soldier is of parent_type /mob/Soldier (less to type when I do it this way)


But... here I'm getting the oddest of most odd errors. In fact, I have never encountered this error. I've encountered the issue itself, but it never produced the error I am about to show you:
Foo
var
fee

var/list/Foo/bar[]

mob/Login()
// no "wrapping" / incorrect
var/Foo/foo = new/Foo
bar[1].fee = 0
if(bar[1].fee == 0)
src << "FAAA!!"

// "wrapping" / correct
var/Foo/few = bar[1]
if(few.fee == 0)
src << "FAAA??"

/*
expected end of statement @ bar[1].fee = 0
missing comma ',' or right-paren ')' @ if(bar[1].fee == 0)
*/


It took me a minute or two to see what the problem was since I was rushing through writing the code. I'd like to avoid having to wrap it though. Is it possible?

Best regards,
FoofeebarFAA
Best response
You can't use the . operator after parentheses or brackets. The : operator has similar problems, but . will never work that way because the type of a list element or proc return value is unknown.

Also, there is no such thing in DM as a typed list.
In response to Lummox JR
Lummox JR wrote:
Also, there is no such thing in DM as a typed list.

It wouldn't hurt to continue using it as a reminder of what it is mainly suppose to hold?
The compiler has no concept of how to handle it. Besides which, that would only be useful in the event that the . operator could work alongside a list access operator syntactically, which it presently can't.