I prefer not to iterate over all the entities to search for.
I try to save the entity name in mod_storage. And then recover the entity when a new game starts.
I tried with 'minetest.luaentities[objectID]' according the wiki
But I get no result. What is that objectID? The name? What?
My code:
To create the entity (it works OK):
Code: Select all
local objectref = minetest.add_entity(pos, "name")
local entity = objectref:get_luaentity()
mod_storage:set_string("ent_name", entity.name)
Code: Select all
local ent_name = mod_storage:get_string("ent_name")
local entity = minetest.luaentities[ent_name]