Same problem as before, when I move and obj to a list other than contents, it just shows the name of the obj, not the obj itself, so you can click on it and such. My code is:
mob
var/obj/list/stuff
proc/Get_Item()
var/obj/item = new /obj/book
usr.stuff += item
What that does is move the name of item into the list. I want the object itself to move into the list, is there anyway I can do this?
Thanks in advance.
ID:179640
![]() Nov 25 2001, 9:19 am
|
|
One way could be to add it to your contents AND your other list. Here's an example (not sure if it works, I'm rusty on stats):
mob var/list/misc Stat() if(statpanel == "Misc") for(var/obj/O in src.contents) if(O in src.misc) stat("",O) |
WizDragon wrote:
So, how would I get /obj/thing to appear where I want it to? Like away from the other contents? Okay, if I read between the lines correctly, you're looking for a system where you can display the user's inventory except for things like equipment, and display equipment separately. Correct? If so, then what you want to do is avoid this little snippet of code: stat("Inventory",contents)
That will show the entire contents list, which is what you don't want. However, you could modify it by subtracting items (or whole lists of items) you don't want to include there: stat("Weapon",weapon) That, or something like that, ought to work. Lummox JR |
Lummox JR wrote:
WizDragon wrote: Yes, but I'm doing spells, not equipment. If so, then what you want to do is avoid this little snippet of code: stat("Inventory",contents)
That will show the entire contents list, which is what you don't want. However, you could modify it by subtracting items (or whole lists of items) you don't want to include there: stat("Weapon",weapon) That, or something like that, ought to work. Tried it. Here's my code, in a more detailed way: mob/var/list/obj/spells mob/Stat() statpanel("Inventory",contents-spells) statpanel("Spellbook") stat("[spells]") mob/Witch/proc/Buy(mob/M as mob) shop code goes here var/obj/spell/magic //this is the thing that you are gonna buy spells += magic magic.Move(usr) That's generally what it looks like. All that happens, however, is that the obj(which is the spell) gets put into usr's Inventory instead, and nothing is displayed under usr's Spellbook. I'm doing spells like this because I want someone to be able to click on it and cast it. Please help! |
WizDragon wrote:
stat("[spells]") There's your problem. You need stat(spells), because "[spells]" will try to change the list to text form, which isn't what you want. Lummox JR |
Ok, I fixed that. The part of the code looks like:
mob/var/list/obj/spells mob/Stat() statpanel("Inventory",contents-spells) statpanel("Spellbook") stat(spells) obj/spell/Fire icon = 'fire.dmi' mob/witch/proc/Buy(mob/M as mob) shop code here var/obj/spell/magic = new /obj/spell/Fire usr.spells += magic magic.Move(usr) That does the same thing. Magic gets moved to Inventory, and there is NOTHING in spellbook. I'm just overly confuzzled here, so can you please help me once again? Thanks! |
As I mentioned in response to your other post on lists (this is the same question), the object itself is being added into the list; it just isn't "moving" in in the sense of Move() and atoms moving around the map. The name is not being added to the list, but the object is; what you're probably seeing is that whatever you do to display the list only shows you the names, but the list itself does have the correct data.
Again, you're confusing the functionality of lists with atoms. An ordinary list is not the same as an atom's contents list. You can add objects to a list just fine, but it doesn't "move in" like with the special-case contents list. container.contents+=thing is a special statement in BYOND equivalent to thing.loc=container. However, mylist+=thing will merely put a reference to the object in the list; the object's location (the atom that contains it) will not change.
Lummox JR