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")
|
|
|
|
|
2020-11-28 01:37:34 +08:00
|
|
|
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.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)
|
|
|
|
|
2020-11-28 01:37:34 +08:00
|
|
|
-- link tool
|
|
|
|
script.on_event("squad-spidertron-link-tool", function(event)
|
|
|
|
GiveLinkTool(event.player_index)
|
2020-08-18 18:52:32 +08:00
|
|
|
end)
|
|
|
|
|
2020-08-15 17:15:37 +08:00
|
|
|
script.on_event(defines.events.on_lua_shortcut, function (event)
|
2020-08-24 20:43:41 +08:00
|
|
|
local name = event.prototype_name
|
|
|
|
if name == "squad-spidertron-follow" then
|
2020-08-18 16:42:01 +08:00
|
|
|
local index = event.player_index
|
2020-11-28 01:37:34 +08:00
|
|
|
-- squad_leader_state(index)
|
|
|
|
SpiderbotFollow(game.players[index])
|
2020-08-24 20:43:41 +08:00
|
|
|
elseif name == "squad-spidertron-link-tool" then
|
2020-11-28 01:37:34 +08:00
|
|
|
GiveLinkTool(event.player_index)
|
2020-08-17 00:04:50 +08:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2020-11-28 01:37:34 +08:00
|
|
|
script.on_nth_tick(settings.global["spidertron-follow-update-interval"].value, function(event)
|
|
|
|
UpdateFollow()
|
|
|
|
UpdateFollowEntity()
|
2020-08-24 20:43:41 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
2020-11-28 01:37:34 +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)
|
|
|
|
|
2020-11-28 01:37:34 +08:00
|
|
|
script.on_load(function()
|
|
|
|
SpidertronWaypointsCompatibility()
|
|
|
|
end)
|