diff options
author | cheapie <no-email-for-you@example.com> | 2024-08-23 12:25:24 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-08-23 12:25:24 -0500 |
commit | 18b293cec8b183f51a479d589ad1b0b429ab4998 (patch) | |
tree | 67ff7edf30e5730ed7ef006dc4adf56a68e6c2a6 | |
parent | 7570b4f5a59a65b4a90108ae29e06bede0a55652 (diff) | |
download | digiscreen-18b293cec8b183f51a479d589ad1b0b429ab4998.tar digiscreen-18b293cec8b183f51a479d589ad1b0b429ab4998.tar.gz digiscreen-18b293cec8b183f51a479d589ad1b0b429ab4998.tar.bz2 digiscreen-18b293cec8b183f51a479d589ad1b0b429ab4998.tar.xz digiscreen-18b293cec8b183f51a479d589ad1b0b429ab4998.zip |
Performance improvements
-rw-r--r-- | init.lua | 27 |
1 files changed, 5 insertions, 22 deletions
@@ -18,32 +18,15 @@ local function generateTexture(pos,serdata) minetest.log("error","[digiscreen] Failed to deserialize display data at "..minetest.pos_to_string(pos,0)) return end + local bincolors = "" for y=1,16,1 do - if type(data[y]) ~= "table" then - minetest.log("error","[digiscreen] Invalid row "..y.." at "..minetest.pos_to_string(pos,0)) - return - end - for x=1,16,1 do - if type(data[y][x]) ~= "string" or string.len(data[y][x]) ~= 6 then - minetest.log("error","[digiscreen] Missing/wrong length display data for X="..x.." Y="..y.." at "..minetest.pos_to_string(pos,0)) - return - end - for i=1,6,1 do - if not tonumber(string.sub(data[y][x],i,i),16) then - minetest.log("error","[digiscreen] Invalid digit in display data for X="..x.." Y="..y.." at "..minetest.pos_to_string(pos,0)) - return - end - end - end - end - - local ret = "[combine:16x16" - for y=1,16,1 do + if type(data[y]) ~= "table" then data[y] = {} end for x=1,16,1 do - ret = ret..string.format(":%d,%d=(digiscreen_pixel.png\\^[colorize\\:#%s\\:255)",x-1,y-1,data[y][x]) + bincolors = bincolors..minetest.colorspec_to_bytes(data[y][x] or "000000") end end - return ret + local img = minetest.encode_png(16,16,bincolors,0) + return "[png:"..minetest.encode_base64(img) end local function updateDisplay(pos) |