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
ID:171884
![]() Jul 28 2004, 1:32 pm
|
|
From wot u've said u want i think this is wot u need:
obj 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> |
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 here is what would work well... obj |
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.
|
is this any better then?
obj |
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). =) |
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