ID:145136
 
Code:
turf/obj/anvil
icon = 'OBJ.dmi'
icon_state = "anvil"
layer=4
density=1
verb
Smith()
set src in oview(1)
var/obj/Items/Smith/Hammer = locate(/obj/Items/Smith/Hammer) in usr.contents
if(Hammer)
var/smithing = input("What would you like to create?","SMITH MENU")in list("Iron Sword","Cancel")
if(smithing == "Iron Sword")
// for(var/obj/Items/Smith/I in src.contents)
// if(istype(I, ironitemType))
var/obj/Items/Smith/Iron_Bar = locate(/obj/Items/Smith/Iron_Bar) in usr.contents
if(Iron_Bar)
if(Iron_Bar>=5)
Smithstart
src.contents.Remove(Iron_Bar)
del(Iron_Bar)
ironswordhowMany -= 1
if(ironswordhowMany <= 0)
usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
usr << "<font size=1><font color=green>You smith an Iron Sword!"
return
else
goto Smithstart
// break
else
usr << "<font size=1><font color=yellow>You need 5 iron bars to make an Iron Sword!"
return
else
usr << "<font size=1><font color=yellow>You need a hammer to start smithing!"
return


Problem description:

For some reason this won't work. Can anyone direct me on what I did wrong?
Kind of hard to tell what's wrong with it if you don't give us any error messages.

The things I see wrong.
1) you need to fix your indents.
2) if(istype(I, ironitemType))
What is this? I believe it should be..
if(istype(I,/obj/items/Iron))
3) Also; why the heck do you have /turf/obj? If you want to make it an obj, just do /obj/
In response to Flame Sage
var/ironswordhowMany = 5    //How many of the item we want to delete.
var/ironitemType = /obj/Items/Smith/Iron_Bar //The path type of the items we're trying to delete.

Sorry I forgot to include the vars.
try switching your usr. for src. that should help. It helped me when I did lvling up for my mining system
In response to FriesOfDoom
Didn't help me...
In response to Drakiel
HMM LET ME SEE IF i CAN GET RID OF ANY USELESS STUFF
HMM LET ME SEE IF i CAN GET RID OF ANY USELESS STUFF (Adding the vars you showed)
<dm>
var
ironswordhowMany = 5 //How many of the item we want to delete.
ironitemType = /obj/Items/Smith/Iron_Bar //The path type of the items we're trying to delete
turf/obj/anvil
icon = 'OBJ.dmi'
icon_state = "anvil"
layer=4
density=1
verb
Smith()
set src in oview(1)
//var/obj/Items/Smith/Hammer = locate(/obj/Items/Smith/Hammer) in usr.contents <-- waste of time if used just once
if(!(locate(/obj/Items/Smith/Hammer) in usr.contents))
var/smithing = input("What would you like to create?","SMITH MENU")in list("Iron Sword","Cancel")
if(smithing == "Iron Sword")
var/Iron_Bar=0
for(var/obj/Items/Smith/I in usr.contents) //„˛ said src.contents beforeˇK
if(istype(I, ironitemType)) Iron_Bar++
// var/obj/Items/Smith/Iron_Bar = locate(/obj/Items/Smith/Iron_Bar) in usr.contents „˛ this causes only one to be found.
if(Iron_Bar>=5)
Smithstart
for(var/obj/Items/Smith/I in usr.contents)
if(istype(I, ironitemType))
del(Iron_Bar)
ironswordhowMany --//saying samething as -=1
if(ironswordhowMany <= 0)
usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
usr << "<font size=1><font color=green>You smith an Iron Sword!"
return
else
goto Smithstart
// break
else
usr << "<font size=1><font color=yellow>You need 5 iron bars to make an Iron Sword!"
return
else
usr << "<font size=1><font color=yellow>You need a hammer to start smithing!"
return


Hmm I think I forgot something in there.. anyways I am at work so the whole thing may be wrong

- GhostAnime
In response to GhostAnime
You can also restructure this and remove that goto of yours. Here's a little shove in the right direction:

for( null; ironswordhowMany > 0;ironswordhowMany-- )
var/ironswordhowMany = 5    //How many of the item we want to delete.
var/ironitemType = /obj/Items/Smith/Iron_Bar //The path type of the items we're trying to delete.



