aboutsummaryrefslogtreecommitdiff
path: root/gamemode/server/heatmap.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-08-24 20:32:34 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-08-24 20:32:34 -0400
commit233e478e40d72a091f70f18dc6846066a4f52016 (patch)
treecf34be714088889731736c81bd44e198c792625a /gamemode/server/heatmap.lua
parent61bc16dae5a1b61bcd237d9f0be36125829d95b1 (diff)
downloadartery-233e478e40d72a091f70f18dc6846066a4f52016.tar.gz
artery-233e478e40d72a091f70f18dc6846066a4f52016.tar.bz2
artery-233e478e40d72a091f70f18dc6846066a4f52016.zip
Fix all linter warnings
Diffstat (limited to 'gamemode/server/heatmap.lua')
-rw-r--r--gamemode/server/heatmap.lua48
1 files changed, 23 insertions, 25 deletions
diff --git a/gamemode/server/heatmap.lua b/gamemode/server/heatmap.lua
index 2e8c1b3..1e95590 100644
--- a/gamemode/server/heatmap.lua
+++ b/gamemode/server/heatmap.lua
@@ -4,25 +4,23 @@
do return end
print("Hello from heatmap.lua!")
local prs = pairs
-local iprs = ipairs
-local prnt = print
local tblins,tbldel = table.insert, table.remove
local pow,sqrt,max = math.pow, math.sqrt, math.max
heatmap = {}
-local function VectorDistance(vec1,vec2)
- if vec1.Distance then return vec1:Distance(vec2)
- else
- local dist = 0
- for k,v in prs(vec1) do
- local add = pow(vec1[k]-vec2[k],2)
- dist = dist + add
- end
- dist = sqrt(dist)
- return dist
- end
-end
+-- local function VectorDistance(vec1,vec2)
+-- if vec1.Distance then return vec1:Distance(vec2)
+-- else
+-- local dist = 0
+-- for k,v in prs(vec1) do
+-- local add = pow(vec1[k]-vec2[k],2)
+-- dist = dist + add
+-- end
+-- dist = sqrt(dist)
+-- return dist
+-- end
+-- end
local function VectorLength(vec)
if vec.Length then return vec:Length()
@@ -40,16 +38,16 @@ end
local function RegisterEffect(self, func, position)
local stbl = {position,func}
- tblins(self.heatpoints,#self.heatpoints+1,stbl)
+ tblins(self.heatpoints,#self.heatpoints + 1,stbl)
end
local function CalculateFor(self, position)
local sh = self.heatpoints[1]
local total = sh[2](sh[1]-position,self.curtime)
- for k=2,#self.heatpoints do
+ for k = 2,#self.heatpoints do
sh = self.heatpoints[k]
total, shouldremove = total + sh[2](sh[1]-position,self.curtime)
- if(shouldremove) then tbldel(k) end
+ if shouldremove then tbldel(k) end
end
return total
end
@@ -74,12 +72,12 @@ end
function heatmap.UniformInfiniteLinearDecay(field,decayrate)
return function(vector,time)
- return heatmap.UniformInfiniteForever(field)-(time*decayrate), false
+ return heatmap.UniformInfiniteForever(field) - (time * decayrate), false
end
end
function heatmap.UniformInfiniteLinearDecayGrounded(field,decayrate)
- local removetime = field/decayrate
+ local removetime = field / decayrate
return function(vector,time)
return max(heatmap.UniformInfiniteLinearDecay(field,decayrate),0), time < removetime
end
@@ -99,20 +97,20 @@ end
function heatmap.LinearInfiniteLinearDecay(field,decayrate)
return function(vector, time)
- return field - VectorLength(vector) - (time*decayrate), false
+ return field - VectorLength(vector) - (time * decayrate), false
end
end
function heatmap.LinearInfiniteLinearDecayGrounded(field,decayrate)
- local removetime = field/decayrate
+ local removetime = field / decayrate
return function(vector, time)
- return max(field-VectorLength(vector) - (time*decayrate),0), time < removetime
+ return max(field-VectorLength(vector) - (time * decayrate),0), time < removetime
end
end
function heatmap.ParabolicInfiniteForever(field, power)
return function(vector, time)
- return field - pow(VectorLength(vector),power)/pow(100,power), false
+ return field - pow(VectorLength(vector),power) / pow(100,power), false
end
end
@@ -127,12 +125,12 @@ end
function heatmap.ParabolicInfiniteLinearDecay(field,power,decayrate)
return function(vector, time)
- return heatmap.ParabolicInfiniteForever(field, power) - (time*decayrate), false
+ return heatmap.ParabolicInfiniteForever(field, power) - (time * decayrate), false
end
end
function heatmap.ParabolicInfiniteLinearDecayGrounded(field,power,decayrate)
- local removetime = field/decayrate
+ local removetime = field / decayrate
return function(vector,time)
return max(heatmap.ParabolicInfiniteLinearDecay(field,power,decayrate),0), time < removetime
end