if(inp=="Dagger Blade")
var/obj/Items/Materials/Dagger_Blade/S=new(M.loc)
S.Quality=quality
O.BaseWeight-=0.4
O.Weight=O.BaseWeight
S.name="[QualityToText(quality)] [O.Material] [S]"
S.Material=O.Material
if(O.BaseWeight<=0) del O
if(inp=="Rod")
var/obj/Items/Materials/Rod/S=new(M.loc)
S.Quality=quality
O.BaseWeight-=1
O.Weight=O.BaseWeight
S.name="[O.Material] [S]"
S.Material=O.Material
if(O.BaseWeight<=0) del O
Problem description:
Compare the above two sections of code, for most instents and purposes, they are exactly the same. To the point where they were literally copied and pasted, and are part of the same proc.
Here is the good part.
The "Rod" item is crafted from a log with a weight of 10. When you craft 10 rods, the log is destroyed (nothing left of it).
The "Dagger Blade" item is crafted from a metal bar, with a weight of 4. Once 10 are crafted, it SHOULD be destroyed, but it is not, instead it's weight apparently becomes some random, crazy number, like 1.19209e-007.
Everything works FINE, up until the metal bar should be destroyed.
This happens with every item that is crafted from a metal bar.
For all intents and purposes, there is no different between the objects Log and Metal Bar, except for the three variables Weight, BaseWeight and Material.
Similarly, there is no different between a rod and dagger blade except for the above 3 variables.
I can eliminate the variable Material by making them both the same.
Can anyone explain just what this madness is? How the hell is BYOND failing at basic math?
Also, what's the point of Weight if its always going to be set to BaseWeight? BaseWeight, if it represents the original weight, shouldn't change, while Weight should, amirite? Or is that just a confusing variable name?