[Solved] Can't write to vehicle_automatic_targeting_parameters
Posted: Sat Oct 03, 2020 12:48 pm
I want to write to the vehicle_automatic_targeting_parameters but it just won't work. Here the full code:
Everything works just fine except the two lines were I try to change vehicle_automatic_targeting_parameters.auto_target_with_gunner to true/false. I am using the same code for enable_logistics_while_moving and it works:
What am I doing wrong?
Code: Select all
script.on_event(defines.events.on_lua_shortcut, function(event)
local prototype_name = event.prototype_name
local player = game.players[event.player_index]
if prototype_name == "targeting-with-gunner" then
if player.driving == true then
if player.vehicle.type == "spider-vehicle" then
if player.vehicle.vehicle_automatic_targeting_parameters.auto_target_with_gunner == true then
player.vehicle.vehicle_automatic_targeting_parameters.auto_target_with_gunner = false
player.set_shortcut_toggled(prototype_name, false)
else
player.vehicle.vehicle_automatic_targeting_parameters.auto_target_with_gunner = true
player.set_shortcut_toggled(prototype_name, true)
end
end
end
end
end)
Code: Select all
player.vehicle.enable_logistics_while_moving = false