Page 1 of 1
Game events request.
Posted: Wed Mar 06, 2013 12:55 pm
by rk84
I'm hitting wall with events currently. I'm trying to do alarm system that would make radars more usefull.
Current idea: When entity is destroyed if in range of radar -> send message to player.
Problem is that "onunitdied" is not called for all entities. Only for "unit" type?
I guess the name makes sense. So other event name for other entities destruction?
While I was trying to find workaround. I got idea of connecting function to one of entity's methods. Could it be done?
Also could "onsectorscanned" -event give the scanning radar as parameter? I had some idea for this but I already forgot it

Re: Game events request.
Posted: Wed Mar 06, 2013 11:58 pm
by kovarex
Yes, onunitdied should actually be onentitydied, and should work for all entities that can die.
rk84 wrote:Also could "onsectorscanned" -event give the scanning radar as parameter? I had some idea for this but I already forgot it

Yes, I added the info to the wiki:
https://forums.factorio.com/wiki/inde ... torscanned
Re: Game events request.
Posted: Thu Mar 07, 2013 3:49 am
by rk84
kovarex wrote:Yes, onunitdied should actually be onentitydied, and should work for all entities that can die.
rk84 wrote:Also could "onsectorscanned" -event give the scanning radar as parameter? I had some idea for this but I already forgot it

Yes, I added the info to the wiki:
https://forums.factorio.com/wiki/inde ... torscanned
Thank you.
creepers are the only thing I have managed to get out of onunitdied.
Code: Select all
...
elseif event.name == "onunitdied" then
glob.player.print(event.unit.name)
...
Re: Game events request.
Posted: Thu Mar 07, 2013 4:57 pm
by ficolas
I think that onunit died, is on entity DIED (you need to shoot it)
Re: Game events request.
Posted: Thu Mar 07, 2013 5:06 pm
by rk84
ficolas wrote:I think that onunit died, is on entity DIED (you need to shoot it)
No. you get it even if you ram creepers with your car. And I have tried weapons.
edit: woo I'm a long handed.
Re: Game events request.
Posted: Thu Mar 07, 2013 5:10 pm
by ficolas
I mean, you need to kill it, not to mine it
Re: Game events request.
Posted: Thu Mar 07, 2013 7:54 pm
by rk84
ficolas wrote:I mean, you need to kill it, not to mine it
I'm not mining...
I used this script to test onunitdied. Can you get this script to print on screen non-unit -type entity with health? I can't.
Code: Select all
if event.name ~= "ontick" then
game.getplayer().print("Event: " .. event.name)
if event.name == "onunitdied" then
game.getplayer().print(event.unit.name .. " died.")
end
end
Re: Game events request.
Posted: Thu Mar 07, 2013 8:01 pm
by kovarex
You need to wait for next version to make it work

And the event will be called onentitydied
Re: Game events request.
Posted: Thu Mar 07, 2013 8:07 pm
by rk84
kovarex wrote:You need to wait for next version to make it work

And the event will be called onentitydied
ah ok. Sorry I though it was working for others. I Can't wait for update. Thank you.
