Hi
I was wondering if this is possible to "ignore" the prefix of a copied entity ?
For example : I do have finished 100% my chest script and the treasure received is based on the entity name on the map, trouble is, if I copy this same entity, there would be a suffix "_x" where x is a number that increase if the same entity has been pasted.
But, as you may read, if I go get the treasure, let's say I do named the treasure "small_key", and open one of it's copy "_2_small_key", the game cannot recognize the item _2_small_key since it read the entire entity:get_name().
I do have see that Solarus have an event to parse all prefixes (
http://www.solarus-games.org/doc/latest/lua_api_map.html#lua_api_map_get_entity) and I know how to retrieve the X value (the pool enigna from MoS helped in some way), but I don't really know how to ignore the prefix itself.
any help would be apreciated
This was my attempt in on_interaction(), but ended with "string expected, got nil", name is declared as local at the start of the script
for entity in map:get_entities("^_([1-9])_$" ..self:get_name()) do
if entity == find(self:get_name()) then
name = self:get_name()
end
end
also tried this, same thing occurs
for entity in map:get_entities() do
if map:get_entities():match("^_([1-9])_$" ..self:get_name()) then
name = self:get_name()
end
end