Game events request.

Place to get help with not working mods / modding interface.
Post Reply
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Game events request.

Post 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 :lol:
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Game events request.

Post 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 :lol:
Yes, I added the info to the wiki:
https://forums.factorio.com/wiki/inde ... torscanned

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Game events request.

Post 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 :lol:
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)
...
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Game events request.

Post by ficolas »

I think that onunit died, is on entity DIED (you need to shoot it)

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Game events request.

Post 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.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Game events request.

Post by ficolas »

I mean, you need to kill it, not to mine it

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Game events request.

Post 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. :cry:

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
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Game events request.

Post by kovarex »

You need to wait for next version to make it work :)
And the event will be called onentitydied

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Game events request.

Post 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. :)
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Post Reply

Return to “Modding help”