ID:264670
 
I'm having a little trouble doing something in a datum's verb. I'm am trying to give a player the ability to give a player verbs from that type that the verb is in. I seem to be getting an error though.

Example:
A
verb/give_this_verb(mob/player/p in world)
p.verbs += typesof(/A/verb)




so.. basically you want to be able to give another player a verb that you have?

Maybe it would be easier to locate that ability within the mob itself.
Instead of datum/verb*give verb*
Mob/verb*give verb*
That looks like an actual compiler issue - the compiler might not be able to handle references to a verb within that verb.

You might be able to deal with it like this:

var/list/A_verbs

world/New()
.=..()
spawn() A_verbs = typesof(/A/verb)

A
verb/give_this_verb(mob/player/p)
p.verbs+=A_verbs


Obviously not ideal, but might be a functioning workaround. Note: I haven't tested this.
In response to Jp (#2)
I was thinking of something else recently. I have multiple datums, each one parents the next. Say the last one is named C, could I do something like,

mob/verb/get_verbs()
var/C/C
src.verbs += C.verbs


to gain all verbs in my datums? This would be the most ideal work around if possible. (I probably have to create a new instance of /C then delete after using it.)
In response to Ulterior Motives (#3)
Is there an infinite cross-reference? If no, you can probably do it.

This compiles:
mob
verbholder
verb
give_verbs(mob/m)
var/mob/verbholder/n = new /mob/verbholder
m.verbs += n.verbs


This does not compile:
mob
verbholder
verb
give_verbs(mob/m)
m.verbs += typesof(/mob/verbholder/verb)


This compiles:
world/New()
verb_list = typesof(/mob/verbholder/verb)

var/list/verb_list

mob
verbholder
verb
give_verbs(mob/m)
m.verbs += verb_list


So does this, incidentally:
mob
verbholder
verb
give_verbs(mob/m)
m.verbs += verbs


So there are your workarounds.
In response to Jp (#4)
Okay, I'll have to mess around with it some.
mob
parent_type = /mob

This will compile as well. ;)
In response to Ulterior Motives (#5)
Yeah, but the workarounds I suggested will probably work. :P

Interestingly enough, this compiles:

mob
testmob
verb/test()
src+=/mob/testmob/verb/test


And so does this:

mob
testmob
proc/test()
for(var/k in typesof(/mob/testmob)) world << k


Not this, though (should be analogous to verb situtation)
mob
testmob
proc/test()
for(var/k in typesof(/mob/testmob/proc)) world << k


Looks like it's something to do with the way typesof is compiled in and proc/verb definitions. Any proc or verb definition that contains a typesof() containing itself will throw the error. Procedures and verbs that recurse the definitions also don't compile:
mob
testmob
proc/test()
for(var/k in typesof(/mob/othertest/proc)) world << k

othertest
proc/test()
for(var/k in typesof(/mob/testmob/proc)) world << k


Probably those typesof() lists are generated at compile-time (Well, they're known at compile time) and it's done at the same time that the list of procedure definitions is compiled.

(That code you've suggested doesn't actually compile. It crashes Dream Maker, actually. But I think you knew that.)

And while we're talking about odd DM code that compiles:
/?/proc/\((\"){var/\\\<;world<<\\\<<\"}


EDIT: Replaced incoherent punctuation code with slightly different incoherent punctuation code.
In response to Jp (#6)
I did this to get all the verbs I needed.

C
verb/give_verbs(mob/player/p)
var/mob/m = new /C
p.verbs += m.verbs
del(m)


And yes I knew that dream maker becomes non-responsive when entering that. Oddly enough giving a datum the same parent_type to which it's type is already, gives you an error instead.

I've seen many weird things compile. For instance I decided to try to help someone out on this fangame they had. The indentation was all wrong through the whole code. Some things had tabs, some didn't, some had weirdly placed tabs like:

something
something else
something

I changed one line an got over 90 indentation errors(all in one, longer than need procedure of course. =)). The whole thing fell apart like that, how it compiled before I have no clue.