summaryrefslogtreecommitdiff
path: root/digilines/lcd.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-17 16:53:18 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-17 16:53:18 -0400
commit907e8bf6a64215a516fdf16869dd81248aeaa2f6 (patch)
treed199282e5764c7ab5183fe0d78ed0412dbb0b89f /digilines/lcd.lua
parent06d9243586cecb1abed74550ce2544b436572a35 (diff)
downloaddreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.gz
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.bz2
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.xz
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.zip
update digilines, technic, unified inventory,
and switched castles to the new modpack form
Diffstat (limited to 'digilines/lcd.lua')
-rw-r--r--digilines/lcd.lua180
1 files changed, 90 insertions, 90 deletions
diff --git a/digilines/lcd.lua b/digilines/lcd.lua
index 3370a31..ce17dac 100644
--- a/digilines/lcd.lua
+++ b/digilines/lcd.lua
@@ -20,16 +20,98 @@ else
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 = {
-- on ceiling
--* [0] = {delta = {x = 0, y = 0.4, z = 0}, pitch = math.pi / -2},
-- on ground
--* [1] = {delta = {x = 0, y =-0.4, z = 0}, pitch = math.pi / 2},
-- sides
- [2] = {delta = {x = 0.4, y = 0, z = 0}, yaw = math.pi / -2},
- [3] = {delta = {x = -0.4, y = 0, z = 0}, yaw = math.pi / 2},
- [4] = {delta = {x = 0, y = 0, z = 0.4}, yaw = 0},
- [5] = {delta = {x = 0, y = 0, z = -0.4}, yaw = math.pi},
+ [2] = {delta = {x = 0.437, y = 0, z = 0}, yaw = math.pi / -2},
+ [3] = {delta = {x = -0.437, y = 0, z = 0}, yaw = math.pi / 2},
+ [4] = {delta = {x = 0, y = 0, z = 0.437}, yaw = 0},
+ [5] = {delta = {x = 0, y = 0, z = -0.437}, yaw = math.pi},
}
local reset_meta = function(pos)
@@ -58,7 +140,7 @@ local prepare_writing = function(pos)
return text
end
-local on_digiline_receive = function(pos, node, channel, msg)
+local on_digiline_receive = function(pos, _, channel, msg)
local meta = minetest.get_meta(pos)
local setchan = meta:get_string("channel")
if setchan ~= channel then return end
@@ -91,7 +173,7 @@ minetest.register_node("digilines:lcd", {
selection_box = lcd_box,
groups = {choppy = 3, dig_immediate = 2},
- after_place_node = function (pos, placer, itemstack)
+ after_place_node = function (pos)
local param2 = minetest.get_node(pos).param2
if param2 == 0 or param2 == 1 then
minetest.add_node(pos, {name = "digilines:lcd", param2 = 3})
@@ -107,7 +189,7 @@ minetest.register_node("digilines:lcd", {
clearscreen(pos)
end,
- on_receive_fields = function(pos, formname, fields, sender)
+ on_receive_fields = function(pos, _, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
minetest.record_protection_violation(pos, name)
@@ -118,7 +200,7 @@ minetest.register_node("digilines:lcd", {
end
end,
- digiline =
+ digiline =
{
receptor = {},
effector = {
@@ -141,88 +223,6 @@ minetest.register_entity(":digilines_lcd:text", {
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({
output = "digilines:lcd 2",
recipe = {