Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
loosewheel committed May 23, 2022
1 parent aa9160b commit 6304a2a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 11 deletions.
23 changes: 23 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
unused_args = false
allow_defined_top = true
max_comment_line_length = 999

read_globals = {
"DIR_DELIM",
"minetest", "core",
"unpack",
"dump",
table = { fields = { "copy", "getn" } },
"vector", "nodeupdate",
"VoxelManip", "VoxelArea",
"PseudoRandom", "ItemStack",
"lwwires",
"default",
"intllib",
"mesecon",
"mesecons",
"digilines",
}

globals = {
}
4 changes: 4 additions & 0 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function lwwires.bundle_on (src_pos, pos, wires)
end

utils.wire_connections.turn_on (src_pos, colors, pos)

return true
end


Expand All @@ -52,6 +54,8 @@ function lwwires.bundle_off (src_pos, pos, wires)
end

utils.wire_connections.turn_off (src_pos, colors, pos)

return true
end


Expand Down
5 changes: 5 additions & 0 deletions change.log
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ v0.1.7

v0.1.8
* Code cleanup.


v0.1.9
* Added bundle_pos parameter to bundle_on and bundle_off interface callbacks.
* Fixed return value in lwwires.bundle_on and lwwires.bundle_off.
14 changes: 10 additions & 4 deletions connections.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ local function add_node_notify_on (pos, color)
if not list then
notify_on_positions[stest_pos] = { }
list = notify_on_positions[stest_pos]
list.bundle_pos = vector.new (pos)
end

list[color] = true
Expand All @@ -130,6 +131,7 @@ local function add_node_notify_off (pos, color)
if not list then
notify_off_positions[stest_pos] = { }
list = notify_off_positions[stest_pos]
list.bundle_pos = vector.new (pos)
end

list[color] = true
Expand All @@ -151,10 +153,12 @@ local function notify (action_wires, action_pos)
local colors = { }

for color, _ in pairs (v) do
colors[#colors + 1] = color
if color ~= "bundle_pos" then
colors[#colors + 1] = color
end
end

wires.bundle_off (pos, colors)
wires.bundle_off (pos, colors, v.bundle_pos)
end
end
end
Expand All @@ -173,10 +177,12 @@ local function notify (action_wires, action_pos)
local colors = { }

for color, _ in pairs (v) do
colors[#colors + 1] = color
if color ~= "bundle_pos" then
colors[#colors + 1] = color
end
end

wires.bundle_on (pos, colors)
wires.bundle_on (pos, colors, v.bundle_pos)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local version = "0.1.8"
local version = "0.1.9"



Expand Down
7 changes: 4 additions & 3 deletions mod_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ A node adjacent to a bundle can have the following interface in its
definition to respond to bundle cable events:
def._wires =
{
bundle_on = function (pos, wires)
bundle_on = function (pos, wires, bundle_pos)
-- called to notify when any wires are turned on
-- no return used
end,

bundle_off = function (pos, wires)
bundle_off = function (pos, wires, bundle_pos)
-- called to notify when any wires are turned off
-- no return used
end,
Expand All @@ -25,7 +25,8 @@ def._wires =
}
pos is the position of the node.
wires is a list of wire color strings affected by the action.
bundle_pos is the position of the bundle cable querying the state.
bundle_pos is the position of the bundle cable sending the notification or
querying the state.

When implementing the current_state callback, the state should be updated
after a call to lwwires.bundle_on but before a call to lwwires.bundle_off.
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CC-BY-SA 3.0

Version
=======
0.1.8
0.1.9


Minetest Version
Expand Down
4 changes: 2 additions & 2 deletions switch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ end



local function send_bundle_on (pos, wires)
local function send_bundle_on (pos, wires, bundle_pos)
local meta = minetest.get_meta (pos)

if meta then
Expand All @@ -183,7 +183,7 @@ end



local function send_bundle_off (pos, wires)
local function send_bundle_off (pos, wires, bundle_pos)
local meta = minetest.get_meta (pos)

if meta then
Expand Down

0 comments on commit 6304a2a

Please sign in to comment.