I was rewriting my module and I was questioning should I use self or not
function KeyHandler.Create()
local Keytable = {}
local KeysActive = {}
local Keys = {}
function Keytable.Init(values : KeyValues)
for i, keyindex in ipairs(values.Keys) do
local keys = string.split(keyindex, ",")
KeysActive[i] = false
for i, key in ipairs(keys) do
local Key = {}
Key.Priority = values.Priority or KeyHandler.Priority
Key.Index = i
Key.Enabled = true
function Key.Fire()
Key.MaxHoldTime = values.MaxHoldTime
--local ComboHoldTime = {}
--local TimeConnections = {}
end
table.insert(Keys, Key)
end
end
end
function Keytable.Call()
end
function Keytable.Active(value : boolean)
for i, Key in ipairs(Keys) do
Key.Enabled = value
end
end
function Keytable.Destroy()
Keytable = nil
end
return Keytable
end
For example code here:
local Key = {}
Key.Priority = values.Priority or KeyHandler.Priority
Key.Index = i
Key.Enabled = true
function Key.Fire()
Key.MaxHoldTime = values.MaxHoldTime
--local ComboHoldTime = {}
--local TimeConnections = {}
end
table.insert(Keys, Key)
Key.MaxHoldTime = values.MaxHoldTime
or
self.MaxHoldTime = values.MaxHoldTime
This is what bothers me. I want explanation.
Also, should I change code structure?
Btw, " : " looks better than " . " but I want code to be as fast as possible.