ID:1157595
 
Code:


Problem description:
Basically i would like to compare an name to current names in the list and if there is more then one of the same name...remove leaving 1 and then adding it as a stack.

like say

Name
Name

would be

Name x2

any help would be appreciated.

list.Find() and some loops could do just fine
In response to Metamorphman
Metamorphman wrote:
list.Find() and some loops could do just fine

could you give me an example :(

my mind is just blank atm...can't think lol :/
Read up on what list.Find() does, and its arguments. You can loop through items in the list, use another loop with list.Find to check for duplicates of the item past its index in the list, then do what you will.
In response to Metamorphman
Metamorphman wrote:
Read up on what list.Find() does, and its arguments. You can loop through items in the list, use another loop with list.Find to check for duplicates of the item past its index in the list, then do what you will.

I know what it does im just confused on how i would compare multiple variables in a list and remove it if there is more than 1 and then stack it.

Galactic Soldier wrote:
._.
proc/stackList(array[])
> . = new/list
>
> for(var/x in array)
> .[x] ++

That's all you really need. To access how many are in the stack you do .[type] or whatever. It's an associative list.
mob/Login()
> var/test[] = list("a", "h", "d", "a", "f", "a")
> var/stacked[] = global.stackList(test)
>
> // Will display 3.
> src << stacked["a"]


Doesn't work for my case really

for example i am trying to compare multiple objects in a list which calls a variable for their name

i would need to compare 2 variables

dName, dQuality

i would need if(dName && dQuality == same as other) then to stack.
    inventory
format = "~$'inventory'"
priority = 1
Process(mob/user)
mb_msgout("Inventory:", user)
if(!user.contents.len)
mb_msgout(" Nothing.", user)
return
for(var/obj/Equipment/I in inv)
if(!I.isDB)
mb_msgout(" \[[CheckColor(I.dEnergy)][I.dEnergy]%[user.Reset]\] \[[I.dQuality]\] [I.dName] ({D[jru_Commafy(num2text(I.dWeight*user.Gravity, 6))] lbs{x).", user)
else
mb_msgout(" \[[I.dQuality]\] [I.dName] ({D[jru_Commafy(num2text(I.dWeight*user.Gravity, 6))] lbs{x).", user)


im trying to make the objects in this list stack
Thanks
no i figured it out im stupid sorry :(
Galactic Soldier wrote:
You sure 'bout that? :/

pretty sure.