aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/lockbox/stream.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/stream.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/stream.lua')
-rw-r--r--gamemode/shared/lockbox/stream.lua112
1 files changed, 0 insertions, 112 deletions
diff --git a/gamemode/shared/lockbox/stream.lua b/gamemode/shared/lockbox/stream.lua
deleted file mode 100644
index aeb3b18..0000000
--- a/gamemode/shared/lockbox/stream.lua
+++ /dev/null
@@ -1,112 +0,0 @@
-local Queue = include("queue.lua");
-local String = string
-
-local Stream = {};
-
-
-Stream.fromString = function(string)
- local i=0;
- return function()
- print("string is:" .. string)
- print("len is:" .. string.len(string))
- print("i is:" .. i)
- i=i+1;
- if(i <= string.len(string)) then
- return string.byte(string,i);
- else
- return nil;
- end
- end
-end
-
-
-Stream.toString = function(stream)
- local array = {};
- local i=1;
-
- local byte = stream();
- while byte ~= nil do
- array[i] = String.char(byte);
- i = i+1;
- byte = stream();
- end
-
- return table.concat(array,"");
-end
-
-
-Stream.fromArray = 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
-
-
-Stream.toArray = 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
-
-
-local fromHexTable = {};
-for i=0,255 do
- fromHexTable[String.format("%02X",i)]=i;
- fromHexTable[String.format("%02x",i)]=i;
-end
-
-Stream.fromHex = function(hex)
- local queue = Queue();
-
- for i=1,String.len(hex)/2 do
- local h = String.sub(hex,i*2-1,i*2);
- queue.push(fromHexTable[h]);
- end
-
- return queue.pop;
-end
-
-
-
-local toHexTable = {};
-for i=0,255 do
- toHexTable[i]=String.format("%02X",i);
-end
-
-Stream.toHex = function(stream)
- print("tohex called with stream")
- print(stream)
- local hex = {};
- local i = 1;
-
- local byte = stream();
- print("First byte is")
- print(byte)
- while byte ~= nil do
- print("Createing hex:")
- print(table.concat(hex,""))
- hex[i] = toHexTable[byte];
- i=i+1;
- byte = stream();
- end
-
- return table.concat(hex,"");
-end
-
-return Stream;