Code:
obj/items/Blacksmithing
icon='Blacksmithing.dmi'
Ingots
Iron_ingot
icon_state="Iron ingot"
Copper_ingot
icon_state="Copper ingot"
obj/Non_items/Blacksmithing
icon='Blacksmithing.dmi'
Forge
icon_state="Forge"
verb/Forge()
set src in oview(1)
var/list/Orelist=list()
if(usr.Working==1)
return
else
usr.Working=1
for(var/obj/items/Mining/Ores/Q in usr.contents)
if(!locate(Q.type)in Orelist)
Orelist += Q
if(!Orelist.len)
usr<<"[A][RED]No ores found!"
usr.Working=0
return
var/obj/items/Mining/Ores/O = input("Which ore would you like to smelt?")as null|anything in Orelist
if(!O)
usr.Working=0
return
else
if(usr.Blacksmithing>=O.Forgelvl)
var/Maxlvl=O.Maxlvl // Maximum gain level
var/Expgain=O.Expgain // Experience gain
var/Ingot=O.Ingot // Used to grab the ingot to make
var/Sleeptime=O.Sleeptime // Used for how long to smelt selected ore for
var/Qty // Used to find out the amount of ores of the type you select
var/ForgeAmt // Used with the upcoming while() proc
var/Name=O.Name // Used for telling purposes
for(O in usr)
if(locate(O)in usr)
Qty++
var/obj/items/Mining/Ores/Amt = input("How many would you like to smelt?","Amount",Qty)as num
if(Amt<1)
usr.Working=0
return
if(Amt>Qty)
ForgeAmt=Qty
else
ForgeAmt=Amt
usr<<"[A][GREEN]You start blacksmithing!"
while(ForgeAmt>0)
sleep(Sleeptime)
usr<<"[A][BLUE]You forge a new [Name]!"
del(O)
ForgeAmt--
new Ingot(usr)
if(usr.Blacksmithing<Maxlvl)
usr.BlacksmithingXP+=Expgain
usr.Blacksmithingup()
usr<<"[A][GREEN]Smelting completed!"
usr.Working=0
return
else
usr<<"[A][RED]You need at least [O.Forgelvl] blacksmithing to forge this!"
usr.Working=0
obj/items/Mining
icon='Mining.dmi'
Ores
Iron_ore
icon_state="Ironore"
Forgelvl = 1
Maxlvl = 200
Expgain = 0
Ingot=/obj/items/Blacksmithing/Ingots/Iron_ingot
Sleeptime=20
Name="Iron ingot"
Copper_ore
icon_state="Copperore"
Forgelvl = 10
Maxlvl = 200
Expgain = 0
Ingot=/obj/items/Blacksmithing/Ingots/Copper_ingot
Problem description:
Theres a few problems:
(1) The part where it sees how many ores are in your inventory of the kind you selected, it counts all of the objects in your inventory.
Example:
-You want to forge iron ingots
---Inventory---
Copper Ore
Copper Ore
Copper Ore
Iron Ore
Iron Ore
Iron Ingot
It counts a total of 6 when it needs to only count 2
(2) During the while() proc, it doesn't delete the ore type you are smelting.
Example:
-You want to forge iron ingots
"You forge an iron ingot!"
new Ingot(usr)
del(O) << That wont work for some reason
In your while loop you will need to set O to a different ingot at the top of the loop, since you are deleting it partway through.