ID:143033
 
Code:
mob
Move()
if(mining)
mining=0
src<<"You are no longer mining."
..()
obj
proc
Mineit(obj/o)
if(o.ores>0)
var/ore=text2path("/obj/Ores/[o.name]")
usr.mining=1
usr<<"You begin to mine..."
while(usr.mining&&o.ores>0)
sleep(src.speeed)
if(!usr.mining)return
usr.contents+=new ore
o.ores--
usr<<"You received [o.name] ore!"
if(o.ores<=0){usr<<"There are no more ores left in this rock.";o.ReRock();usr.mining=0;return}
else{usr<<"There aren't any ores left in this rock.";return}


Problem description:
If the rock that the player is mining runs out of ores, it sets mining to 0 so that when the player moves it won't show the message "You are no longer mining.". But it still does, does anybody know why?
If your ganna make a good mining system you should read this demo:
http://developer.byond.com/hub/Megafartcannon/MiningDemo

Curzon.
In response to Curzon
I prefer my mining system, thanks though.
This is one reason why most people on the forum tell people not to use usr in procedures because they can screw you over such as here.

http://members.byond.com/ DreamMakers?command=view_post&post=35932

Somehow, try passing an argument which contains the /mob who is trying to dig so you can successfully reference to that particular mob rather than the first person to do it (aka usr).

Ex: obj/proc/Mineit(obj/o,mob/m)



Note that the above lecture is seen when you're not the only person in the game and you are the second, or so, person to do something (Try it, log in another key to your game and see what happens to the one who mined second in the same spot... just remember to set ores back to whatever number).

The reason why the message didn't appear when the ores were depleted is because the condition where you were checking if it was finished is WITHIN THE while() LOOP. The while() loop condition is if the person is still mining and while there's more than 1 ore. So when the ores reached <= 0, the while() break'd itself which is why the message did not appear... simply because the while() fulfilled its condition.

Suggestion: De-indent the condition checking if ores <= 0 by 1, so it is outside the while() loop.
In response to GhostAnime
Ok, thanks for telling me. I think I understand what you are saying. Is this right? If it is, it still has the same problem. When ores run out it displays the message but then when I move, it still calls the Move() proc where mining is 1 and displays that message too.
mob
Move()
if(mining)
mining=0
src<<"You are no longer mining."
..()
obj
Pickaxe
Bronze
icon_state="bronze pickaxe"
speeed=60
verb/Mine(var/obj/Rocks/p in get_step(usr,usr.dir))
Mineit(p,usr)
Iron
icon_state="iron pickaxe"
speeed=50
verb/Mine(var/obj/Rocks/p in get_step(usr,usr.dir))
Mineit(p,usr)
proc
Mineit(obj/o,mob/m)
if(o.ores>0)
var/ore=text2path("/obj/Ores/[o.name]")
m.mining=1
m<<"You begin to mine..."
while(m.mining&&o.ores>0)
sleep(src.speeed)
if(!m.mining)return
m.contents+=new ore
o.ores--
m<<"You received [o.name] ore!"
if(o.ores<=0){m<<"There are no more ores left in this rock.";o.ReRock();m.mining=0;return}
else{m<<"There aren't any ores left in this rock.";return}
ReRock()
var/o=text2path("/obj/Rocks/[src.name]")
src.icon_state="empty"
sleep(src.spawny)
new o(src.loc)
del(src)
In response to Evidence
Because it's waiting for ReRock() to return before it sets mining to 0. You're going to want to spawn() off the call to it so it runs in a separate thread instead.
In response to Garthor
Thanks for showing me where it was going wrong., I just put m.mining=0 before it called ReRock and it worked perfectly.