ID:145980
 
Code:set category
    verb
set category = "Speech"
say(mesg as text)
world << "[usr.key]: [mesg]"


Problem description:I don't understand why im getting an error. It says mobs.dm:14:error:set :invalid proc definition. Any help would be good thank you ^_^

verb
set category = "Speech" <------------1
say(mesg as text)
world << "[usr.key]: [mesg]"

1: cant do that mister.
has to come AFTER you define the verb
example
= tab
mob/verb
Say(T as text)
set category = "Speech"
world << "[usr.name]([usr.key]) says : [T]"


Obvously Nick hasnt contributed much to these forums and doesnt know that you have to explain what you are actually doing so newbies can understand.

Ok, well basically you have put set category in the wrong place. Here is what you should do. Oh and Nick, when you are posting code use '
' and '
' tabs.

    verb
say(mesg as text)//Oh also I find it easier to use msg instead of mesg
set category = "Speech"//As you see you need to put set category under the verb your defining
world << "[usr.key]: [mesg]"

I hope this can help you.

In response to ADT_CLONE
ADT_CLONE wrote:
Obvously Nick hasnt contributed much to these forums and doesnt know that you have to explain what you are actually doing so newbies can understand.

Ok, well basically you have put set category in the wrong place. Here is what you should do. Oh and Nick, when you are posting code use '
' and '
' tabs.
>     verb
> say(mesg as text)//Oh also I find it easier to use msg instead of mesg
> set category = "Speech"//As you see you need to put set category under the verb your defining
> world << "[usr.key]: [mesg]"
>

I hope this can help you.


Bah, dont use usr. Use src, much better. I am sure many people have discussed this before.
In response to XxDohxX

Bah, dont use usr. Use src, much better. I am sure many people have discussed this before.

Actually usr in verbs are OKay!
In response to Crzylme
Yes, they work. But using usr in verb will lead to usr in procs which is a no-no.
In response to Rky_nick
Thanks for the help :)

I was wondering if you could explain why you can't use [usr.key] and why you should use [src.key]
In response to XxDohxX
XxDohxX wrote:
Yes, they work. But using usr in verb will lead to usr in procs which is a no-no.

Yes but you telling him NOT to use usr in a verb when its okay to.

I've had many problems in which I COULD NOT use src in a verb thus making the verb useless.
In response to Seriphin
Seriphin wrote:

I was wondering if you could explain why you can't use [usr.key] and why you should use [src.key]

http://www.byondscape.com/ascape.dmb/LummoxJR.2002-1104/

Try reading this. It'll tell you what you need to know.
In response to Crzylme
no usr in verbs O.o
... Why you would like to know.
because verbs can be procs. and procs can be verbs.

At least I think... right XxDohxX?
In response to Green Lime
The problem with using usr in procs is that usr is automatically set to the initiator of the verb that starts the thread of procs. What this means is demonstrated below:
mob
verb/say(t as text)
view() << "[usr.key]: [t]"

NPC
verb/talk()
set src in view()
usr.say("Hello")
src.say("Hi!")

This 'talk' verb will result in the following:
Hazman: Hello
Hazman: Hi

Why? Here's why:
mob
verb/say(t as text)
view() << "[usr.key]: [t]" //This is saying usr. Usr is automatically set when I use the 'talk' verb.

NPC
verb/talk()
set src in view()
usr.say("Hello") // The code is specifically saying 'Hazman (usr), say "Hello"'
src.say("Hi!") //While this is saying 'Tell the usr, Hazman, to say, "Hi!"'

Of course, when I say 'saying' I mean calling, but to make it more understandable I used
In response to Crzylme
Crzylme wrote:
Seriphin wrote:

I was wondering if you could explain why you can't use [usr.key] and why you should use [src.key]

http://www.byondscape.com/ascape.dmb/LummoxJR.2002-1104/

Try reading this. It'll tell you what you need to know.

Mind you all this is being done within a verb. usr is perfectly all right in verbs. The only case where you should avoid it is if you're going to be calling that verb as if it's a proc. For example, if to make NPCs talk you route everything through say(), then you'd want to use src instead of usr.

As it is I'd leave it with usr.key.

Lummox JR
In response to XxDohxX
XxDohxX wrote:
Yes, they work. But using usr in verb will lead to usr in procs which is a no-no.

Uh, no. You have no idea what you're saying.

usr in verbs is not only okay; it's expected. You can use usr all you want in verbs. That has nothing to do with whether you misused it in a proc.

The only time usr is unsafe in a verb is if you're treating that verb as a proc and manually calling it from other places in your code.

As it is it's not wrong to use src.key, but it's just as valid as usr.key here unless that verb is going to be pulling double-duty as a proc.

Lummox JR
In response to Lummox JR
I think what he was getting at is that getting used to using usr (heh) in verbs might spread to accidentally using usr in procs as well... So, it's just better to be safe and never use usr at all, even when it's alright...

If you're paying attention, this isn't a problem, but these days, who's paying attention? lol
In response to SuperSaiyanGokuX
SuperSaiyanGokuX wrote:
I think what he was getting at is that getting used to using usr (heh) in verbs might spread to accidentally using usr in procs as well... So, it's just better to be safe and never use usr at all, even when it's alright...

If you're paying attention, this isn't a problem, but these days, who's paying attention? lol

Huh, what did you SuperSaiyanGokuX :P

So I was right, right Lummox JR?
Seriphin wrote:
Code:set category
>   verb
> set category = "Speech"
> say(mesg as text)
> world << "[usr.key]: [mesg]"
>

Problem description:I don't understand why im getting an error. It says mobs.dm:14:error:set :invalid proc definition. Any help would be good thank you ^_^


You're putting the category before the defined verb.

    verb
say(mesg as text)
set category = "Speech" // That's where it needs to go.
world << "[usr.key]: [mesg]"
In response to Green Lime
Green Lime wrote:
So I was right, right Lummox JR?

No, only if verbs are going to be used as procs, which is quite rare. And in those cases the author knows what they're doing.

Putting usr in a verb is natural and shouldn't be given a second thought, unless you're doing the above in which case all bets are off, and you'd know it.

Lummox JR