ID:171884
 
I tried to make it so when you Mine a rock more than 5 times the rock gets deleted

Rock
verb
mine()
src.Mined ++

and

obj/var/Mined = 0

and

proc/Mine()
if(Mined > 5)
del src

it said Mined was an undefined var though

Help is greatly appreciated
This is very messy try this instead
BTW i hope rock is idntified somewhere else in your coding. This will not mine ore it will not delete the rock all it will do is show you that when minedd = 5 it will call the alert
mob
var
minedd
Rock
verb
mine()
if (usr.minedd==5)
alert("This rock has broken!!")
else
usr.minedd += 1
From wot u've said u want i think this is wot u need:

obj
var
Mined = 0
obj
Rock
icon = 'pturfs.dmi'
icon_state = "door"
Mined = 0
mob
verb
Mine(obj/Rock/R in oview(1))
if(R.Mined<5)
//*insert mining code here* Everytime u need to use the rock use the variable R. The bit before the else command is a code to test and you should replace it with your mining code.
R.Mined ++
usr << "Rock mined [R.Mined] times"

else
alert("The rock breaks")
del(R)


You'd be better off making the rock an obj not a turf, if u have/will make it an obj then change Mine(turf/Rock/R) to Mine(obj/Rock/R)
Since I can't tell what your code is doing unless you format it properly and include everything:

<code>obj/rock var/amount = 5 verb/Mine() set src in range(usr, 1) usr << "You mine ore from \the [src]." src.amount-- if(src.amount <= 0) del(src)</code>
In response to DeathAwaitsU
That's terrible. The first, most glaring problem is the use of alert(). Not only is alert() annoying, but it will give you an error when someone mines a rock, gets the alert, and someone else tries to mine it. It will try to delete the same object twice. On top of that, the verb should belong to the rock, not the mob.
Artekia wrote:
I tried to make it so when you Mine a rock more than 5 times the rock gets deleted

Rock
verb
mine()
src.Mined ++

and

obj/var/Mined = 0

and

proc/Mine()
if(Mined > 5)
del src

it said Mined was an undefined var though

Help is greatly appreciated


here is what would work well...

obj
rock
icon = 'rock.dmi' //or whatever
density = 1
var/Mined = 0

verb/mine()
set src in oview(1)
//code for what happens when you mine

Mined++
if (Mined == 5)
view(5) << "The rock is destroyed..."
del(src)

In response to Jik
You DEFINITELY want to be using if(Mined >= 5) instead of if(Mined == 5) there. If the verb is called enough, Mined can equal 6 or more.
In response to Garthor
is this any better then?

obj
var
Mined = 0
obj
Rock
icon = 'pturfs.dmi'
icon_state = "door"
Mined = 0
verb
Mine(obj/Rock/R in oview(1))
if(R.Mined<5)
//*insert mining code here* Everytime u need to use the rock use the variable R. The bit before the else command is a code to test and you should replace it with your mining code.
R.Mined ++
vies(5) << "[usr] mines the rock"

else
view(5) << "The rocks breaks"
del(R)
In response to DeathAwaitsU
1. You should probably declare Mined under the rock object, unless you actually plan on mining tables, swords, or any other obj in the game. =)
2. The R variable is completely useless, the rock is src here.
3. Unless the rock is going to be in the players mob, he/she won't have access to the verb. You'll have to set src to something, oview(1) seems good.

Well, those are my problems with it. I hope you don't take this as me being mean, I'm just trying to help (you, along with the topic creator). =)
In response to YMIHere
Ah yea i didn't see most of that coz i just copied and pasted to give the rock the verb.

Thanks for the help and no i dont find u being mean because i'm here to learn and u taught :)