2016-08-03 17:22:27 -07:00
|
|
|
local tests = {}
|
2016-08-03 08:54:21 -07:00
|
|
|
|
2016-08-17 22:55:08 -07:00
|
|
|
local constants = require("libs/Constants")
|
|
|
|
|
2016-08-03 17:22:27 -07:00
|
|
|
function tests.test1()
|
|
|
|
local player = game.players[1]
|
|
|
|
local playerChunkX = math.floor(player.position.x / 32)
|
|
|
|
local playerChunkY = math.floor(player.position.y / 32)
|
|
|
|
print("------")
|
|
|
|
print(playerChunkX .. ", " .. playerChunkY)
|
|
|
|
print("--")
|
|
|
|
for x=playerChunkX-3, playerChunkX+3 do
|
|
|
|
for y=playerChunkY-3, playerChunkY+3 do
|
2016-08-19 19:52:27 -07:00
|
|
|
if (global.regionMap[x] ~= nil) then
|
|
|
|
local chunk = global.regionMap[x][y]
|
2016-08-03 17:22:27 -07:00
|
|
|
if (chunk ~= nil) then
|
|
|
|
print(serpent.dump(chunk))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-08-03 08:54:21 -07:00
|
|
|
|
2016-08-06 20:38:47 -07:00
|
|
|
function tests.test2()
|
2016-08-19 19:52:27 -07:00
|
|
|
print("--")
|
|
|
|
for i=1, #global.natives.squads do
|
|
|
|
local squad = global.natives.squads[i]
|
2016-08-17 22:55:08 -07: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-19 19:52:27 -07:00
|
|
|
print(serpent.dump(squad))
|
2016-08-06 20:38:47 -07:00
|
|
|
end
|
|
|
|
end
|
2016-08-04 21:47:51 -07:00
|
|
|
end
|
2016-08-03 08:54:21 -07:00
|
|
|
|
2016-08-17 22:55:08 -07: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 08:54:21 -07:00
|
|
|
|
2016-08-18 15:14:40 -07: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-19 19:52:27 -07:00
|
|
|
max_distance=constants.CHUNK_SIZE,
|
|
|
|
force = "enemy"})
|
2016-08-18 15:14:40 -07:00
|
|
|
if (entity ~= nil) then
|
|
|
|
print(entity.name)
|
|
|
|
end
|
|
|
|
print("--")
|
|
|
|
end
|
|
|
|
|
2016-08-18 19:02:13 -07:00
|
|
|
function tests.test5()
|
2016-08-19 19:52:27 -07:00
|
|
|
print(global.natives.points)
|
2016-08-18 19:02:13 -07:00
|
|
|
end
|
|
|
|
|
2016-08-03 17:22:27 -07:00
|
|
|
return tests
|