ID:136542
 
I was wondering if you could put in a feature that lets us create pointers to functions using variables. It would really be beneficial to a lot of people who want to call different procs and verbs without using lengthy switches. This could be useful for all sorts of things, like creating AI systems to let NPC's act with verbs and such, as well as many others.

-Koshigia-
According to the helpfile for the call proc, you can already do this. I admit, I have not tried it in recent memory though.
Koshigia wrote:
I was wondering if you could put in a feature that lets us create pointers to functions using variables. It would really be beneficial to a lot of people who want to call different procs and verbs without using lengthy switches. This could be useful for all sorts of things, like creating AI systems to let NPC's act with verbs and such, as well as many others.

-Koshigia-
<code> mob/proc/AI() if(!length(args)) return 0 var/a=args[1] args -= a call(src,a)(args) </code>
That will call a procedure by the name of the first argument passed to AI, with the rest of what is passed to AI as argument(s). Ie:
<code> turf/Entered(O) for(var/mob/npc/a in src) a.AI("EnterRoom",O) </code>
Unless im missunderstanding you?
Alathon\\
In response to Alathon
Actually, now I feel like an idiot. I forgot all about call proc. Well, I no longer need the pointer anymore with the new reminder :P. Thank you AC and Alathon.

-Koshigia-