dofile( "data/scripts/lib/utilities.lua" )

local entity_id    = GetUpdatedEntityID()
local pos_x, pos_y = EntityGetTransform( entity_id )

local projectile_component = EntityGetFirstComponent(entity_id, "ProjectileComponent")

if(projectile_component ~= nil)then
    local action_id = ComponentObjectGetValue2(projectile_component, "config", "action_id")

    local extra_entities = GlobalsGetValue("extra_entities", "")

    --print(extra_entities)

    local components = EntityGetComponent( entity_id, "VariableStorageComponent" )

    if( components ~= nil ) then
    
        for key,comp_id in pairs(components) do 
            local var_name = ComponentGetValue( comp_id, "name" )

            if( var_name == "extra_entities") then
                ComponentSetValue2(comp_id, "value_string", extra_entities)
            end                   
        end
    end       
    if(has_modifiers_stored ~= true)then
        EntityAddComponent(entity_id, "VariableStorageComponent", 
        { 
            name = "extra_entities",
            value_string = extra_entities,
        })
    end            

end