I need to delete a value in a table inside enemy_spawner.script
local enemys = {hash("/Instance0")} <---this guy
First thing first a factory created game object(aka. enemy.go) send a msg to a enemy_spawner.script
msg.post("/enemy_spawner", hash("enemy_destroyed"))
enemy_spawner.script recives this msg and then checks every element in a enemys table and compare is it the guy we want or not.
local enemys = {--there are lots of enemy here like 20 of them}
function on_message(self, message_id, message, sender)
if message_id == hash("enemy_destroyed") then
for i,p in ipairs(enemys) do
print(p, sender)
if p == go.get_parent(sender) then --Here's the critical line--
print("YESSS BABYYYYYYYYYYYYYYYYYY")
print("Destroy the ",enemys[i])
table.remove(enemys,i)
end
end
end
end
and then the console output is this:
DEBUG:SCRIPT: hash: [/instance1] url: [main:/instance1#enemy]
So this means the script doesnt find any equivalent.(whıch is imposible because every enemy inside this table)
The problem is i dont know how to compare a hash and a url.