ID:139053
 
Code:
    var/walls[]
var/starterobjs = list("Fancy", "Eerie", "Cool", "Tech")
switch(input("Which Starter Objects would you like?")in starterobjs)
if("Fancy")
walls+= typesof(/Buildables/Walls/Fancy)
for(var/w in walls)
var/path = text2path(w)
var/Buildables/Walls = new path()
bwalls+=Walls
if("Eerie")
walls+= typesof(/Buildables/Walls/Eerie)
for(var/w in walls)
var/path = text2path(w)
var/Buildables/Walls = new path()
bwalls+=Walls
if("Cool")
walls+= typesof(/Buildables/Walls/Cool)
for(var/w in walls)
var/path = text2path(w)
var/Buildables/Walls = new path()
bwalls+=Walls
if("Tech")
walls+= typesof(/Buildables/Walls/Tech)
for(var/w in walls)
var/path = text2path(w)
var/Buildables/Walls = new path()
bwalls+=Walls


Problem description:
Basically, I am working on a building system that uses datums. A newbie gets a set of the datums and is able to chose from certain themes...but I can't seem to get typesof() working with new.
Besides the above code, I have tried maybe 3 alternate solutions, yet none have worked with me. I know it's possible to type a path, then use text2path to define a variable, then use new for that variable (I have another piece of code that perfectly uses the process) so it must be in the way I defined the path list using typesof()...

All of the ones I have done have left me blank (though one way created a list of completely null datums...didn't even have the icon registered. I know cause I even used a specific null icon)

The one above is my most recent attempt, it finally returned something....tangible...in a way...
"Cannot create objects of type null."
so from what I get, there are only nulls in the list. How should I work with typesof() here?

try atom/Buildables (or whateves). That has to be the path of the datum as well to work.
In response to Lugia319
unfortunately, that just made everything error up...sorry
(though thanks for the quick reply)

It couldn't find the type path after I put /atom before buildables and thought I was talking about a var if I didn't use /
In response to Katsuri
you have to code the datum as atom

atom
Buildables
Wall
In response to Lugia319
Then it wouldn't be much of a datum.
This should work, the walls variable should be defined as a list. I also made some changes to make the code shorter :)

    var/list/walls
var/starterobjs = list("Fancy", "Eerie", "Cool", "Tech")
switch(input("Which Starter Objects would you like?")in starterobjs)
if("Fancy")
walls = typesof(/Buildables/Walls/Fancy)
if("Eerie")
walls = typesof(/Buildables/Walls/Eerie)
if("Cool")
walls = typesof(/Buildables/Walls/Cool)
if("Tech")
walls+= typesof(/Buildables/Walls/Tech)
for(var/w in walls)
var/path = text2path(w)
var/Buildables/Walls = new path()
bwalls+=Walls
In response to Lugia319
well...according to the help file (in this situation)

"You should not create instances of /atom directly but should use /area, /turf, /obj, and /mob for actual objects. The /atom object type exists for the purpose of defining variables or procedures that are shared by all of the other "physical" objects."

so...there's really no point in typing atom/ unless it was something like

atom/var
sharedvar


..plus...I don't think that's much of a problem since I have a similar instance working on a different piece of code. The only difference is that I don't need to define a list of types (via typesof, of course) so I can give the player a large amount of datums without typing "new/Buildable/etc" for each of the things I want to put in the list...

...lesson over. I'm sorry I run my mouth (fingers?) .-.

...whoops, posted late XD
thanks..lemme try that :3
In response to ExPixel
nope...I still get
"Cannot create objects of type null."

...maybe because you actually didn't change anything at all. var/listvar[] creates a list (and you can throw a number in there to limit the list size)

thanks for trying though ^^'
In response to Katsuri
I know how to initialize lists. Actually changing it to a list made my version work. I tested it with the brackets and it didn't work.
In response to Katsuri
Oh, I see why it didn't work for me (was checking for the wrong thing), I hate giving wrong answers :P. Anyway I figured out your problem, the things in the list aren't text but types.

Doesn't work:
mob
verb
Call_Directly()
var/X[]
X += typesof(/buldin/)
src<<"[length(X)]"
for(var/v in X)
src<<"[v] \..."
if(istext(v)) src<<"text yep"
else src<<"not text"
var/t = text2path(v)//because of this
var/buldin/a = new t
src<<"<font color = red>[a.type]</font>"


buldin
asdasd
e
wg
weg
w
eg
we
gw
eg
we
g
weg
w
eg
weg
w
eg
weg


Works:
mob
verb
Call_Directly()
var/X[]
X += typesof(/buldin/)
src<<"[length(X)]"
for(var/v in X)
src<<"[v] \..."
if(istext(v)) src<<"text yep"
else src<<"not text"
var/t = text2path("[v]")
var/buldin/a = new t
src<<"<font color = red>[a.type]</font>"


buldin
asdasd
e
wg
weg
w
eg
we
gw
eg
we
g
weg
w
eg
weg
w
eg
weg
In response to ExPixel
No, but you could then edit certain variables that would normally belong to objects, which seems to be the case.
In response to Lugia319
I am not editing variables, much less assigning new ones. I am merely trying to throw a lot of datums into a list so I don't have to program each and every one to go into the list..
sorry for that confusion :/
In response to ExPixel
progress!~ kinda
I got a datum, but then...I got an error
"runtime error: type mismatch: Arabian Wall (/Buildables/Walls/Fancy/Arabian_Wall) += Blue Wall (/Buildables/Walls/Fancy/Blue_Wall)"

...Seems as though there's a part changing the walls variable...INTO the wall...
actually....it might just be changing the value of the variable then trying to add a new one

strange...I don't see an area where a list could be changed into a normal variable (given, bwalls is programmed as a list...)

the error says to go to the line that says "bwalls+=wall"
YES I got it!
after screwing around quite a bit, I FINALLY found the problem...
my new code is this (fairly simple fix really):
    var/list/walls = list()
var/starterobjs = list("Fancy", "Eerie", "Cool", "Tech")
switch(input("Which Starter Objects would you like?")in starterobjs)
if("Fancy")
walls += typesof(/Buildables/Walls/Fancy)
if("Eerie")
walls += typesof(/Buildables/Walls/Eerie)
if("Cool")
walls += typesof(/Buildables/Walls/Cool)
if("Tech")
walls += typesof(/Buildables/Walls/Tech)
for(var/w in walls)
var/path = text2path("[w]")
bwalls.Add(new path())
mob/var/list
bwalls = list()

I decided to try working with the Add() proc. It was a good idea until I got "cannot execute null Add()" But I soon found an answer to that...
Unfortunately, I thought I HAD defined bwalls as a list...but so be it, I hadn't. I was thinking about what Pixel posted (his first post) and went to check...then fix.

Thanks guys for your help :3 (and I can't believe all that work for such a simple answer...)