is there anything that can help me to understand how i can change verbs into procs so that i can have one proc that does the verb even if it changes...
if that sounds confusing here is an exzample
I want the usr to be able to press .center when near a npc and the npc talks to him...so instead of using a talk verb i want to use .center
ID:170425
Jan 25 2005, 5:59 pm
|
|
In response to Xeal
|
|
set hidden = 1
|
Motre wrote:
is there anything that can help me to understand how i can change verbs into procs so that i can have one proc that does the verb even if it changes... Well the first thing you need to do is stop saying "the usr". This nasty verbal shortcut puts usr foremost in people's minds so they end up using it in their code in places it has no business--like, for example, procs that used to be verbs. You really mean "the user", which is another way of saying "the player". But actually you mean a player, since BYOND is a multiplayer environment. On to the question. Just create a mob proc that will do what you want, but in this proc, use src instead of usr. When you call that proc from client/Center(), call it as usr.theproc(). client/Center() The only real trouble from there is figuring out which NPC you're talking to. Unlike in a verb where you could use "set src in oview(1)" or such, here src is a player and the NPC is something else. So now you have to find the NPC nearby. You have a few options, including these: 1) You can talk to the one you're facing. 2) You can talk to any NPC within 1 tile. So here's some code for the facing form: mob/proc/Talk() And now for the form that talks to everyone within 1 tile: mob/proc/Talk() By the way, you're not limited to src<<M.Response() either. You can use something like M.Response(src) so that a Response() proc can do complex things like buying and selling for shopkeepers. For example: mob/shopkeeper This code should be very robust. Take a look at the if(!O || !wares[O]) test above. The !O test accounts for the player clicking the Cancel button, but !wares[O] is actually there as a redundant safety check. Any non-null choice returned from input() should be a valid one and should have an associated value in this list, but a little extra caution never hurts. These little things, and the if(!M || !M.client) check at the top of the proc, make your code a lot more stable. Lummox JR |
Make a .dms file
Than input this :
Put this somewhere else: