on_trigger_created_entity event not triggered

Place to get help with not working mods / modding interface.
Post Reply
goobboy
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Sep 30, 2018 7:19 pm
Contact:

on_trigger_created_entity event not triggered

Post by goobboy »

Hi,

I think I didn't understand something here :
When I launch a destroyer capsule, it never triggers the event on_trigger_created_entity

Code: Select all

--control.lua
script.on_event(defines.events.on_trigger_created_entity,
  function(event)
  	game.print("test")
  end
)
despite having set trigger_created_entity to true as specified here https://lua-api.factorio.com/latest/eve ... ted_entity

Code: Select all

--data.lua
data.raw["capsule"]["destroyer-capsule"].trigger_created_entity=true
data.raw["combat-robot"]["destroyer"].trigger_created_entity=true
I tested with both the capsule and the robot, just in case. I also tested with true as a string ("true").

I'm kinda lost here...

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: on_trigger_created_entity event not triggered

Post by Klonan »

It needs to be in the projectiles trigger effect, not in the entity or capsule prototype

Code: Select all

    type = "projectile",
    name = "destroyer-capsule",
    flags = {"not-on-map"},
    acceleration = 0.005,
    action =
    {
      type = "direct",
      action_delivery =
      {
        type = "instant",
        target_effects =
        {
          type = "create-entity",
          show_in_tooltip = true,
          entity_name = "destroyer",
          offsets = {{-0.7, -0.7},{-0.7, 0.7},{0.7, -0.7},{0.7, 0.7},{0, 0}}
          >>>>>>>>> PUT IT HERE  <<<<<<<<<<<<<<<<<<<<<<<<
        }
      }
    }
    

goobboy
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Sep 30, 2018 7:19 pm
Contact:

Re: on_trigger_created_entity event not triggered

Post by goobboy »

Thank you very much, I added this line :

Code: Select all

--data.lua
data.raw["projectile"]["destroyer-capsule"]["action"]["action_delivery"]["target_effects"].trigger_created_entity = true
Now I can properly catch the event.

But I have another question now ^^ I can create a new discussion if you prefer.

My goal is to modify the combat robots speed and friction, I tried this :

Code: Select all

--control.lua
script.on_event(defines.events.on_trigger_created_entity,
  function(event)
	if event.entity.name == "destroyer" then
		event.entity.speed = settings.startup["capsule-speed"].value
		event.entity.friction_modifier = settings.startup["capsule-friction"].value
	end
  end
)
Which of course doesn't work (error), and I haven't found other properties that would match the attributes I want to change (speed and friction).

My final goal is to modify the speed and the friction of combat robots only AFTER a research, so after the game has started and data is already loaded. These two lines already work :

Code: Select all

--data.lua
data.raw["combat-robot"]["destroyer"].speed = settings.startup["capsule-speed"].value
data.raw["combat-robot"]["destroyer"].friction = settings.startup["capsule-friction"].value
But as I said, I only want these attribute to be modified once a research is completed. Maybe there is a better way to do all of this which I haven't found.

goobboy
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Sep 30, 2018 7:19 pm
Contact:

Re: on_trigger_created_entity event not triggered

Post by goobboy »

Okay I've finaly found a workaround, you can see the result in the mod "Sticky capsules".

Post Reply

Return to “Modding help”