mob/verb/wink()
set src in view()
view() << "[usr] winks at [src]."
Instead of taking a mob as an argument, this verb defines a public verb on mobs that is
accessible to others in view, allowing them to wink at the mob. From the user’s point of view,
these two cases are identical. From the programmer’s view, however, it is sometimes more
convenient to use one technique over the other.
Suppose you wanted to make a special type of mob that when winked at would reveal a
magic word. In that case, the best way to do things would be to have the target of the wink be
the source of the verb. Then you can override the wink verb for the special mob type like this:
mob/guard/wink()
..()
usr << "[src] whispers, ’drow cigam!’"
What I don't understand is the set src in view()
Does that mean it is setting the src as mob that the code will execute to from the view() list? Or does that mean it will execute to ALL objects in view()? I'm assuming the first one since when I use the code in game, it only speaks to mobs that are in my view, including myself.
Now, if I change set src in view() to set src in oview(), that will only send messages to mobs other than myself correct?
Also the second code portion I am having trouble understanding.
The default proc on it and the explanation tells me that the pre defined mob/verb/wink is used as a sort of macro when the default proc is called after the mob/guard/wink().
But that makes no sense to me whatsoever, because if that is the case, then anytime someone winks at the guard, the guard would instantly wink back at the persons in view() or oview() on top of telling himself "usr" to whisper only to himself?
Someone please explain this as simple as possible for me, and it would be even cooler if you just commented the code snippets for me.
ID:155218
Aug 17 2011, 9:49 pm
|
|
In response to Truseeker
|
|
Okay so basically it's a different kind of if statement
mob/guard/wink() verb wink ..() Run original verb if true and src is in view/oview usr << "[src] whispers, ’drow cigam!’" guard whispers Do I got that correct? |
In response to Penguinsandwich
|
|
You can use <"DM"> <"/DM"> tags (without the "" quotes), they allow you to do this with the code displayed on the forum:
Penguinsandwich wrote: Okay so basically it's a different kind of if statement mob/guard/wink() //verb wink Do I got that correct? It's not a different kind of if() statement, when you write ..() it will run the originally defined node (wink()) right away, no checks. (Though you can use ..() Inside an if() statement). It's more like: mob/guard/wink() /*Since the original is mob/verb/wink(), it makes a wink verb for all mobs. |
The first one is correct,
That means your setting the source of the verb to any mob in your view. The source is who the verb belongs to, which is Whichever mob you choose in your view() list. (Because it's a mob verb.)
Yes, if you change view() to oview(), you won't be able to see what you typed yourself, only others in your view().
For the second portion:
I'll just explain this a bit. mob/guard is basically a specific mob that you would define in your code, so you could replace it with Knight, Wizard, or Goku if you wanted to, as long as you've defined it. Defining something is easy, just put Guard under mob (hit tab on your keyboard) and BAM it's defined.
Now since wink() was written out before (in the DM guide) and you've typed that in your code file, when you click wink() and choose the Guard to be the source aka src then you activate Guard's wink() which calls the default mob/verb/wink() with the "..()" operator, then "usr << "[src] whispers, ’drow cigam!’" <-That sends the message in the double quotes to the usr, not anyone else. If you don't want everyone in the view to know that you winked at the Guard, then you erase "..()" which is what calls the original wink().
Hope this helps and was basic enough, feel free to ask any questions if you don't understand.