Convert string to identifier

I have some strings I built using a script. I also have some variables whose names are the same as the strings.

How can I reference the variables using the strings? I.e. turn the string “HGN_PROBE” into the variable identifier HGN_PROBE? Can I access the globals table? Do I need to use rawget or rawset?


The best way I can imagine is to have a lookup table,


foo= "HGN_PROBE"

It’d be fragile to set up if your ship list is being actively developed, and tedious in any case, but I would think it should work.

Access to the globals table depends on your scope, but last I check you could get to it from a lot of places.