ID:149239
 
My mind is blanked, i'm stumped and feeling dumb.
For smithing in my game, it's only deleteing 1 ore no matter what i try, so thats what i got in this code, deletes 1 ore.
mob
Miner1
icon = 'man2.dmi'
density = 1
verb
Talk()
set src in view(2)
var/tmp/blacksmith = input("Welcome to the Smithing shop, what may i help you with on this fine day?") in list ("Smith","Cancel")
if (blacksmith == ("Smith"))
var/pick = input("What do you want to make?") in list ("Bone Armor","No")
if(pick == "Bone Armor")
if(usr.ore >= 2)
var/list/L = new
for(var/obj/ore/O in usr)
if(istype(O,/obj/ore))
L += O
L += "Bye"
var/obj/item = input("Which ore you want to use?","???")in L
if(item == "Bye")
usr << "No ores sorry."
return
usr.contents+=new/obj/armor/Bone_Armor
usr << "Smithed 1 bone armor."
usr << "Enjoy your Armor!"
del(item)
ore=0
usr.smithing+=1
else
usr << "Aw, dude, not enough ores!"
return



Now, if usr.ores <= 2

Then it will create bone armor and delete 2 ores, i cant get it to delete 2, only 1 so im depressed.
Anyone?

RaeKwon
It is because you 'del(item)' refers to the list, not the player's contents.

Try running another loop on the character's contents for the particular ore, and delete it that way.

- Malver
In response to Malver
Malver wrote:
It is because you 'del(item)' refers to the list, not the player's contents.

Try running another loop on the character's contents for the particular ore, and delete it that way.

- Malver

Malver, listen, i don't want abunch of loops in my code causeing it to lag, i would think somthing like this would work -
for(var/obj/ore/O in usr)
Del O


But it don't work.
i dont want to many loops, some things you need 30-40 ore's for.
In response to RaeKwon
var/oreneeded = 20
var/ore = 0
for(var/obj/O in usr)
if(istype(O,/obj/ore))
if(ore < oreneeded)
del(O)
ore += 1
else break
In response to RaeKwon
RaeKwon wrote:
Malver, listen, i don't want abunch of loops in my code causeing it to lag

A "bunch" of loops? One more loop won't cause any noticable lag. Just try it first before making assumptions.

- Malver