ID:155218
 
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.
Penguinsandwich wrote:
mob/verb/wink()
set src in view()
view() << "[usr] winks at [src]."

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.

The first one is correct,
set src in view()

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.)



Now, if I change set src in view() to set src in oview(), that will only send messages to mobs other than myself correct?

Yes, if you change view() to oview(), you won't be able to see what you typed yourself, only others in your view().

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?

For the second portion:
mob/guard/wink()
..()
usr << "[src] whispers, ’drow cigam!’"


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.
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
> ..() //Run original verb, if true and src is in view/oview
>
> usr << "[src] whispers, ’drow cigam!’" //guard whispers

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.
"Now" your redefining wink for the Guard, remember that you choose the src from the view() list?
Well, if "Guard" is the source, you will use "His" redefined wink(), but remember--*/


..() /*Run original wink() verb. So we're calling the original wink to go first, which tells
everyone in our view list who we winked at, remember "view() << "[usr] winks at [src]?*/


usr << "[src] whispers, ’drow cigam!’" /*guard whispers to the only the user, which is him who has
accessed Guard's wink() verb.*/