ID:172315
 
How would I make a verb appear when a user is standing next to an object, and then disappear when they walk away? Example: A player walks up to a punching bag, and the hitbag verb appears so they can train.
obj
NAMEOFOBJ
icon = 'icon.dmi'
verb
VERBNAME()
set src in view(1)
//stuff for the verb to do.


~Ease~
In response to Ease
This is what I have:

pbag
icon_state = "pbag"
density = 1
verb
Hitbag()
set src in oview(1)
src.exp += 9
if(src.exp>=src.expneed)
src.lvl += 1
src.exp -= src.expneed
src.expneed +=13
src.HP += 11
src.MP += 8
src.str += 3
src.def += 4
world << "<font color='#FF33FF'>[src.name] has reached level [src.lvl]!</font>"


I keep on getting indeinfed var errors when I compile, and the variables ARE defined. How would I fix this? Changing them to usr.HP doesn't work either.


ALSO: This is a building game, so I'm also trying to make it so that a player can build a sign and then read it. The sign is an obj, and it's name becomes whatever the player wants the sign to say. What proc do I use to make it display the sign's name? Bump() and Enter() don't work
In response to Mooseboy
Firstly, I would put the "if" level up part into a proc. Secondly, all of yours "src"s are adding the the Pbag, not the player. And thirdly, NO MORE PBAGS!! We hate them!

~Ease~
In response to Mooseboy
Mooseboy wrote:
This is what I have:

pbag
icon_state = "pbag"
density = 1
verb
Hitbag()
set src in oview(1)
src.exp += 9
if(src.exp>=src.expneed)
src.lvl += 1
src.exp -= src.expneed
src.expneed +=13
src.HP += 11
src.MP += 8
src.str += 3
src.def += 4
world << "<font color='#FF33FF'>[src.name] has reached level [src.lvl]!</font>"


I keep on getting indeinfed var errors when I compile, and the variables ARE defined. How would I fix this? Changing them to usr.HP doesn't work either.

First of all, it would be better to make a proc instead of typing that for more objs in your game.

mob/proc/levelup()
if(src.exp>=src.expneed)
src.lvl++
src.exp = 0
src.expneed += 13
src.HP += 1
src.str += 3
src.def += 4
world <<"[src] has reached [src.lvl]"

obj/
pbag
icon_state = "pbag
density = 1
verb/Hit_bag()
set src in oview(1)
usr.exp += 9
usr.levelup()


Also, you can't just type in "icon_state = pbag". There needs to be a dmi file with the icon state set in it.
In response to SSJ4_Gohan_Majin
well its in an object GROUP and they all use the same dmi file, its defined earlier so technically, i CAN just use the icon state thingy >8D
In response to Ease
I myself don't like pbags, but I'm too lazy to make monsters an stuff - i DID read the bwicki thing on that. Very interesting and true.

As of now, I'm not getting any errors, but thats only at compilation, it hasnt been tested yet. I'll post again if i have trouble, thanks
In response to Mooseboy
It works, but has anyone figured out the sign thing?

sign
icon_state = "sign"
density = 1
Bump(mob/M)
M << "[src.name]-[src.owner]"


That doesn't do anything, neither does Enter(). Help? Both name AND owner do exist, but the proc doesnt work
In response to Mooseboy
Mooseboy wrote:
It works, but has anyone figured out the sign thing?

sign
icon_state = "sign"
density = 1
Bump(mob/M)
M << "[src.name]-[src.owner]"


That doesn't do anything, neither does Enter(). Help? Both name AND owner do exist, but the proc doesnt work
atom/proc/Bumped()
return

atom/movable/Bump(atom/A)
A.Bumped(src)

obj/sign
icon_state = "sign"
density = 1
Bumped(mob/M)
M <<"[src.name] - [src.owner]"


If it works, credit goes to Foomer, he gave that to me a while back for my CTF game.
In response to SSJ4_Gohan_Majin
I have no idea why it worked. but It worked. Thanks Foomer 8/
In response to Mooseboy
Mooseboy wrote:
It works, but has anyone figured out the sign thing?

sign
icon_state = "sign"
density = 1
Bump(mob/M)
M << "[src.name]-[src.owner]"


That doesn't do anything, neither does Enter(). Help? Both name AND owner do exist, but the proc doesnt work

The Bump() proc is called for the atom that bumps into something, so unless your signs are running around bumping into people, that won't work :P

One of the best ways to do this is described here.
In response to Mooseboy
I would call Bump, if I ran into you. I would called Bumped if you ran into me. The sign isn't going to run into anybody, so it needs to call Bumped.

~Ease~
In response to Mooseboy
Mooseboy wrote:
I have no idea why it worked. but It worked. Thanks Foomer 8/

If you don't know why it works, please go read the link I posted.

Thanks
In response to Ease
ah - i didnt see bumped in the helpfiles.
In response to Mooseboy
That's because it, you know, isn't.