Compare commits

...

16 Commits

Author SHA1 Message Date
f5b2521e4b Merge remote-tracking branch 'upstream/master' 2022-08-26 14:53:49 +02:00
d35f7f12c4 zh_TW Translations (#76) 2022-08-13 15:03:12 +02:00
b36dd31f0f Merge remote-tracking branch 'upstream/master' 2021-07-24 13:05:51 +02:00
f03cd02854 Send messages from digiline chest when items are moved with tubelib (#73)
Sends the same events from tubelib interaction as would be sent from pipeworks

 * Moved the tube_can_insert and tube_insert_object callbacks out of the node definition so they can be re-used in the tubelib registration
 * Optionally required tubelib and registered callbacks for pushing and pulling
 * Used "speculative pull" variable to only send a "take" event if tubelib's unpull is not called after a pull - this happens when it tries to take an item but there is no room, so it fails
2021-07-21 15:07:15 +02:00
5a04699b3e Merge remote-tracking branch 'upstream/master' 2021-06-20 17:06:29 +02:00
a055b5045a Add craft recipes for RTC and Lightsensor (#71) 2021-05-13 15:33:58 +02:00
7a5cc43280 Merge remote-tracking branch 'upstream/master' 2021-04-17 13:45:38 +02:00
660bd62528 Optimize textures to avoid use_texture_alpha warnings (#70)
Co-authored-by: sys4 <bricassa@sys4.fr>
2021-04-14 16:19:53 +02:00
327c96cba8 Merge branch 'github' 2021-03-19 22:20:48 +01:00
0aa935c271 Optimize textures to avoid use_texture_alpha warnings 2021-03-19 22:15:45 +01:00
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
24 changed files with 301 additions and 128 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,8 +7,11 @@ read_globals = {
"pipeworks", "pipeworks",
"dump", "dump",
"VoxelArea", "VoxelArea",
"ItemStack",
} }
globals = { globals = {
"digilines", "digilines",
"tubelib",
"tubelib2"
} }

View File

@ -54,6 +54,9 @@ overflow <itemstack> <count>
Tricky situation: Tricky situation:
if you have a blank spot and put say 82 torches down your pipeline, followed by 99 coal, the 82 torches will go in the chest, and the chest will see that 1 more torch can fit since that would only go to 83. Since 1 more torch can fit, no "full" message will fire off. Then when the coal hits the chest, the "fail" message will fire and the coal will bounce out. The chest couldn't predict that coal would be coming next, so it couldn't know that the chest is full, for coal, while not full for torches. if you have a blank spot and put say 82 torches down your pipeline, followed by 99 coal, the 82 torches will go in the chest, and the chest will see that 1 more torch can fit since that would only go to 83. Since 1 more torch can fit, no "full" message will fire off. Then when the coal hits the chest, the "fail" message will fire and the coal will bounce out. The chest couldn't predict that coal would be coming next, so it couldn't know that the chest is full, for coal, while not full for torches.
The inventory is also compatible with [`tubelib`](https://github.com/joe7575/techpack/tree/master/tubelib), which generally works in the same way as [`pipeworks`](https://gitlab.com/VanessaE/pipeworks) but transfers happen immediately and do not "bounce". This means that the messages should be identical to the messages sent by [`pipeworks`](https://gitlab.com/VanessaE/pipeworks), except that items will not send the "lost" message when they cannot fit.
One oddity is that "take" messages will be asynchronous because, if an item does not fit in the chest, the event will need to be canceled. This means that it is possible (though highly unlikely) to recieve a "put" message into a slot which you have not yet recieved a "take" message for, there will not actually be two stacks in the same slot, though it may briefly appear that way until the "take" message is recieved.
TODO: TODO:
- make chest.lua a mixin that gets both default and locked chests - make chest.lua a mixin that gets both default and locked chests
- digiline aware furnaces - digiline aware furnaces

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

@ -1,5 +1,5 @@
digilines = {} digilines = {}
digilines.S = minetest.get_translator("digilines")
-- Backwards compatibility code. -- Backwards compatibility code.
-- We define a proxy table whose methods can be called with the -- We define a proxy table whose methods can be called with the

View File

@ -92,7 +92,7 @@ function digilines.transmit(pos, channel, msg, checked)
return return
end end
checked[checkedID] = true checked[checkedID] = true
digilines.vm_begin() digilines.vm_begin()
local queue = queue_new() local queue = queue_new()
queue_enqueue(queue, pos) queue_enqueue(queue, pos)
@ -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

@ -1,3 +1,5 @@
local S = digilines.S
local pipeworks_enabled = minetest.get_modpath("pipeworks") ~= nil local pipeworks_enabled = minetest.get_modpath("pipeworks") ~= nil
-- Sends a message onto the Digilines network. -- Sends a message onto the Digilines network.
@ -51,9 +53,102 @@ local last_inventory_put_stack
-- that should be removed once thats fixed. -- that should be removed once thats fixed.
local last_inventory_take_index local last_inventory_take_index
local tube_can_insert = function(pos, _, stack, direction)
local ret = minetest.get_meta(pos):get_inventory():room_for_item("main", stack)
if not ret then
-- The stack cannot be accepted. It will never be passed to
-- insert_object, but it should be reported as a toverflow.
-- Here, direction = direction item is moving, which is into
-- side.
local side = vector.multiply(direction, -1)
send_message(pos, "toverflow", stack, nil, nil, side)
end
return ret
end
local tube_insert_object = function(pos, _, original_stack, direction)
-- Here, direction = direction item is moving, which is into side.
local side = vector.multiply(direction, -1)
local inv = minetest.get_meta(pos):get_inventory()
local inv_contents = inv:get_list("main")
local any_put = false
local stack = original_stack
local stack_name = stack:get_name()
local stack_count = stack:get_count()
-- Walk the inventory, adding items to existing stacks of the same
-- type.
for i = 1, #inv_contents do
local existing_stack = inv_contents[i]
if not existing_stack:is_empty() and existing_stack:get_name() == stack_name then
local leftover = existing_stack:add_item(stack)
local leftover_count = leftover:get_count()
if leftover_count ~= stack_count then
-- We put some items into the slot. Update the slot in
-- the inventory, tell Digilines listeners about it,
-- and keep looking for the a place to put the
-- leftovers if any.
any_put = true
inv:set_stack("main", i, existing_stack)
local stack_that_was_put
if leftover_count == 0 then
stack_that_was_put = stack
else
stack_that_was_put = ItemStack(stack)
stack_that_was_put:set_count(stack_count - leftover_count)
end
send_message(pos, "tput", stack_that_was_put, nil, i, side)
stack = leftover
stack_count = leftover_count
if stack_count == 0 then
break
end
end
end
end
if stack_count ~= 0 then
-- Walk the inventory, adding items to empty slots.
for i = 1, #inv_contents do
local existing_stack = inv_contents[i]
if existing_stack:is_empty() then
local leftover = existing_stack:add_item(stack)
local leftover_count = leftover:get_count()
if leftover_count ~= stack_count then
-- We put some items into the slot. Update the slot in
-- the inventory, tell Digilines listeners about it,
-- and keep looking for the a place to put the
-- leftovers if any.
any_put = true
inv:set_stack("main", i, existing_stack)
local stack_that_was_put
if leftover_count == 0 then
stack_that_was_put = stack
else
stack_that_was_put = ItemStack(stack)
stack_that_was_put:set_count(stack_count - leftover_count)
end
send_message(pos, "tput", stack_that_was_put, nil, i, side)
stack = leftover
stack_count = leftover_count
if stack_count == 0 then
break
end
end
end
end
end
if any_put then
check_full(pos, original_stack)
end
if stack_count ~= 0 then
-- Some items could not be added and bounced back. Report them.
send_message(pos, "toverflow", stack, nil, nil, side)
end
return stack
end
minetest.register_alias("digilines_inventory:chest", "digilines:chest") minetest.register_alias("digilines_inventory:chest", "digilines:chest")
minetest.register_node("digilines:chest", { minetest.register_node("digilines:chest", {
description = "Digiline Chest", description = S("Digiline Chest"),
tiles = { tiles = {
"default_chest_top.png"..tubeconn, "default_chest_top.png"..tubeconn,
"default_chest_top.png"..tubeconn, "default_chest_top.png"..tubeconn,
@ -68,14 +163,14 @@ minetest.register_node("digilines:chest", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Digiline Chest") meta:set_string("infotext", S("Digiline Chest"))
meta:set_string("formspec", "size[8,10]".. meta:set_string("formspec", "size[8,10]"..
((default and default.gui_bg) or "").. ((default and default.gui_bg) or "")..
((default and default.gui_bg_img) or "").. ((default and default.gui_bg_img) or "")..
((default and default.gui_slots) or "").. ((default and default.gui_slots) or "")..
"label[0,0;Digiline Chest]".. "label[0,0;" .. S("Digiline Chest") .. "]" ..
"list[current_name;main;0,1;8,4;]".. "list[current_name;main;0,1;8,4;]"..
"field[2,5.5;5,1;channel;Channel;${channel}]".. "field[2,5.5;5,1;channel;" .. S("Channel") .. ";${channel}]"..
((default and default.get_hotbar_bg) and default.get_hotbar_bg(0,6) or "").. ((default and default.get_hotbar_bg) and default.get_hotbar_bg(0,6) or "")..
"list[current_player;main;0,6;8,4;]".. "list[current_player;main;0,6;8,4;]"..
"listring[]") "listring[]")
@ -97,7 +192,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
@ -109,97 +204,8 @@ minetest.register_node("digilines:chest", {
return not pipeworks.connects.facingFront(i,param2) return not pipeworks.connects.facingFront(i,param2)
end, end,
input_inventory = "main", input_inventory = "main",
can_insert = function(pos, _, stack, direction) can_insert = tube_can_insert,
local ret = minetest.get_meta(pos):get_inventory():room_for_item("main", stack) insert_object = tube_insert_object,
if not ret then
-- The stack cannot be accepted. It will never be passed to
-- insert_object, but it should be reported as a toverflow.
-- Here, direction = direction item is moving, which is into
-- side.
local side = vector.multiply(direction, -1)
send_message(pos, "toverflow", stack, nil, nil, side)
end
return ret
end,
insert_object = function(pos, _, original_stack, direction)
-- Here, direction = direction item is moving, which is into side.
local side = vector.multiply(direction, -1)
local inv = minetest.get_meta(pos):get_inventory()
local inv_contents = inv:get_list("main")
local any_put = false
local stack = original_stack
local stack_name = stack:get_name()
local stack_count = stack:get_count()
-- Walk the inventory, adding items to existing stacks of the same
-- type.
for i = 1, #inv_contents do
local existing_stack = inv_contents[i]
if not existing_stack:is_empty() and existing_stack:get_name() == stack_name then
local leftover = existing_stack:add_item(stack)
local leftover_count = leftover:get_count()
if leftover_count ~= stack_count then
-- We put some items into the slot. Update the slot in
-- the inventory, tell Digilines listeners about it,
-- and keep looking for the a place to put the
-- leftovers if any.
any_put = true
inv:set_stack("main", i, existing_stack)
local stack_that_was_put
if leftover_count == 0 then
stack_that_was_put = stack
else
stack_that_was_put = ItemStack(stack)
stack_that_was_put:set_count(stack_count - leftover_count)
end
send_message(pos, "tput", stack_that_was_put, nil, i, side)
stack = leftover
stack_count = leftover_count
if stack_count == 0 then
break
end
end
end
end
if stack_count ~= 0 then
-- Walk the inventory, adding items to empty slots.
for i = 1, #inv_contents do
local existing_stack = inv_contents[i]
if existing_stack:is_empty() then
local leftover = existing_stack:add_item(stack)
local leftover_count = leftover:get_count()
if leftover_count ~= stack_count then
-- We put some items into the slot. Update the slot in
-- the inventory, tell Digilines listeners about it,
-- and keep looking for the a place to put the
-- leftovers if any.
any_put = true
inv:set_stack("main", i, existing_stack)
local stack_that_was_put
if leftover_count == 0 then
stack_that_was_put = stack
else
stack_that_was_put = ItemStack(stack)
stack_that_was_put:set_count(stack_count - leftover_count)
end
send_message(pos, "tput", stack_that_was_put, nil, i, side)
stack = leftover
stack_count = leftover_count
if stack_count == 0 then
break
end
end
end
end
end
if any_put then
check_full(pos, original_stack)
end
if stack_count ~= 0 then
-- Some items could not be added and bounced back. Report them.
send_message(pos, "toverflow", stack, nil, nil, side)
end
return stack
end,
remove_items = function(pos, _, stack, dir, count) remove_items = function(pos, _, stack, dir, count)
-- Here, stack is the ItemStack in our own inventory that is being -- Here, stack is the ItemStack in our own inventory that is being
-- pulled from, NOT the stack that is actually pulled out. -- pulled from, NOT the stack that is actually pulled out.
@ -229,7 +235,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
@ -310,6 +316,96 @@ minetest.register_node("digilines:chest", {
end end
}) })
if minetest.global_exists("tubelib") then
local speculative_pull = nil
local pull_succeeded = function(passed_speculative_pull)
if passed_speculative_pull.canceled then return end
send_message(passed_speculative_pull.pos, "ttake", passed_speculative_pull.taken,
passed_speculative_pull.index, nil, vector.multiply(passed_speculative_pull.dir, -1))
check_empty(passed_speculative_pull.pos)
end
local function tube_side(pos, side)
if side == "U" then return {x=0,y=-1,z=0}
elseif side == "D" then return {x=0,y=1,z=0}
end
local param2 = minetest.get_node(pos).param2
return vector.multiply(
minetest.facedir_to_dir(
tubelib2.side_to_dir(side, param2) - 1),
-1)
end
tubelib.register_node("digilines:chest", {}, {
on_pull_stack = function(pos, side, _)
local inv = minetest.get_meta(pos):get_inventory()
for i, stack in pairs(inv:get_list("main")) do
if not stack:is_empty() then
speculative_pull = {
canceled = false,
pos = pos,
taken = stack,
index = i,
dir = tube_side(pos, side)
}
minetest.after(0, pull_succeeded, speculative_pull)
inv:set_stack("main", i, nil)
return stack
end
end
return nil
end,
on_pull_item = function(pos, side, _)
local inv = minetest.get_meta(pos):get_inventory()
for i, stack in pairs(inv:get_list("main")) do
if not stack:is_empty() then
local taken = stack:take_item(1)
speculative_pull = {
canceled = false,
pos = pos,
taken = taken,
index = i,
dir = tube_side(pos, side)
}
minetest.after(0, pull_succeeded, speculative_pull)
inv:set_stack("main", i, stack)
return taken
end
end
return nil
end,
on_push_item = function(pos, side, item, _)
local dir_vec = tube_side(pos, side)
if not tube_can_insert(pos, nil, item, dir_vec) then
return false
end
tube_insert_object(pos, nil, item, dir_vec)
return true
end,
on_unpull_item = function(pos, _, item, _)
local inv = minetest.get_meta(pos):get_inventory()
if not inv:room_for_item("main", item) then
return false
end
local existing_stack = inv:get_stack("main", speculative_pull.index)
local leftover = existing_stack:add_item(item)
if not leftover:is_empty() then
return false
end
inv:set_stack("main", speculative_pull.index, existing_stack)
-- Cancel speculative pull
-- this on_unpull_item callback should be called
-- immediately after on_pull_item if it fails
-- so this should be procedural
speculative_pull.canceled = true
speculative_pull = nil
return true
end,
})
end
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = "digilines:chest", output = "digilines:chest",

22
lcd.lua
View File

@ -1,3 +1,5 @@
local S = digilines.S
--* parts are currently not possible because you cannot set the pitch of an entity from lua --* parts are currently not possible because you cannot set the pitch of an entity from lua
-- Font: 04.jp.org -- Font: 04.jp.org
@ -84,9 +86,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 if word ~= " " then
else
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
@ -240,7 +241,7 @@ local prepare_writing = function(pos)
if entity then if entity then
set_texture(entity) set_texture(entity)
rotate_text(pos) rotate_text(pos)
end end
end end
local spawn_entity = function(pos) local spawn_entity = function(pos)
@ -271,7 +272,7 @@ local lcd_box = {
minetest.register_alias("digilines_lcd:lcd", "digilines:lcd") minetest.register_alias("digilines_lcd:lcd", "digilines:lcd")
minetest.register_node("digilines:lcd", { minetest.register_node("digilines:lcd", {
drawtype = "nodebox", drawtype = "nodebox",
description = "Digiline LCD", description = S("Digiline LCD"),
inventory_image = "lcd_lcd.png", inventory_image = "lcd_lcd.png",
wield_image = "lcd_lcd.png", wield_image = "lcd_lcd.png",
tiles = {"lcd_anyside.png"}, tiles = {"lcd_anyside.png"},
@ -292,12 +293,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 +314,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 +341,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

@ -1,3 +1,5 @@
local S = digilines.S
local GET_COMMAND = "GET" local GET_COMMAND = "GET"
local lsensor_nodebox = local lsensor_nodebox =
@ -31,7 +33,7 @@ end
minetest.register_alias("digilines_lightsensor:lightsensor", "digilines:lightsensor") minetest.register_alias("digilines_lightsensor:lightsensor", "digilines:lightsensor")
minetest.register_node("digilines:lightsensor", { minetest.register_node("digilines:lightsensor", {
description = "Digiline Lightsensor", description = S("Digiline Lightsensor"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"digilines_lightsensor.png"}, tiles = {"digilines_lightsensor.png"},
@ -39,7 +41,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 = {
@ -61,3 +63,11 @@ minetest.register_node("digilines:lightsensor", {
end end
end, end,
}) })
minetest.register_craft({
output = "digilines:lightsensor",
recipe = {
{"default:glass","default:glass","default:glass"},
{"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"},
}
})

17
locale/digilines.zh_TW.tr Normal file
View File

@ -0,0 +1,17 @@
# textdomain: digilines
### inventory.lua ###
Digiline Chest=訊纜儲物箱
Channel=頻道
### lcd.lua ###
Digiline LCD=訊纜 LCD
### lightsensor.lua ###
Digiline Lightsensor=訊纜光感應器
### rtc.lua ###
Digiline Real Time Clock (RTC)=訊纜實時時鐘
### wire_std.lua ###
Digiline=訊纜

17
locale/template.txt Normal file
View File

@ -0,0 +1,17 @@
# textdomain: digilines
### inventory.lua ###
Digiline Chest=
Channel=
### lcd.lua ###
Digiline LCD=
### lightsensor.lua ###
Digiline Lightsensor=
### rtc.lua ###
Digiline Real Time Clock (RTC)=
### wire_std.lua ###
Digiline=

View File

@ -1,5 +1,6 @@
name = digilines name = digilines
depends = default depends = default
optional_depends = tubelib,tubelib2
description = """ description = """
This mod adds digiline wires, an RTC (Real Time Clock), a light sensor as well as an LCD Screen. This mod adds digiline wires, an RTC (Real Time Clock), a light sensor as well as an LCD Screen.
Can be used together with the luacontroller from mesecons. Can be used together with the luacontroller from mesecons.

15
rtc.lua
View File

@ -1,3 +1,5 @@
local S = digilines.S
local GET_COMMAND = "GET" local GET_COMMAND = "GET"
local rtc_nodebox = local rtc_nodebox =
@ -26,7 +28,7 @@ end
minetest.register_alias("digilines_rtc:rtc", "digilines:rtc") minetest.register_alias("digilines_rtc:rtc", "digilines:rtc")
minetest.register_node("digilines:rtc", { minetest.register_node("digilines:rtc", {
description = "Digiline Real Time Clock (RTC)", description = S("Digiline Real Time Clock (RTC)"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"digilines_rtc.png"}, tiles = {"digilines_rtc.png"},
@ -35,7 +37,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 = {
@ -57,3 +59,12 @@ minetest.register_node("digilines:rtc", {
end end
end, end,
}) })
minetest.register_craft({
output = "digilines:rtc",
recipe = {
{"", "dye:black", ""},
{"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
{"", "digilines:wire_std_00000000", ""}
}
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 B

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 143 B

View File

@ -1,3 +1,5 @@
local S = digilines.S
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off -- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
-- The conditions in brackets define whether there is a digiline at that place or not -- The conditions in brackets define whether there is a digiline at that place or not
-- 1 = there is one; 0 = there is none -- 1 = there is one; 0 = there is none
@ -36,7 +38,7 @@ for zmy=0, 1 do
if nodeid == "00000000" then if nodeid == "00000000" then
groups = {dig_immediate = 3} groups = {dig_immediate = 3}
wiredesc = "Digiline" wiredesc = S("Digiline")
else else
groups = {dig_immediate = 3, not_in_creative_inventory = 1} groups = {dig_immediate = 3, not_in_creative_inventory = 1}
end end
@ -90,7 +92,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