ID:263424
 
Code:
obj
punching_bag1
icon = 'bag 1.dmi'
density = 1
verb
hit()
set category = "Training"
var/stamina = 10
stamina += 1


Problem description:
I put some of my punching bags on the map and tested it and absolutely nothing happened when I came up to it. It didn't show up in my training stat panel and nothing happened when I right clicked on it. I was hoping for at least some kind of reaction when I came up to it. What did I do wrong? Also this is off topic but how could I make it so you will see the movement state of the bag whenever I hit it?

Firstly, why are you defining a variable called stamina for the punching bag?

Anyways, you probably want something like this instead :
mob/var/Stamina=10

obj/Punching_Bag
icon='bag 1.dmi'
icon_state="bag 1"
density=1
verb/Hit()
set category="Training"
src.icon_state="bag 1 moving"//change the bag's icon state to this to make it move.You just need an icon now.
sleep(1)//after 1 tenth of a second.
src.icon_state="bag 1"//the bag's icon state changes back to normal, or non-moving.
usr.Stamina+=1
In response to Dragon_fire6653
Dragon_fire6653 wrote:
Firstly, why are you defining a variable called stamina for the punching bag?

Anyways, you probably want something like this instead :
> mob/var/Stamina=10
>
> obj/Punching_Bag
> icon='bag 1.dmi'
> icon_state="bag 1"
> density=1
> verb/Hit()
> set category="Training"
> src.icon_state="bag 1 moving"//change the bag's icon state to this to make it move.You just need an icon now.
> sleep(1)//after 1 tenth of a second.
> src.icon_state="bag 1"//the bag's icon state changes back to normal, or non-moving.
> usr.Stamina+=1
>
Actually, rather than going through the trouble of switching to another icon state for 1/10th of a second, you can use the flick proc. It will flick through the new icon only once. You can look it up in the dm reference. So try adding something like this; rather than src.icon = 'blah.dmi' and the sleep and change the icon back.
flick('bagbehit.dmi',src)
In response to Avren
Hmmm... still won't work. It's doing the same as before. The verb still wont show up in training. Maybe I copied it wrong? This is what I put:
mob/var/Stamina=10

obj/punching_bag
icon = 'bag 1.dmi'
icon_state = "bag 1"
density = 1
verb/hit()
set category = "Training"
flick("bag 1 moving",src)
usr.Stamina += 1
In response to Red Lightning
That is some serious weirdness you had in your original code up there... I suggest reading some tutorials.

Your problem here, is that you didn't set when this verb should be available. By default, for mob/verb's, the verb is available if the player has that verb. However, for obj/verb's, by default, the verb is only available if the obj is inside the player (in his contents). You need to override that default behaviour to make it available when the obj (src) is in view(), etc. Look up the 'src setting (verb)' entry in the DM Reference.