Code: Select all
--control.lua
require "util"
script.on_event({defines.events.on_tick},
function (e)
if game.player.character.vehicle.name ~= nil
then if game.player.character.vehicle.name == "car"
and game.player.character.vehicle.grid.avabile_in_batteries == 0
then game.player.character.vehicle.speed = 0 end end
end)
When I enter the game, that error occurs:
Code: Select all
Error while running event EGMOT::on_tick (ID 0)
__EGMOT__/control.lua:7: attempt to index field 'player' (a nil value)
Can you plase help me and tell me what's wrong?
Should I include any logs?