Skip to content

Commit

Permalink
luacheck + translation support (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklp09 committed Jul 5, 2023
1 parent ac3d41f commit f1486be
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: luacheck
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""
10 changes: 10 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
unused_args = false

read_globals = {
"minetest",
"digilines"
}

globals = {
"nixie_tubes"
}
40 changes: 26 additions & 14 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
nixie_tubes = {}

local S = minetest.get_translator(minetest.get_current_modname())
local FS = function(...) return minetest.formspec_escape(S(...)) end

local nixie_types = {
"1",
Expand Down Expand Up @@ -32,8 +33,8 @@ local reset_meta = function(pos)
minetest.get_meta(pos):set_string("formspec",
"formspec_version[4]"..
"size[8,4]"..
"button_exit[3,2.5;2,0.5;proceed;Proceed]"..
"field[1.75,1.5;4.5,0.5;channel;Channel;${channel}]"
"button_exit[3,2.5;2,0.5;proceed;"..FS("Proceed").."]"..
"field[1.75,1.5;4.5,0.5;channel;"..FS("Channel")..";${channel}]"
)
end

Expand Down Expand Up @@ -66,20 +67,20 @@ local on_digiline_receive_deca = function(pos, node, channel, msg)
num = (tonumber(tubenum) or 0) + 1
if num > 9 then
num = 0
digiline:receptor_send(pos, digiline.rules.default, channel, "carry")
digilines:receptor_send(pos, digilines.rules.default, channel, "carry")
end
minetest.swap_node(pos, { name = "nixie_tubes:decatron_"..num, param2 = node.param2})

elseif msg == "dec" then
num = (tonumber(tubenum) or 0) - 1
if num < 0 then
num = 9
digiline:receptor_send(pos, digiline.rules.default, channel, "borrow")
digilines:receptor_send(pos, digilines.rules.default, channel, "borrow")
end
minetest.swap_node(pos, { name = "nixie_tubes:decatron_"..num, param2 = node.param2})

elseif msg == "get" then
digiline:receptor_send(pos, digiline.rules.default, channel, tubenum)
digilines:receptor_send(pos, digilines.rules.default, channel, tubenum)

end
end
Expand All @@ -88,10 +89,10 @@ end

for _,tube in ipairs(nixie_types) do
local groups = { cracky = 2, not_in_creative_inventory = 1}
local light = LIGHT_MAX-4
local light2 = LIGHT_MAX-5
local description = S("Nixie Tube ("..tube..")")
local description2 = S("Decatron ("..tube..")")
local light = minetest.LIGHT_MAX-4
local light2 = minetest.LIGHT_MAX-5
local description = S("Nixie Tube (@1)", tube)
local description2 = S("Decatron (@1)", tube)
local description3 = S("Numitron Tube")
local cathode = "nixie_tube_cathode_off.png^nixie_tube_cathode_"..tube..".png"
local cathode2 = "decatron_cathode_"..tube..".png"
Expand Down Expand Up @@ -377,7 +378,8 @@ local display_string = function(pos, channel, string)
local node = minetest.get_node(pos2)
local meta = minetest.get_meta(pos2)
local setchan = meta:get_string("channel")
if not string.match(node.name, "nixie_tubes:alnum_") or (setchan ~= nil and setchan ~= "" and setchan ~= channel) then break end
if not string.match(node.name, "nixie_tubes:alnum_")
or (setchan ~= nil and setchan ~= "" and setchan ~= channel) then break end
local asc = string.byte(padded_string, i, i)
if node.param2 == fdir and ((asc > 30 and asc < 128) or asc == 144) then
minetest.swap_node(pos2, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2})
Expand Down Expand Up @@ -413,9 +415,11 @@ local on_digiline_receive_alnum = function(pos, node, channel, msg)
if (asc > 30 and asc < 128) or asc == 144 then
minetest.swap_node(pos, { name = "nixie_tubes:alnum_"..asc, param2 = node.param2})
elseif msg == "get" then -- get value as ASCII numerical value
digiline:receptor_send(pos, digiline.rules.default, channel, tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)"))) -- wonderfully horrible string manipulaiton
digilines:receptor_send(pos, digilines.rules.default, channel,
tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)")))
elseif msg == "getstr" then -- get actual char
digiline:receptor_send(pos, digiline.rules.default, channel, string.char(tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)"))))
digilines:receptor_send(pos, digilines.rules.default, channel, string.char(
tonumber(string.match(minetest.get_node(pos).name,"nixie_tubes:alnum_(.+)"))))
end
end
elseif msg and type(msg) == "number" then
Expand All @@ -432,8 +436,8 @@ for i in ipairs(alnum_chars) do
local bits = alnum_chars[i][2]

local groups = { cracky = 2, not_in_creative_inventory = 1}
local light = LIGHT_MAX-4
local description = S("Alphanumeric Nixie Tube ("..char..")")
local light = minetest.LIGHT_MAX-4
local description = S("Alphanumeric Nixie Tube (@1)", char)

local wires = "nixie_tube_alnum_wires.png"
for j = 1, 15 do
Expand Down Expand Up @@ -505,6 +509,14 @@ minetest.register_craft({
},
})

minetest.register_craft({
output = "nixie_tubes:decatron_off 4",
recipe = {
{ "", "default:glass", "" },
{ "default:glass", "default:mese_crystal_fragment", "default:glass" },
{ "default:glass", "default:copper_ingot", "default:glass" }
},
})

minetest.register_craft({
output = "nixie_tubes:alnum_32 4",
Expand Down
10 changes: 10 additions & 0 deletions locale/nixie_tubes.de.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# textdomain: nixie_tubes
Nixie Tube (@1)=Nixie Röhre (@1)
Decatron (@1)=Dekatron (@1)
Numitron Tube=Numitron Röhre
Nixie Tube=Nixie Röhre
Decatron=Dekatron
Alphanumeric Nixie Tube (@1)=Alphanumerische Nixie Röhre (@1)
Alphanumeric Nixie Tube=Alphanumerische Nixie Röhre
Proceed=Fortsetzen
Channel=Kanal
10 changes: 10 additions & 0 deletions locale/template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# textdomain: nixie_tubes
Nixie Tube (@1)=
Decatron (@1)=
Numitron Tube=
Nixie Tube=
Decatron=
Alphanumeric Nixie Tube (@1)=
Alphanumeric Nixie Tube=
Proceed=
Channel=

0 comments on commit f1486be

Please sign in to comment.