forked from Mirrorlandia_minetest/digilines
Add .luacheckrc
and fix warnings.
This commit is contained in:
parent
f5e6a7d181
commit
5caacf3019
12
.luacheckrc
Normal file
12
.luacheckrc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"minetest",
|
||||||
|
"default",
|
||||||
|
"pipeworks",
|
||||||
|
"dump",
|
||||||
|
"VoxelArea",
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"digilines",
|
||||||
|
}
|
164
lcd.lua
164
lcd.lua
@ -20,6 +20,88 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- CONSTANTS
|
||||||
|
local LCD_WITH = 100
|
||||||
|
local LCD_PADDING = 8
|
||||||
|
|
||||||
|
local LINE_LENGTH = 12
|
||||||
|
local NUMBER_OF_LINES = 5
|
||||||
|
|
||||||
|
local LINE_HEIGHT = 14
|
||||||
|
local CHAR_WIDTH = 5
|
||||||
|
|
||||||
|
local create_lines = function(text)
|
||||||
|
local line = ""
|
||||||
|
local line_num = 1
|
||||||
|
local tab = {}
|
||||||
|
for word in string.gmatch(text, "%S+") do
|
||||||
|
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then
|
||||||
|
if line ~= "" then
|
||||||
|
line = line.." "..word
|
||||||
|
else
|
||||||
|
line = word
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(tab, line)
|
||||||
|
if word ~= "|" then
|
||||||
|
line = word
|
||||||
|
else
|
||||||
|
line = ""
|
||||||
|
end
|
||||||
|
line_num = line_num+1
|
||||||
|
if line_num > NUMBER_OF_LINES then
|
||||||
|
return tab
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(tab, line)
|
||||||
|
return tab
|
||||||
|
end
|
||||||
|
|
||||||
|
local generate_line = function(s, ypos)
|
||||||
|
local i = 1
|
||||||
|
local parsed = {}
|
||||||
|
local width = 0
|
||||||
|
local chars = 0
|
||||||
|
while chars < max_chars and i <= #s do
|
||||||
|
local file = nil
|
||||||
|
if charmap[s:sub(i, i)] ~= nil then
|
||||||
|
file = charmap[s:sub(i, i)]
|
||||||
|
i = i + 1
|
||||||
|
elseif i < #s and charmap[s:sub(i, i + 1)] ~= nil then
|
||||||
|
file = charmap[s:sub(i, i + 1)]
|
||||||
|
i = i + 2
|
||||||
|
else
|
||||||
|
print("[digilines] W: LCD: unknown symbol in '"..s.."' at "..i)
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
if file ~= nil then
|
||||||
|
width = width + CHAR_WIDTH
|
||||||
|
table.insert(parsed, file)
|
||||||
|
chars = chars + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
width = width - 1
|
||||||
|
|
||||||
|
local texture = ""
|
||||||
|
local xpos = math.floor((LCD_WITH - 2 * LCD_PADDING - width) / 2 + LCD_PADDING)
|
||||||
|
for ii = 1, #parsed do
|
||||||
|
texture = texture..":"..xpos..","..ypos.."="..parsed[ii]..".png"
|
||||||
|
xpos = xpos + CHAR_WIDTH + 1
|
||||||
|
end
|
||||||
|
return texture
|
||||||
|
end
|
||||||
|
|
||||||
|
local generate_texture = function(lines)
|
||||||
|
local texture = "[combine:"..LCD_WITH.."x"..LCD_WITH
|
||||||
|
local ypos = 16
|
||||||
|
for i = 1, #lines do
|
||||||
|
texture = texture..generate_line(lines[i], ypos)
|
||||||
|
ypos = ypos + LINE_HEIGHT
|
||||||
|
end
|
||||||
|
return texture
|
||||||
|
end
|
||||||
|
|
||||||
local lcds = {
|
local lcds = {
|
||||||
-- on ceiling
|
-- on ceiling
|
||||||
--* [0] = {delta = {x = 0, y = 0.4, z = 0}, pitch = math.pi / -2},
|
--* [0] = {delta = {x = 0, y = 0.4, z = 0}, pitch = math.pi / -2},
|
||||||
@ -141,88 +223,6 @@ minetest.register_entity(":digilines_lcd:text", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- CONSTANTS
|
|
||||||
local LCD_WITH = 100
|
|
||||||
local LCD_PADDING = 8
|
|
||||||
|
|
||||||
local LINE_LENGTH = 12
|
|
||||||
local NUMBER_OF_LINES = 5
|
|
||||||
|
|
||||||
local LINE_HEIGHT = 14
|
|
||||||
local CHAR_WIDTH = 5
|
|
||||||
|
|
||||||
create_lines = function(text)
|
|
||||||
local line = ""
|
|
||||||
local line_num = 1
|
|
||||||
local tab = {}
|
|
||||||
for word in string.gmatch(text, "%S+") do
|
|
||||||
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then
|
|
||||||
if line ~= "" then
|
|
||||||
line = line.." "..word
|
|
||||||
else
|
|
||||||
line = word
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.insert(tab, line)
|
|
||||||
if word ~= "|" then
|
|
||||||
line = word
|
|
||||||
else
|
|
||||||
line = ""
|
|
||||||
end
|
|
||||||
line_num = line_num+1
|
|
||||||
if line_num > NUMBER_OF_LINES then
|
|
||||||
return tab
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(tab, line)
|
|
||||||
return tab
|
|
||||||
end
|
|
||||||
|
|
||||||
generate_texture = function(lines)
|
|
||||||
local texture = "[combine:"..LCD_WITH.."x"..LCD_WITH
|
|
||||||
local ypos = 16
|
|
||||||
for i = 1, #lines do
|
|
||||||
texture = texture..generate_line(lines[i], ypos)
|
|
||||||
ypos = ypos + LINE_HEIGHT
|
|
||||||
end
|
|
||||||
return texture
|
|
||||||
end
|
|
||||||
|
|
||||||
generate_line = function(s, ypos)
|
|
||||||
local i = 1
|
|
||||||
local parsed = {}
|
|
||||||
local width = 0
|
|
||||||
local chars = 0
|
|
||||||
while chars < max_chars and i <= #s do
|
|
||||||
local file = nil
|
|
||||||
if charmap[s:sub(i, i)] ~= nil then
|
|
||||||
file = charmap[s:sub(i, i)]
|
|
||||||
i = i + 1
|
|
||||||
elseif i < #s and charmap[s:sub(i, i + 1)] ~= nil then
|
|
||||||
file = charmap[s:sub(i, i + 1)]
|
|
||||||
i = i + 2
|
|
||||||
else
|
|
||||||
print("[digilines] W: LCD: unknown symbol in '"..s.."' at "..i)
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
if file ~= nil then
|
|
||||||
width = width + CHAR_WIDTH
|
|
||||||
table.insert(parsed, file)
|
|
||||||
chars = chars + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
width = width - 1
|
|
||||||
|
|
||||||
local texture = ""
|
|
||||||
local xpos = math.floor((LCD_WITH - 2 * LCD_PADDING - width) / 2 + LCD_PADDING)
|
|
||||||
for i = 1, #parsed do
|
|
||||||
texture = texture..":"..xpos..","..ypos.."="..parsed[i]..".png"
|
|
||||||
xpos = xpos + CHAR_WIDTH + 1
|
|
||||||
end
|
|
||||||
return texture
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "digilines:lcd 2",
|
output = "digilines:lcd 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
25
wire_std.lua
25
wire_std.lua
@ -3,19 +3,19 @@
|
|||||||
-- 1 = there is one; 0 = there is none
|
-- 1 = there is one; 0 = there is none
|
||||||
-- y always means y+
|
-- y always means y+
|
||||||
|
|
||||||
box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
|
local box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
|
||||||
box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
|
local box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
|
||||||
box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
|
local box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
|
||||||
|
|
||||||
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
|
local box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
|
||||||
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
|
local box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
|
||||||
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
|
local box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
|
||||||
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
|
local box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
|
||||||
|
|
||||||
box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
|
local box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
|
||||||
box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
|
local box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
|
||||||
box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
|
local box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
|
||||||
box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
|
local box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
|
||||||
|
|
||||||
for xp=0, 1 do
|
for xp=0, 1 do
|
||||||
for zp=0, 1 do
|
for zp=0, 1 do
|
||||||
@ -32,6 +32,8 @@ for zmy=0, 1 do
|
|||||||
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
|
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
|
||||||
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
|
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
|
||||||
|
|
||||||
|
local wiredesc
|
||||||
|
|
||||||
if nodeid == "00000000" then
|
if nodeid == "00000000" then
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
wiredesc = "Digiline"
|
wiredesc = "Digiline"
|
||||||
@ -51,6 +53,7 @@ for zmy=0, 1 do
|
|||||||
if xmy == 1 then table.insert(nodebox, box_xmy) end
|
if xmy == 1 then table.insert(nodebox, box_xmy) end
|
||||||
if zmy == 1 then table.insert(nodebox, box_zmy) end
|
if zmy == 1 then table.insert(nodebox, box_zmy) end
|
||||||
|
|
||||||
|
local tiles
|
||||||
if adjx and adjz and (xp + zp + xm + zm > 2) then
|
if adjx and adjz and (xp + zp + xm + zm > 2) then
|
||||||
table.insert(nodebox, box_bump1)
|
table.insert(nodebox, box_bump1)
|
||||||
table.insert(nodebox, box_bump2)
|
table.insert(nodebox, box_bump2)
|
||||||
|
Loading…
Reference in New Issue
Block a user