2016-08-04 02:22:27 +02:00
|
|
|
local tests = {}
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2016-08-18 07:55:08 +02:00
|
|
|
local constants = require("libs/Constants")
|
|
|
|
|
2016-08-04 02:22:27 +02:00
|
|
|
function tests.test1()
|
2016-08-25 01:30:45 +02:00
|
|
|
local player = game.player.character
|
2016-08-04 02:22:27 +02:00
|
|
|
local playerChunkX = math.floor(player.position.x / 32)
|
|
|
|
local playerChunkY = math.floor(player.position.y / 32)
|
|
|
|
print("------")
|
2016-08-29 02:05:28 +02:00
|
|
|
print(#global.regionMap.processQueue)
|
2016-08-04 02:22:27 +02:00
|
|
|
print(playerChunkX .. ", " .. playerChunkY)
|
|
|
|
print("--")
|
|
|
|
for x=playerChunkX-3, playerChunkX+3 do
|
|
|
|
for y=playerChunkY-3, playerChunkY+3 do
|
2016-08-20 04:52:27 +02:00
|
|
|
if (global.regionMap[x] ~= nil) then
|
|
|
|
local chunk = global.regionMap[x][y]
|
2016-08-04 02:22:27 +02:00
|
|
|
if (chunk ~= nil) then
|
2016-08-21 23:48:55 +02:00
|
|
|
local str = ""
|
|
|
|
for i=1,#chunk do
|
|
|
|
str = str .. " " .. tostring(i) .. "/" .. tostring(chunk[i])
|
|
|
|
end
|
|
|
|
if (chunk.cX == playerChunkX) and (chunk.cY == playerChunkY) then
|
|
|
|
print("*", chunk.cX, chunk.cY, str)
|
|
|
|
else
|
|
|
|
print(chunk.cX, chunk.cY, str)
|
|
|
|
end
|
|
|
|
-- print(str)
|
|
|
|
print("-")
|
2016-08-04 02:22:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2016-08-07 05:38:47 +02:00
|
|
|
function tests.test2()
|
2016-08-20 04:52:27 +02:00
|
|
|
print("--")
|
|
|
|
for i=1, #global.natives.squads do
|
|
|
|
local squad = global.natives.squads[i]
|
2016-08-18 07:55:08 +02:00
|
|
|
if squad.group.valid then
|
|
|
|
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state)
|
2016-08-20 04:52:27 +02:00
|
|
|
print(serpent.dump(squad))
|
2016-08-07 05:38:47 +02:00
|
|
|
end
|
|
|
|
end
|
2016-08-05 06:47:51 +02:00
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2016-08-18 07:55:08 +02:00
|
|
|
function tests.test3()
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
|
|
|
local entities = game.surfaces[1].find_entities_filtered({area={{chunkX, chunkY},
|
|
|
|
{chunkX + constants.CHUNK_SIZE, chunkY + constants.CHUNK_SIZE}},
|
|
|
|
force="player"})
|
|
|
|
for i=1, #entities do
|
|
|
|
print(entities[i].name)
|
|
|
|
end
|
|
|
|
print("--")
|
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2016-08-19 00:14:40 +02:00
|
|
|
function tests.test4()
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
|
|
|
local entity = game.surfaces[1].find_nearest_enemy({position={chunkX, chunkY},
|
2016-08-20 04:52:27 +02:00
|
|
|
max_distance=constants.CHUNK_SIZE,
|
|
|
|
force = "enemy"})
|
2016-08-19 00:14:40 +02:00
|
|
|
if (entity ~= nil) then
|
|
|
|
print(entity.name)
|
|
|
|
end
|
|
|
|
print("--")
|
|
|
|
end
|
|
|
|
|
2016-08-19 04:02:13 +02:00
|
|
|
function tests.test5()
|
2016-08-25 01:30:45 +02:00
|
|
|
print(global.natives.points, game.tick)
|
2016-08-19 04:02:13 +02:00
|
|
|
end
|
|
|
|
|
2016-08-21 02:28:35 +02:00
|
|
|
function tests.test6()
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
|
|
|
game.surfaces[1].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
|
|
|
{name="fillableDirt", position={chunkX, chunkY-1}},
|
|
|
|
{name="fillableDirt", position={chunkX-1, chunkY}},
|
|
|
|
{name="fillableDirt", position={chunkX, chunkY}}},
|
|
|
|
false)
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.test7()
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
|
|
|
game.surfaces[1].create_entity({name="tunnel-entrance", position={chunkX, chunkY}})
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.test8(x)
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
|
|
|
game.surfaces[1].create_entity({name=x, force="enemy", position={chunkX, chunkY}})
|
|
|
|
end
|
|
|
|
|
2016-08-26 00:20:06 +02:00
|
|
|
function tests.test9()
|
|
|
|
local enemy = game.surfaces[1].find_nearest_enemy({position={0,0},
|
|
|
|
max_distance = 1000})
|
|
|
|
if (enemy ~= nil) and enemy.valid then
|
|
|
|
print(enemy, enemy.unit_number)
|
|
|
|
enemy.set_command({type=defines.command.attack_area,
|
|
|
|
destination={0,0},
|
|
|
|
radius=32})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-27 08:44:17 +02:00
|
|
|
function tests.test10()
|
|
|
|
game.players[1].cheat_mode = true
|
|
|
|
game.forces.player.research_all_technologies()
|
|
|
|
end
|
|
|
|
|
2016-08-29 02:05:28 +02:00
|
|
|
function tests.test11()
|
|
|
|
print(serpent.dump(global.pheromoneTotals))
|
|
|
|
end
|
|
|
|
|
2016-08-04 02:22:27 +02:00
|
|
|
return tests
|