turf/obj/anvil
icon = 'OBJ.dmi'
icon_state = "anvil"
layer=4
density=1
verb
Smith()
set src in oview(1)
// var/obj/Items/Smith/Hammer = locate(/obj/Items/Smith/Hammer) in usr.contents
if(!(locate(/obj/Items/Smith/Hammer) in usr.contents))
usr << "<font size=1><font color=yellow>You need a hammer to start smithing!"
return
else
var/smithing = input("What would you like to create?","SMITH MENU")in list("Iron Sword","Cancel")
if(smithing == "Iron Sword")
var/Iron_Bar = 0
for(var/obj/Items/Smith/I in usr.contents)
if(istype(I,ironitemType))
Iron_Bar++
if(Iron_Bar>=5)
Smithstart
for(var/obj/Items/Smith/B in usr.contents)
if(istype(B,ironitemType))
del(B)
ironswordhowMany --
if(ironswordhowMany <= 0)
usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
usr << "<font size=1><font color=green>You smith an Iron Sword!"
return
else
goto Smithstart
// break
else
usr << "<font size=1><font color=yellow>You need 5 iron bars to make an Iron Sword!"
return


It compiles and it looks like it would all work, but when I go to try and smith it says I need 5 iron bars. I guess its not detecting all my iron bars, but I thought for would scan all. Now im stumped.
var/ironswordhowMany = 5    //How many of the item we want to delete.
var/ironitemType = /obj/Items/Smith/Iron_Bar //The path type of the items we're trying to delete.

turf/obj/anvil
icon = 'OBJ.dmi'
icon_state = "anvil"
layer=4
density=1
verb
Smith()
set src in oview(1)
// var/obj/Items/Smith/Hammer = locate(/obj/Items/Smith/Hammer) in usr.contents
if(!(locate(/obj/Items/Smith/Hammer) in usr.contents))
usr << "<font size=1><font color=yellow>You need a hammer to start smithing!"
return
else
var/smithing = input("What would you like to create?","SMITH MENU")in list("Iron Sword","Cancel")
if(smithing == "Iron Sword")
var/Iron_Bar = 0
for(var/obj/Items/Smith/I in usr.contents)
if(istype(I,ironitemType))
Iron_Bar++
if(Iron_Bar>=5)
// Smithstart
for( var/i = 0; i < 6; i++ )
var/obj/Items/Smith/B = locate() in usr.contents
// for(var/obj/Items/Smith/B in usr.contents)
// if(istype(B,ironitemType))
if( istype( B, ironitemType ) )
del(B)
// ironswordhowMany --
// if(ironswordhowMany <= 0)
usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
usr << "<font size=1><font color=green>You smith an Iron Sword!"
return
// else
// goto Smithstart
// break
else
usr << "<font size=1><font color=yellow>You need 5 iron bars to make an Iron Sword!"
return

After some help, this is how I modified it to be. The only problem is that now it deltes 1 bar and makes 1 sword were it should be deleting 5 bars.
In response to Drakiel
Close, you just gotta de-indent some lines to keep it out of the loop (I will remove the uncommented lines from your post:
                      for( var/i = 0; i < 6; i++ )
var/obj/Items/Smith/B = locate() in usr.contents
if( istype( B, ironitemType ) )
del(B)
usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
usr << "<font size=1><font color=green>You smith an Iron Sword!"
return


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Close, you just gotta de-indent some lines to keep it out of the loop (I will remove the uncommented lines from your post:
>                       for( var/i = 0; i < 6; i++ )
> var/obj/Items/Smith/B = locate() in usr.contents
> if( istype( B, ironitemType ) )
> del(B)
> usr.contents+=new/obj/Items/equipment/arms/right/Iron_Sword
> usr << "<font size=1><font color=green>You smith an Iron Sword!"
> return
>

- GhostAnime

Now the only problem is that after I create an Iron Sword it deletes only 4 bars from my inventory. Then, I make another one and it doesn't delete any more. I tried to reset the Iron_Bar var to 0 at the end but that didn't do anything. Can anyone see the problem in the loop?