ID:158006
 
Okay, i'm trying to make my Proc as efficient as possible, what i'm wondering is, if it is possible to make a Variable in a list assigned to a proc. Like

ProcList["Fireball Spell"] = FireBallSpell()


Or even if there is a better way to do this?

Basically, they use the required incantation, it'll check if they know that spell. Then finally, it'll do.

src.ProcList["Spell Name"]

Which will call the proc.

It doesn't even need to be that exact way, but i'm wondering if it's possible to do something like this? It'd be much appreciated. I hate having to do a check for the Spell Name inside the proc, i'd like to to be automated. You know?

Edit:
For those who saw it, it said Jutsu cuz this is for my Naruto game, I just thought it'd be easier to describe/read if it was a Spell instead.
No, BYOND does not support function pointers. Technically, you can muck around with the call()() proc to call a proc by name, but that's really not advisable.

A better solution would be for your abilities to instead be wrapped in some sort of skill object, which you can then add to lists. The skills would then all inherit a "use()" proc which handles any usage of the ability.
This is one of the rare cases where I'll disagree with Garthor, because I think using the proc path (or name) along with call() would be a fine way to manage this. If each of your spell procs has a standard format (that is, they take the same arguments, even if they don't use them all), then you can easily set something like so:

ProcList["Fireball Spell"] = /mob/spells/proc/fireball


However Garthor's alternate proposal may be worth looking into because there are always different ways to organize this kind of thing, and there's merit in having a simple Use() proc to handle everything. What I can tell you about this particular method is that it won't involve the creation of any objects or datums to represent the spell being available; if you want such a thing however, like for statpanels, Garthor's option may well be the better way to go.

My only point of disagreement really is on call() being a bad idea to use; I think it's perfectly fine if you go into it with your eyes open. The degree of difficulty in using it makes it much harder to mess up with than, say, usr abuse or using the : operator inappropriately.

Lummox JR