The _init_name function gives you the name of the entity as well as the id, you just store them in a list for later use.
Look at the script attached to see how it can be used.
All entities that you need to get the ids of by name will have to have a script attached so if you are using many different scripts just make the list global and you can access it from any script. Always start global variables with g_ so that 1) it reminds you that they are indeed global, 2) there is less chance of accidentally updating a global variable instead of a local one and 3) the GG save game mechanism should save them for you.
To use a global list properly do the following in each script that needs to access it:
g_listname = g_listname or {}
What this does is either use an existing declared list or (if it has not yet been declared) declare a new one.
This way it doesn't matter which script gets called first the global variable will be declared and used safely.
If all accesses to the variable are in one script attached to many entities make the variable local as local variables are much quicker to access though.
Been there, done that, got all the T-Shirts!