ID:174203
Sep 18 2003, 9:40 pm
|
|
How would I go about doin that? I need to get a var from an obj contained in a list. The list is made with istypes(/obj) Ive tried var/S = usr.listname[index].var and :var and pretty much every other variation of those and still have 0 results. I can list the items just fine and get a certain record of it just fine but I cant figure out how to get a variable from it. Any one that can throw me a bone?
|
Aridale wrote:
How would I go about doin that? I need to get a var from an obj contained in a list. The list is made with istypes(/obj) Ive tried var/S = usr.listname[index].var and :var and pretty much every other variation of those and still have 0 results. I can list the items just fine and get a certain record of it just fine but I cant figure out how to get a variable from it. Any one that can throw me a bone? Arrr, ye can't use a dot or a colon after a list bracket, me hearty. First ye assigns the list item to another var, then ye use the dot. Lummox JR |
In response to Lummox JR
|
|
Arrr, ye can't use a dot or a colon after a list bracket, me hearty. First ye assigns the list item to another var, then ye use the dot. XDXDXDXDXDxDxDXDXDXDxDxdD THE YE USE THE DOT! THE DOT!!! i use to use the comma by accident -.o; |
In response to Lummox JR
|
|
Ive done exactly that but when I use the verb I do it in nothing happens at all. No errors or anything. It doesnt output anything. It just acts as if I never accessed the verb. But I know the list works cause Ive made tests to display it with verbs and so on. Heres my list
var/list/AvailableSpells <--- in normal mob variable section where I define all my vars. AvailableSpells = typesof(/obj/Spell) <--- in Login() And heres my verbs ListSpells1() var/Slot1 for(var/Index = 1, Index < usr.AvailableSpells.len, Index++) Slot1 = usr.AvailableSpells:Slot1 usr << "[Index]) [usr.AvailableSpells[Index]]" usr << "Slot1: [Slot1]" ListSpells2() for(var/Index in usr.AvailableSpells) usr << "Index: [Index]" ListSpellNames() for(var/obj/CheckItem in src.AvailableSpells) world << CheckItem.name ListSpell(N as num) if (N == 0) usr << "Lists do not store a value at 0 please do not enter 0 as a refrence" return if (N >= usr.AvailableSpells.len) usr << "That refrence to the list will either return an out of bounds or the parent class" return else usr << "[N]) [usr.AvailableSpells[N]]" I got one for iterrating thru it with an index one for just just displaying everything in it one for getting a specific record in it and then the exact code Volte posted about what he and you said about assigning the record to a var then usin .varname Maybe you guys can tell me whats goin wrong. |
You can loop through the list;
~>Volte