ID:264506
 
Code:
obj
Hud
Unlockable
Learn_Techniques
icon_state = "learn tech"
Click()
var/learn = input("Do you want to learn all the techniques?\n- This is just temporary until all techniques are done","Learn Techniques") in list("Yes","No")
if(learn == "No") return
else
usr.techniques = initial(usr.techniques)
var/list/techs = typesof(/obj/Technique/)
techs -= /obj/Technique/
for(var/obj/Technique/T in techs)
var/A = new T
usr.techniques += A
..()


Problem description: Well, for testing purpose I want it so you can learn every technique defined as obj/Technique, but I keep getting runtime errors such as "usr.techniques += Fly; invalid" and i've tried alternate ways but it seems it just ends up clearing the techniques list.

YOU'RE DOING IT WRONG!
for(var/O in typesof(/obj/Technique/) - /obj/Technique/) 
if(!(locate(O) in usr.techniques))
new O(usr.techniques)
In response to Super Saiyan X
YOU'RE DOING IT WRONG!

Presumably, techniques is a list, not an atom. Therefore, supplying it as an argument to new() for the loc parameter won't work, because an atom's loc can't be a list. You'd have to do:

techniques += new O()
In response to Garthor
Since when can't a list be a location? o.0
I WAS NOT INFORMED OF THIS!
In response to Super Saiyan X
In response to Garthor
I've never had a problem with adding objects to a list before though.
In response to Super Saiyan X
usr.techniques = newlist(arglist(typesof(/obj/Technique)-/obj/Technique))
In response to Super Saiyan X
You can add objects to a list all you want. However, their loc won't be that list, and as the first argument to new() is the loc of the object to be created, you can't add an object to a list by using that argument to new().
In response to Kaiochao
You know, I was screwing around with something like this a while ago and I totally forgot about the arglist() proc. Though, it still doesn't work at compile-time so you can't use it in the manner I was trying to.
In response to Garthor
Your little tidbit helped, and the problem has been resolved, I thank everyone for helping me.