spidertron-squad-control/control.lua

90 lines
2.8 KiB
Lua
Raw Normal View History

2020-08-15 00:22:11 +08:00
--[[ Copyright (c) 2020 npc_strider
* For direct use of code or graphics, credit is appreciated. See LICENSE.txt for more information.
* This mod may contain modified code sourced from base/core Factorio
*
* control.lua
* Spiderbot.
--]]
2020-08-18 16:42:01 +08:00
require("util")
require("constants")
require("control.debug")
-- REMEMBER TO COMMENT DEBUG OUT IN RELEASE!!
-- REMEMBER TO COMMENT DEBUG OUT IN RELEASE!!
-- REMEMBER TO COMMENT DEBUG OUT IN RELEASE!!
-- REMEMBER TO COMMENT DEBUG OUT IN RELEASE!!
-- REMEMBER TO COMMENT DEBUG OUT IN RELEASE!!
require("control.gui")
require("control.init")
require("control.remote")
require("control.give_remote")
require("control.player_select")
require("control.player_man_designate")
require("control.player_follow")
require("control.entity_follow")
require("control.functions")
-- require("control.select")
------------------------------------------------------------------------
-- EVENTS
------------------------------------------------------------------------
-- Follow
script.on_event("squad-spidertron-follow", function(event)
-- squad_leader_state(event.player_index)
SpiderbotFollow(game.players[event.player_index])
2020-08-15 17:15:37 +08:00
end)
-- link tool
script.on_event("squad-spidertron-link-tool", function(event)
local index = event.player_index
local settings = settings.get_player_settings(game.players[index])
GiveLinkTool(index, settings)
end)
script.on_event("squad-spidertron-remote", function(event)
local index = event.player_index
local settings = settings.get_player_settings(game.players[index])
GiveSquadTool(index, settings)
end)
script.on_event("squad-spidertron-list", function(event)
ToggleGuiList(event.player_index)
end)
script.on_event(defines.events.on_lua_shortcut, function(event)
local index = event.player_index
local settings = settings.get_player_settings(game.players[index])
2020-08-24 20:43:41 +08:00
local name = event.prototype_name
if name == "squad-spidertron-remote" then
GiveLinkTool(index, settings)
elseif name == "squad-spidertron-link-tool" then
GiveSquadTool(index, settings)
elseif name == "squad-spidertron-follow" then
-- squad_leader_state(index)
SpiderbotFollow(game.players[index])
elseif name == "squad-spidertron-list" then
ToggleGuiList(index)
end
end)
script.on_nth_tick(settings.global["spidertron-follow-update-interval"].value, function(event)
UpdateFollow()
UpdateFollowEntity()
2020-08-24 20:43:41 +08:00
end)
script.on_nth_tick(settings.global["spidertron-gui-update-interval"].value, function(event)
for _, player in pairs(game.players) do
UpdateGuiList(player)
end
end)
2020-08-24 20:43:41 +08:00
-- script.on_event(defines.events.on_spider_command_completed, function (event)
-- game.print(game.tick)
2020-08-24 20:43:41 +08:00
-- end)
script.on_load(function()
SpidertronWaypointsCompatibility()
end)