Compare commits

...

6 Commits

Author SHA1 Message Date
dd8432ef34 Merge remote-tracking branch 'upstream/master' 2021-01-24 12:54:09 +01:00
af4a699e19 Fix LuaCheck warning (#69) 2021-01-24 10:42:01 +01:00
c3f1b4ef41 Merge remote-tracking branch 'upstream/master' 2021-01-23 12:57:25 +01:00
ff525c09a4 Fix wires not connecting to nodes using digilines def (#68) 2021-01-21 17:47:55 +01:00
45991bf124 Merge remote-tracking branch 'upstream/master' 2021-01-19 23:26:45 +01:00
dc6cc0b04a [LuaCheck]: Various changes and improvements (#65)
* Add GitHub workflow
* Fix LuaCheck warnings
* Add build status badge on README.md
2021-01-16 09:59:19 +01:00
10 changed files with 40 additions and 28 deletions

11
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""

View File

@ -7,6 +7,7 @@ read_globals = {
"pipeworks", "pipeworks",
"dump", "dump",
"VoxelArea", "VoxelArea",
"ItemStack",
} }
globals = { globals = {

View File

@ -1,6 +1,8 @@
Digilines Digilines
========== ==========
[![Build status](https://github.com/minetest-mods/digilines/workflows/build/badge.svg)](https://github.com/minetest-mods/digilines/actions)
- The minetest counterpart for bus systems like i2c, SPI, RS232, USB - - The minetest counterpart for bus systems like i2c, SPI, RS232, USB -
- Minetest 5.0.0+ is required to use this mod. - Minetest 5.0.0+ is required to use this mod.

View File

@ -112,9 +112,9 @@ function digilines.transmit(pos, channel, msg, checked)
for _, rule in ipairs(rules) do for _, rule in ipairs(rules) do
local nextPos = digilines.addPosRule(curPos, rule) local nextPos = digilines.addPosRule(curPos, rule)
if digilines.rules_link(curPos, nextPos) then if digilines.rules_link(curPos, nextPos) then
local checkedID = minetest.hash_node_position(nextPos) local checkedID2 = minetest.hash_node_position(nextPos)
if not checked[checkedID] then if not checked[checkedID2] then
checked[checkedID] = true checked[checkedID2] = true
queue_enqueue(queue, nextPos) queue_enqueue(queue, nextPos)
end end
end end

View File

@ -97,7 +97,7 @@ minetest.register_node("digilines:chest", {
minetest.get_meta(pos):set_string("channel",fields.channel) minetest.get_meta(pos):set_string("channel",fields.channel)
end end
end, end,
digiline = { digilines = {
receptor = {}, receptor = {},
effector = { effector = {
action = function() end action = function() end
@ -229,7 +229,7 @@ minetest.register_node("digilines:chest", {
last_inventory_take_index = index last_inventory_take_index = index
return stack:get_count() return stack:get_count()
end, end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, _, from_index, _, to_index, count, player)
-- See what would happen if we were to move the items back from in the -- See what would happen if we were to move the items back from in the
-- opposite direction. In the event of a normal move, this must -- opposite direction. In the event of a normal move, this must
-- succeed, because a normal move subtracts some items from the from -- succeed, because a normal move subtracts some items from the from

14
lcd.lua
View File

@ -84,9 +84,8 @@ local create_lines = function(text)
line = word line = word
end end
else else
if word == " " then
-- don't add the space since we have a line break -- don't add the space since we have a line break
else if word ~= " " then
if line_len > 0 then if line_len > 0 then
-- ok, we need the new line -- ok, we need the new line
if flush_line_and_check_for_return() then return tab end if flush_line_and_check_for_return() then return tab end
@ -292,12 +291,12 @@ minetest.register_node("digilines:lcd", {
end, end,
on_construct = reset_meta, on_construct = reset_meta,
on_destruct = clearscreen, on_destruct = clearscreen,
on_punch = function(pos, node, puncher, pointed_thing) on_punch = function(pos, _, puncher, _)
if minetest.is_player(puncher) then if minetest.is_player(puncher) then
spawn_entity(pos) spawn_entity(pos)
end end
end, end,
on_rotate = function(pos, node, user, mode, new_param2) on_rotate = function(pos, _, _, mode, new_param2)
if mode ~= screwdriver.ROTATE_FACE then if mode ~= screwdriver.ROTATE_FACE then
return false return false
end end
@ -313,7 +312,7 @@ minetest.register_node("digilines:lcd", {
minetest.get_meta(pos):set_string("channel", fields.channel) minetest.get_meta(pos):set_string("channel", fields.channel)
end end
end, end,
digiline = { digilines = {
receptor = {}, receptor = {},
effector = { effector = {
action = on_digiline_receive action = on_digiline_receive
@ -340,7 +339,10 @@ minetest.register_craft({
output = "digilines:lcd 2", output = "digilines:lcd 2",
recipe = { recipe = {
{"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"}, {"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"},
{"mesecons_lightstone:lightstone_green_off","mesecons_lightstone:lightstone_green_off","mesecons_lightstone:lightstone_green_off"}, {"mesecons_lightstone:lightstone_green_off",
"mesecons_lightstone:lightstone_green_off",
"mesecons_lightstone:lightstone_green_off"},
{"default:glass","default:glass","default:glass"} {"default:glass","default:glass","default:glass"}
} }
}) })

View File

@ -39,7 +39,7 @@ minetest.register_node("digilines:lightsensor", {
groups = {dig_immediate=2}, groups = {dig_immediate=2},
selection_box = lsensor_selbox, selection_box = lsensor_selbox,
node_box = lsensor_nodebox, node_box = lsensor_nodebox,
digiline = digilines =
{ {
receptor = {}, receptor = {},
effector = { effector = {

View File

@ -35,7 +35,7 @@ minetest.register_node("digilines:rtc", {
groups = {dig_immediate=2}, groups = {dig_immediate=2},
selection_box = rtc_selbox, selection_box = rtc_selbox,
node_box = rtc_nodebox, node_box = rtc_nodebox,
digiline = digilines =
{ {
receptor = {}, receptor = {},
effector = { effector = {

View File

@ -90,7 +90,7 @@ for zmy=0, 1 do
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
digiline = digilines =
{ {
wire = wire =
{ {

View File

@ -1,15 +1,12 @@
minetest.register_on_placenode(function(pos, node)
if minetest.registered_nodes[node.name].digiline then
digilines.update_autoconnect(pos)
end
end)
minetest.register_on_dignode(function(pos, node) local function check_and_update(pos, node)
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].digiline then if digilines.getspec(node) then
-- need to make sure that node exists (unknown nodes!)
digilines.update_autoconnect(pos) digilines.update_autoconnect(pos)
end end
end) end
minetest.register_on_placenode(check_and_update)
minetest.register_on_dignode(check_and_update)
function digilines.update_autoconnect(pos, secondcall) function digilines.update_autoconnect(pos, secondcall)
local xppos = {x=pos.x+1, y=pos.y, z=pos.z} local xppos = {x=pos.x+1, y=pos.y, z=pos.z}
@ -42,8 +39,7 @@ function digilines.update_autoconnect(pos, secondcall)
digilines.update_autoconnect(zmympos, true) digilines.update_autoconnect(zmympos, true)
end end
local def = minetest.registered_nodes[minetest.get_node(pos).name] local digilinespec = digilines.getspec(minetest.get_node(pos))
local digilinespec = def and def.digiline
if not (digilinespec and digilinespec.wire and if not (digilinespec and digilinespec.wire and
digilinespec.wire.use_autoconnect) then digilinespec.wire.use_autoconnect) then
return nil return nil