ID:148965
 
I won't give all of the code just the part with the error
The part that is missing is what each item does. I have that part on my computer.

the error is


Mobs.dm:44:choice :warning: variable defined but not used


mob
Smithing
name = "Smither"
icon = 'Tiles.dmi'
icon_state = "anvil"
verb



Smith()
set src in view(1)
set category = "Skills"

var/choice = input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")
Codesterz wrote:
I won't give all of the code just the part with the error
The part that is missing is what each item does. I have that part on my computer.

the error is

Mobs.dm:44:choice :warning: variable defined but not used

It looks like you left out a little too much. Whatever's after the choice line is where you're going wrong, because you're telling it to use some other var where you probably meant to use choice. I'd say likely the source of this warning is in the next few lines.

Lummox JR
In response to Lummox JR
Actually, it looks like he meant to use switch(input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")) and so on. The warning is coming from not using the var you defined. It is NOT an error, and you can compile and run perfectly fine, but it is there to remind you that you have something you don't need, or you possibly botched a line of code.
In response to Garthor
Garthor wrote:
Actually, it looks like he meant to use switch(input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")) and so on. The warning is coming from not using the var you defined. It is NOT an error, and you can compile and run perfectly fine, but it is there to remind you that you have something you don't need, or you possibly botched a line of code.

That's what I was thinking, only as a rule I avoid switch(input()) situations anyway as it's too messy. It's easier to trap for errors by using a var.
My thought was that he's missing a line for switch(choice). This being the case, the rest of the proc may look like a bunch of ifs that belong inside switch().

Lummox JR
In response to Lummox JR
well here's the entire code.


mob
Smithing
name = "Smither"
icon = 'Tiles.dmi'
icon_state = "anvil"
verb



Smith()
set src in view(1)
set category = "Skills"

var/choice = input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")
if("Dagger")
if(usr.metal >= 100)
usr<<"You Smithed a Dagger"
usr.metal -= 100
new/obj/dagger(usr)


if("Short Sword")
if(usr.metal >= 250)
usr<<"You Smithed a Short Sword"
usr.metal -= 250
new/obj/shortsword(usr)


if("Bronze Sword")
if(usr.metal >= 500)
usr<<"You Smithed a Bronze Sword"
usr.metal -= 500
new/obj/bronzesword(usr)


if("Bronze Armor")
if(usr.metal >= 500)
usr<<"You Smithed a Bronze Armor"
usr.metal -= 500
new/obj/bronze(usr)
In response to Codesterz
Yep, I was right. You could have solved this just by reading my last post.

Codesterz wrote:
var/choice = input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")
if("Dagger")

And there's your problem, right there. That should either be if(choice=="Dagger") (and the same for the other ifs below it), or all your ifs should be in a switch() statement:
var/choice = ....
switch(choice)
...

Outside of the switch(), the string in your ifs isn't being compared to a var. The compiler doesn't know you want to see if choice is "Dagger", but thinks you merely want to know if "Dagger" isn't an empty string. Thus this first if() will always be true--and so will all the others after it. The only way to get it to function the way you want is to put it in a switch, or actually put in the choice== manually in all those ifs.

Lummox JR
In response to Lummox JR
Another error

Mobs.dm:49:error: Sword: missing comma ',' or right-paren ')'




mob
Smithing
name = "Smither"
icon = 'Tiles.dmi'
icon_state = "anvil"
verb



Smith()
set src in view(1)
set category = "Skills"
var/choice = input("What would you like to smith?") in list("Dagger","Short Sword","Bronze Sword","Bronze Armor")
if(choice==Dagger)
if(usr.metal >= 100)
usr<<"You Smithed a Dagger"
usr.metal -= 100
new/obj/dagger(usr)


if(choice==Short Sword)
if(usr.metal >= 250)
usr<<"You Smithed a Short Sword"
usr.metal -= 250
new/obj/shortsword(usr)


if(choice==Bronze Sword)
if(usr.metal >= 500)
usr<<"You Smithed a Bronze Sword"
usr.metal -= 500
new/obj/bronzesword(usr)


if(choice==Bronze Armor)
if(usr.metal >= 500)
usr<<"You Smithed a Bronze Armor"
usr.metal -= 500
new/obj/bronze(usr)
In response to Codesterz
Codesterz wrote:
Another error

Mobs.dm:49:error: Sword: missing comma ',' or right-paren ')'

Why in the world did you take the quotes away from those text strings? It shouldn't be if(choice==Dagger) but if(choice=="Dagger"), like it was (although before it didn't have the choice== part). You just introduced a brand new error for no reason at all.

Lummox JR
In response to Lummox JR
Oops didn't mean to take off the "