ID:140513
 
Code:
obj
Overhead
icon='Overhead.dmi'
icon_state=""//hmmif
density=0
layer=10
Click()
if(src.icon_state=="")
world<<"ITS ICON STATE IS BLANK"
switch(alert("What do you wish to turn this into?","","Machine Gun - 100","Grenader - 200"))
if("Machine Gun")
if(gold>=100)
gold-=100
src.icon_state="Machine Gun"
src.model=1
Check()
else
world<<"Not enough gold!"
if("Grenader")
if(gold>=200)
gold-=200
src.icon_state="Grenader"
src.model=1
Check()
else
world<<"Not enough gold!"
return
if(src.icon_state=="Machine Gun")
if(src.model==10)
world<<"This has no more upgrades!"
return
var/cost = model*100
switch(alert("Do you wish to upgrade this Machine Gun v[src.model] for [cost]?","","Yes","No"))
if("Yes")
if(gold>=cost)
src.model+=1
gold-=cost
else
world<<"Not enough gold!"
return
if(src.icon_state=="Grenader")
if(src.model==10)
world<<"This has no more upgrades!"
return
var/cost = model*100
switch(alert("Do you wish to upgrade this Grenader v[src.model] for [cost]?","","Yes","No"))
if("Yes")
if(gold>=cost)
src.model+=1
gold-=cost
else
world<<"Not enough gold!"
return
proc/Check()
for(var/mob/Enemies/M in view(7+src.model))
flick("[src.icon_state] Attack",src)
if(src.icon_state=="Machine Gun")
M.overlays+='Neon Blood.dmi'
M.health-=src.model+2
if(M.health<=0)
gold+=5
sleep(30-src.model*2)
Check()
return
if(src.icon_state=="Grenader")
M.overlays+='Neon Blood.dmi'
M.health-=src.model+3
if(M.health<=0)
gold+=5
sleep(40-src.model*2)
Check()
return


Problem description:

OK see where I put world<<"ITS ICON STATE IS BLANK"? Well that doesn't show, WHEN IT SHOULD =( is there something I'm not seeing or could this be a software bug?
Did you consider trying
if(!src.icon_state)
In response to Dark Prince X
Dark Prince X wrote:
Did you consider trying
> if(!src.icon_state)
>


^ This.

"" != (0 == null)

Garthor may pop in and correct me on this, but I believe that is the correct answer.
In response to AJX
Yeah, I was thinking Garthor was going to jump in and correct me for the 500th time. :p
In response to AJX
Yeah. I've done everything I could. I even put world<<"I" then world<<"[src.icon_state]" right before the if(src.icon_state=="") and it shows that the icon_state is indeed"".
In response to Ganing
Ganing wrote:
Yeah. I've done everything I could. I even put world<<"I" then world<<"[src.icon_state]" right before the if(src.icon_state=="") and it shows that the icon_state is indeed"".

... Did you try all of these:
if(icon_state==0)
if(icon_state=="")
if(icon_state==null)
if(!icon_state)

In response to AJX
Good news, after putting in the if(src.icon_state==null) it worked!
Bad news, after choosing machine gun, and grenader, it's icon_state would not switch to them. =(
In response to Ganing
That is because the cases in your switch statement do not match the options in the input.

In other news: your Check() proc is absolutely loathesome. You need to ditch the for() loop, use locate() instead, and ditch the recursive call to Check() and use a while() loop instead.
In response to Garthor
Tried doing it, and epically failed.
In response to Ganing
Yes. That is why I am suggesting you fix it.
In response to Garthor
I meant the locate and while(). I tried it. Failed, so went with what I got and it worked.