ID:141860
 
Code:
mob
admin
verb
give_host()
set category="Host"
var/templist[]
for(var/mob/m in world)
if(!m.client||m==src) continue
templist+=m
if(templist)
var/mob/a=input("Who would you like the new host to be?","New Host")in templist
a.verbs+=typesof(/mob/admin/verb)
administrator=a


Problem description:

I've been searching for a while now and this is the first time I honestly can't spot something like this. I don't see any cross reference loop with this. :s
For a reason I can't really explain, doing verbs+=typesof(/mob/admin/verb) more than once causes a problem.
Example:
mob/admin
verb
give_admin(mob/m)m.verbs+=typesof(/mob/admin/verb)
give_admin2(mob/m)m.verbs+=typesof(/mob/admin/verb)


But here's an easy fix:
mob/proc
GiveAdmin()verbs+=typesof(/mob/admin/verb)

Just replace all instances of "m.verbs+=typesof(/mob/admin/verb)" with "m.GiveAdmin()".
Thanks. Now my only question is, why is templist only getting objects in it?
In response to Speedro
Objects?
In response to Kaiochao
Well, templist somehow only has obj's in it. There's no mob's even though I specifically put a 'for(var/mob/m)' in there.


Meh, I changed it. I don't care if the host makes him/herself the host again:

mob
admin
verb
give_host()
set category="Host"
var/mob/templister[]=new
for(var/mob/m in world)
if(m.client)
templister+=m
if(templister)
var/mob/a=input(src,"Who would you like the new host to be?","New Host")in templister
world<<"<b>\blue The new host is: [a]"
src.RemoveAdmin()
a.GiveAdmin()
administrator=a
In response to Speedro
I don't know if it matters, but I usually define lists var/list/List=list().
In response to Kaiochao
I'm pretty sure that's just a longer version of: list[]
That's because you're using /mob/admin/verb in a proc with the path /mob/admin/verb/give_host, which confuses the compiler. To fix it, you can just put the call in a differently-pathed proc, or simply specify the path in text string form for typesof() to use ( typesof("/mob/admin/verb") ) - this way the type is only stored, then evaluated at runtime instead of compile-time.

Speedro wrote:
I'm pretty sure that's just a longer version of: list[]

Doing var/MyVar[] doesn't actually initialize the list (MyVar stays with null value), though MyVar = list() or MyVar = new /list naturally does, and sets the var to that list with the = operator. There is a quirky shorthand for initializing the list though, it's var/MyVar[null], or 0 instead of null. It defines MyVar as a /list type and sets it to a new empty list. More crap on this here: [link] :P
In response to Kaioken
typesof() takes text as an argument? Never knew that; I probably would have added text2path() in there. Thanks!
In response to Jeff8500
_> Actually, procs like text2path() and also ispath() don't actually work with paths like /mob/verb or /any/datum/here/proc and as such (they return null and 0 respectively), and there may also be other quirks with them, so unfortunately you can't use them for some kinds of dynamic processing. It's lucky typesof() supports text itself though for one reason or another, so for this specific situation it's doable.