ID:270924
 
This is probably going to sound stupid, but is there any way to create static procs or variables in BYOND?

Basically, I want a global list to store the name of each type of tool object. I figure it would be easiest to do by having each tool object register itself with said list, but I don't want it to have to search the whole list to see if it's already been added. Figured it would be easiest done with static stuff.
You can have global procs or variables, but that's about it - no statics, I'm afraid.

You could generate that list using the typesof() proc, by the way.

var/list/toollist

proc/MakeToolList()
var/list/ret=list()
var/obj/tool/t
for(var/k in typesof(/obj/tool))
t=new k
ret+=t.name
toollist=ret.Copy()


Tada!
In response to Jp
Jp wrote:
You can have global procs or variables, but that's about it - no statics, I'm afraid.

You could generate that list using the typesof() proc, by the way.

> var/list/toollist
>
> proc/MakeToolList()
> var/list/ret=list()
> var/obj/tool/t
> for(var/k in typesof(/obj/tool))
> t=new k
> ret+=t.name
> toollist=ret.Copy()
>

Tada!

var/static/static_variable


btw, static is like global.