From 1b0fe3100245801fca20fff5d0fdaa3180da83ab Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Fri, 22 Mar 2019 21:18:59 -0400 Subject: [PATCH] minor change This change allows for databuffers to treat numbers like strings and a number that would contain more that 1 byte would be wxpanded to fit into the next. The max length is 4 bytes --- bin/init.lua | 2 +- test.lua | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test.lua diff --git a/bin/init.lua b/bin/init.lua index b6ebf52..aadea41 100644 --- a/bin/init.lua +++ b/bin/init.lua @@ -1020,7 +1020,7 @@ function bin.newDataBuffer(size,fill) -- fills with \0 or nul or with what you e if type(v)=="string" then data=v elseif type(v)=="number" then - data=string.char(v) + data=bits.numToBytes(v) else -- try to normalize the data of type v data=bin.normalizeData(v) diff --git a/test.lua b/test.lua new file mode 100644 index 0000000..54e2ce0 --- /dev/null +++ b/test.lua @@ -0,0 +1,5 @@ +local bin = require("bin") +local bits = bin.bits +test = bin.newDataBuffer(16) +print() +