I'm creating a unit in my projectile code, but that unit creation is not being detected in my control.lua.
I think the problem is with "defines.events.on_built_entity", should I use something else since it's created in the projectile?
Or is the problem with how I have my projectile setup.
Here is my Control code:
Code: Select all
script.on_event(defines.events.on_robot_built_entity, function(event) On_Built(event) end)
script.on_event(defines.events.on_built_entity, function(event) On_Built(event) end)
------------------------------
-- Detection code
function On_Built(event)
--- unit cluster was created
writeDebug("Cluster Unit Created") -- <-- Does not get to this step!
if event.created_entity.name == "unit-cluster" then
event.created_entity.damage(1, game.forces.neutral,physical)
end
end
Code: Select all
type = "projectile",
name = "Infected-Projectile-Worm",
flags = {"not-on-map"},
acceleration = 0.05,
action =
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
{
type = "create-entity",
entity_name = "unit-cluster"
},
{
type = "damage",
damage = {amount = 10*NE_Difficulty, type = "explosion"}
},
}
}
},