I can not register an event
Posted: Mon Sep 10, 2018 12:32 pm
I created a file in which I wrote a script that I had to run in the event.on_player_created. In the control.lua I also already have this event. But I do not want to move this function from mid.lua to control.lua.
control.lua:
mid.lua:
I'm getting the error that I did wrong?
control.lua:7: > require "mid"
mid.lua:6: > Event.register(defines.events.on_player_created, whatever)
control.lua:
Code: Select all
require "mid"
script.on_event(defines.events.on_player_created, function(event)
functiont1(event)
functiont2(event)
functiont3(event)
end)
Code: Select all
local function whatever(event)
local player = game.players[event.player_index]
player.insert{name="iron-plate", count=10}
end
Event.register(defines.events.on_player_created, whatever)
mid.lua:6: > Event.register(defines.events.on_player_created, whatever)