mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
FACTO-96: Fixed rampantSetAIState command for multiple AIs per surface
This commit is contained in:
parent
2d9b87e127
commit
d671709e1f
@ -25,6 +25,7 @@ Version: 3.0.0
|
||||
- Fixed Krastorio2 on_force_created playerforces being nil
|
||||
- Fixed enemy map scan creating bases unnecessarily
|
||||
- Fixed base.index reference error in displaying ai state
|
||||
- Fixed rampantSetAIState command to work with multiple ais per surface
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.2.0
|
||||
|
34
control.lua
34
control.lua
@ -1072,20 +1072,18 @@ remote.add_interface("rampantTests",
|
||||
)
|
||||
|
||||
local function rampantSetAIState(event)
|
||||
local surfaceIndex = game.players[event.player_index].surface.index
|
||||
local map = universe.maps[surfaceIndex]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
|
||||
game.print(map.surface.name .. " is in " .. constants.stateEnglish[map.state])
|
||||
|
||||
if event.parameter then
|
||||
local target = tonumber(event.parameter)
|
||||
local target
|
||||
local baseId
|
||||
local i = 0
|
||||
|
||||
if (target == nil) then
|
||||
game.print("invalid param")
|
||||
return
|
||||
for m in string.gmatch(event.parameter, "%d+") do
|
||||
if i == 0 then
|
||||
i = i + 1
|
||||
target = tonumber(m)
|
||||
else
|
||||
baseId = tonumber(m)
|
||||
end
|
||||
end
|
||||
|
||||
if target ~= constants.BASE_AI_STATE_PEACEFUL and
|
||||
@ -1095,11 +1093,17 @@ local function rampantSetAIState(event)
|
||||
target ~= constants.BASE_AI_STATE_SIEGE and
|
||||
target ~= constants.BASE_AI_STATE_ONSLAUGHT
|
||||
then
|
||||
game.print(target .. " is not a valid state")
|
||||
game.print(target .. " is not a valid state. /rampantSetAIState <stateId> <baseId>")
|
||||
return
|
||||
else
|
||||
map.state = target
|
||||
game.print(map.surface.name .. " is now in " .. constants.stateEnglish[map.state])
|
||||
local base = universe.bases[baseId]
|
||||
if not base then
|
||||
game.print(baseId .. " is not a valid base. /rampantSetAIState <stateId> <baseId>")
|
||||
return
|
||||
end
|
||||
base.stateAI = target
|
||||
local surface = base.surface
|
||||
game.print("id:" .. baseId .. " on surface:" .. surface.name .. " is now in " .. constants.stateEnglish[base.stateAI])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user