Skip to content

Commit

Permalink
0.0.9 and 0.0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
veden committed Sep 14, 2016
1 parent 9e2d97c commit 9e0f35a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ luac.out
*.bat

# extra
*.rkt
*.lua#
*.rkt~
*.lua~
Expand Down
17 changes: 13 additions & 4 deletions libs/MapProcessor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ local pheromoneUtils = require("PheromoneUtils")
local aiBuilding = require("AIBuilding")
local constants = require("Constants")

-- constants

local PROCESS_QUEUE_SIZE = constants.PROCESS_QUEUE_SIZE
local ENEMY_BASE_PHEROMONE_GENERATOR_AMOUNT = constants.ENEMY_BASE_PHEROMONE_GENERATOR_AMOUNT
local SCAN_QUEUE_SIZE = constants.SCAN_QUEUE_SIZE

local CHUNK_SIZE = constants.CHUNK_SIZE
local ENEMY_BASE_GENERATOR = constants.ENEMY_BASE_GENERATOR

-- imported functions

local scents = pheromoneUtils.scents
Expand Down Expand Up @@ -45,7 +54,7 @@ function mapProcessor.processMap(regionMap, surface, natives, evolution_factor,
end

local processQueue = regionMap.processQueue
local endIndex = mMin(index + constants.PROCESS_QUEUE_SIZE, #processQueue)
local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue)
for x=index,endIndex do
local chunk = processQueue[x]

Expand All @@ -72,15 +81,15 @@ function mapProcessor.scanMap(regionMap, surface)
local index = regionMap.scanPointer

local processQueue = regionMap.processQueue
local endIndex = mMin(index + constants.SCAN_QUEUE_SIZE, #processQueue)
local endIndex = mMin(index + SCAN_QUEUE_SIZE, #processQueue)
for x=index,endIndex do
local chunk = processQueue[x]

local spawners = surface.count_entities_filtered({area = {{chunk.pX, chunk.pY},
{chunk.pX + constants.CHUNK_SIZE, chunk.pY + constants.CHUNK_SIZE}},
{chunk.pX + CHUNK_SIZE, chunk.pY + CHUNK_SIZE}},
type = "unit-spawner",
force = "enemy"})
chunk[constants.ENEMY_BASE_GENERATOR] = spawners * constants.ENEMY_BASE_PHEROMONE_GENERATOR_AMOUNT
chunk[ENEMY_BASE_GENERATOR] = spawners * ENEMY_BASE_PHEROMONE_GENERATOR_AMOUNT
end

if (endIndex == #processQueue) then
Expand Down
31 changes: 17 additions & 14 deletions libs/PheromoneUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,32 @@ function pheromoneUtils.processPheromone(chunk, neighbors)
local totalDiffused = 0
local chunkValue = chunk[DEATH_PHEROMONE] * persistence
local diffusedAmount = chunkValue * diffusionAmount
for i=1,#neighbors do
local neighborChunk = neighbors[i]
if (neighborChunk ~= nil) then
totalDiffused = totalDiffused + diffusedAmount
neighborChunk[DEATH_PHEROMONE] = neighborChunk[DEATH_PHEROMONE] + diffusedAmount
end
if (chunkValue > 2) then
for i=1,#neighbors do
local neighborChunk = neighbors[i]
if (neighborChunk ~= nil) then
totalDiffused = totalDiffused + diffusedAmount
neighborChunk[DEATH_PHEROMONE] = neighborChunk[DEATH_PHEROMONE] + diffusedAmount
end
end
end
chunk[DEATH_PHEROMONE] = (chunkValue - totalDiffused)


diffusionAmount = STANDARD_PHERONOME_DIFFUSION_AMOUNT
persistence = STANDARD_PHEROMONE_PERSISTANCE
for x=2,6 do
totalDiffused = 0
chunkValue = chunk[x] * persistence
diffusedAmount = chunkValue * diffusionAmount
for i=1,#neighbors do
local neighborChunk = neighbors[i]
if (neighborChunk ~= nil) then
totalDiffused = totalDiffused + diffusedAmount
neighborChunk[x] = neighborChunk[x] + diffusedAmount
end
end
if (chunkValue > 2) then
for i=1,#neighbors do
local neighborChunk = neighbors[i]
if (neighborChunk ~= nil) then
totalDiffused = totalDiffused + diffusedAmount
neighborChunk[x] = neighborChunk[x] + diffusedAmount
end
end
end
chunk[x] = (chunkValue - totalDiffused)
end
end
Expand Down
79 changes: 79 additions & 0 deletions make.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
(module BuildScript racket

(require file/zip)
(require json)

;(define modFolder "C:/Users/veden/AppData/Roaming/Factorio/mods/")
;(define zipModFolder "C:/Program Files/Factorio_0.14.1/mods/")
(define modFolder "/home/veden/.factorio/mods/")
(define zipModFolder "/home/veden/.factorio/mods/")
(define configuration (call-with-input-file "info.json"
(lambda (port)
(string->jsexpr (port->string port)))))
(define packageName (string-append (string-replace (hash-ref configuration 'name) " " "_")
"_"
(hash-ref configuration 'version)))

(define (makeZip)
(let ((packagePath (string->path (string-append modFolder
packageName
".zip"))))
(when (file-exists? packagePath)
(delete-file packagePath)))
(zip (string-append modFolder
packageName
".zip")
#:path-prefix packageName
(string->path "info.json")
(string->path "control.lua")
;(string->path "config.lua")
(string->path "data.lua")
(string->path "LICENSE.md")
(string->path "tests.lua")
; (string->path "setupUtils.lua")
(string->path "README.md")
; (string->path "setup.lua")
(string->path "NOTICE")
(string->path "libs")
(string->path "locale")
(string->path "graphics")
(string->path "prototypes")))


;(current-directory "..")
(define (copyFile fileName modFolder)
(copy-file (string->path fileName)
(string->path (string-append modFolder
packageName
"/"
fileName))))

(define (copyDirectory directoryName modFolder)
(copy-directory/files (string->path directoryName)
(string->path (string-append modFolder
packageName
"/"
directoryName))))

(define (copyFiles modFolder)
(let ((packagePath (string->path (string-append modFolder
packageName))))
(when (directory-exists? packagePath)
(delete-directory/files packagePath))
(sleep 0.1)
(make-directory packagePath)
(copyFile "control.lua" modFolder)
; (copyFile "config.lua" modFolder)
(copyFile "info.json" modFolder)
; (copyFile "setupUtils.lua" modFolder)
(copyFile "data.lua" modFolder)
(copyFile "tests.lua" modFolder)
(copyDirectory "libs" modFolder)
(copyDirectory "locale" modFolder)
(copyDirectory "graphics" modFolder)
(copyDirectory "prototypes" modFolder)))

; (copyFiles modFolder)
; (copyFiles zipModFolder)
(makeZip)
)

0 comments on commit 9e0f35a

Please sign in to comment.