aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/lockbox/array.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
commit4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99 (patch)
treeac47724191a8959c19b2408d4da384d64b6098ec /gamemode/shared/lockbox/array.lua
parent2c4329e2b6e19182a441f79a5c3010011f8ae767 (diff)
downloadartery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.gz
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.bz2
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.zip
Started refactoring item and inventory system
Diffstat (limited to 'gamemode/shared/lockbox/array.lua')
-rw-r--r--gamemode/shared/lockbox/array.lua210
1 files changed, 0 insertions, 210 deletions
diff --git a/gamemode/shared/lockbox/array.lua b/gamemode/shared/lockbox/array.lua
deleted file mode 100644
index 8a2fd30..0000000
--- a/gamemode/shared/lockbox/array.lua
+++ /dev/null
@@ -1,210 +0,0 @@
-local String = string
-local Bit = include("bit.lua");
-
-local XOR = Bit.bxor;
-
-local Array = {};
-
-Array.size = function(array)
- return #array;
-end
-
-Array.fromString = function(string)
- local bytes = {};
-
- local i=1;
- local byte = String.byte(string,i);
- while byte ~= nil do
- bytes[i] = byte;
- i = i + 1;
- byte = String.byte(string,i);
- end
-
- return bytes;
-
-end
-
-Array.toString = function(bytes)
- local chars = {};
- local i=1;
-
- local byte = bytes[i];
- while byte ~= nil do
- chars[i] = String.char(byte);
- i = i+1;
- byte = bytes[i];
- end
-
- return table.concat(chars,"");
-end
-
-Array.fromStream = function(stream)
- local array = {};
- local i=1;
-
- local byte = stream();
- while byte ~= nil do
- array[i] = byte;
- i = i+1;
- byte = stream();
- end
-
- return array;
-end
-
-Array.readFromQueue = function(queue,size)
- local array = {};
-
- for i=1,size do
- array[i] = queue.pop();
- end
-
- return array;
-end
-
-Array.writeToQueue = function(queue,array)
- local size = Array.size(array);
-
- for i=1,size do
- queue.push(array[i]);
- end
-end
-
-Array.toStream = function(array)
- local queue = Queue();
- local i=1;
-
- local byte = array[i];
- while byte ~= nil do
- queue.push(byte);
- i=i+1;
- byte = array[i];
- end
-
- return queue.pop;
-end
-
-
-local fromHexTable = {};
-for i=0,255 do
- fromHexTable[String.format("%02X",i)]=i;
- fromHexTable[String.format("%02x",i)]=i;
-end
-
-Array.fromHex = function(hex)
- local array = {};
-
- for i=1,String.len(hex)/2 do
- local h = String.sub(hex,i*2-1,i*2);
- array[i] = fromHexTable[h];
- end
-
- return array;
-end
-
-
-local toHexTable = {};
-for i=0,255 do
- toHexTable[i]=String.format("%02X",i);
-end
-
-Array.toHex = function(array)
- local hex = {};
- local i = 1;
-
- local byte = array[i];
- while byte ~= nil do
- hex[i] = toHexTable[byte];
- i=i+1;
- byte = array[i];
- end
-
- return table.concat(hex,"");
-
-end
-
-Array.concat = function(a,b)
- local concat = {};
- local out=1;
-
- local i=1;
- local byte = a[i];
- while byte ~= nil do
- concat[out] = byte;
- i = i + 1;
- out = out + 1;
- byte = a[i];
- end
-
- local i=1;
- local byte = b[i];
- while byte ~= nil do
- concat[out] = byte;
- i = i + 1;
- out = out + 1;
- byte = b[i];
- end
-
- return concat;
-end
-
-Array.truncate = function(a,newSize)
- local x = {};
-
- for i=1,newSize do
- x[i]=a[i];
- end
-
- return x;
-end
-
-Array.XOR = function(a,b)
- local x = {};
-
- for k,v in pairs(a) do
- x[k] = XOR(v,b[k]);
- end
-
- return x;
-end
-
-Array.substitute = function(input,sbox)
- local out = {};
-
- for k,v in pairs(input) do
- out[k] = sbox[v];
- end
-
- return out;
-end
-
-Array.permute = function(input,pbox)
- local out = {};
-
- for k,v in pairs(pbox) do
- out[k] = input[v];
- end
-
- return out;
-end
-
-Array.copy = function(input)
- local out = {};
-
- for k,v in pairs(input) do
- out[k] = v;
- end
- return out;
-end
-
-Array.slice = function(input,start,stop)
- local out = {};
-
- for i=start,stop do
- out[i-start+1] = input[i];
- end
- return out;
-end
-
-
-return Array;