I've found one nice solution how to make compilation of scripts.
in the control.lua must be
Code: Select all
require "script1"
require "script2"
...
Code: Select all
local function script1_on_gui_click(event)
-- here you code
end
local function script1_create_GUI(event)
local player = game.players[event.player_index]
if player.gui.top.script1_GUI == nil then
local button = player.gui.top.add({ type = "sprite-button", name = "script1_GUI", sprite = "item/raw-fish" })
button.style.minimal_height = 38
button.style.minimal_width = 38
button.style.top_padding = 2
button.style.left_padding = 4
button.style.right_padding = 4
button.style.bottom_padding = 2
end
end
Event.register(defines.events.on_gui_click, script1_on_gui_click)
Event.register(defines.events.on_player_joined_game, script1_create_GUI)