v0.09 functions set_data/get_data added
parent
8be8751100
commit
8d6706d13e
14
README.md
14
README.md
|
@ -8,13 +8,13 @@ The focus for this Mod are:
|
|||
- simple API for programmers
|
||||
|
||||
The mod provides:
|
||||
- lumber tubes to connect 2 blocks
|
||||
- a Pusher block to pull/push items through tubes
|
||||
- a Distributor block with 4 output channels to sort incoming items
|
||||
- a Blackhole block which lets all items disappear (example/template for programmers)
|
||||
- a Button/switch block to send "switch on/off" messages
|
||||
- a Lamp block as receiving example for message communication
|
||||
- support for default blocks: furnace and chests
|
||||
- lumber tubes to connect 2 nodes
|
||||
- a Pusher node to pull/push items through tubes
|
||||
- a Distributor node with 4 output channels to sort incoming items
|
||||
- a Blackhole node which lets all items disappear (example/template for programmers)
|
||||
- a Button/switch node to send "switch on/off" messages
|
||||
- a Lamp node as receiving example for message communication
|
||||
- support for default node: furnace and chests
|
||||
|
||||
Hints for Admins: ![manual.md](https://github.com/joe7575/Minetest-Tubelib/blob/master/manual.md)
|
||||
Programmers Manual: ![api.md](https://github.com/joe7575/Minetest-Tubelib/blob/master/api.md)
|
||||
|
|
8
api.md
8
api.md
|
@ -270,10 +270,10 @@ If every player should be able to send a message, use nil for clicker_name.
|
|||
Tubelib includes the following example nodes which can be used for study
|
||||
and as templates for own projects:
|
||||
|
||||
- pusher.lua: a simple client pushing/pulling items
|
||||
- blackhole.lua: a simple server client, makes all items disappear
|
||||
- button.lua: a simple communication node, only sending messages
|
||||
- lamp.lua: a simple communication node, only receiving messages
|
||||
- pusher.lua: a simple client pushing/pulling items
|
||||
- blackhole.lua: a simple server client, makes all items disappear
|
||||
- button.lua: a simple communication node, only sending messages
|
||||
- lamp.lua: a simple communication node, only receiving messages
|
||||
|
||||
|
||||
## 6. Further information
|
||||
|
|
32
command.lua
32
command.lua
|
@ -135,6 +135,26 @@ function tubelib.get_node_number(pos)
|
|||
return nil
|
||||
end
|
||||
|
||||
-- Store any node number related, additional data
|
||||
-- param number: node number, returned by tubelib.add_node
|
||||
-- param name: name of the data (string)
|
||||
-- param data: any data (number, string, table)
|
||||
function tubelib.set_data(number, name, data)
|
||||
if Number2Pos[number] and type(name) == "string" then
|
||||
Number2Pos[number]["u_"..name] = data
|
||||
end
|
||||
end
|
||||
|
||||
-- Read node number related data
|
||||
-- param number: node number, returned by tubelib.add_node
|
||||
-- param name: name of the data (string)
|
||||
function tubelib.get_data(number, name)
|
||||
if Number2Pos[number] and type(name) == "string" then
|
||||
return Number2Pos[number]["u_"..name]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
-- Node construction/destruction functions
|
||||
-------------------------------------------------------------------
|
||||
|
@ -203,8 +223,10 @@ function tubelib.send_message(numbers, placer_name, clicker_name, topic, payload
|
|||
local data = Number2Pos[num]
|
||||
if placer_name and not minetest_is_protected(data.pos, placer_name) then
|
||||
if clicker_name == nil or not minetest_is_protected(data.pos, clicker_name) then
|
||||
if data and data.name and tubelib_NodeDef[data.name].on_recv_message then
|
||||
tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload)
|
||||
if data and data.name then
|
||||
if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then
|
||||
tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -217,8 +239,10 @@ function tubelib.send_request(number, placer_name, clicker_name, topic, payload)
|
|||
local data = Number2Pos[number]
|
||||
if placer_name and not minetest_is_protected(data.pos, placer_name) then
|
||||
if clicker_name == nil or not minetest_is_protected(data.pos, clicker_name) then
|
||||
if data and data.name and tubelib_NodeDef[data.name].on_recv_message then
|
||||
return tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload)
|
||||
if data and data.name then
|
||||
if tubelib_NodeDef[data.name] and tubelib_NodeDef[data.name].on_recv_message then
|
||||
return tubelib_NodeDef[data.name].on_recv_message(data.pos, topic, payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
1
init.lua
1
init.lua
|
@ -17,6 +17,7 @@
|
|||
2017-10-08 v0.06 tubelib.get_node_number() added, tubelib.version added
|
||||
2017-10-29 v0.07 Pusher bugfix, commands start/stop replaced by on/off
|
||||
2017-11-02 v0.08 Data base changed, aging of node positions added
|
||||
2017-11-04 v0.09 functions set_data/get_data added
|
||||
|
||||
]]--
|
||||
|
||||
|
|
30
manual.md
30
manual.md
|
@ -2,19 +2,21 @@
|
|||
|
||||
## Hints for Admins and Players
|
||||
|
||||
Tubelib is little useful for itself, it makes only sense with extensions such as ![tubelib_addons1](https://github.com/joe7575/tubelib_addons1).
|
||||
Tubelib is little useful for itself, it makes only sense with extensions such as:
|
||||
- ![tubelib_addons1](https://github.com/joe7575/tubelib_addons1) with farming nodes like Harvester, Quarry, Grinder, Autocrafter, Fermenter and Reformer.
|
||||
- ![tubelib_addons2](https://github.com/joe7575/tubelib_addons2) with control task nodes like Timer, Sequencer, Repeater, Gate, Door, Access Lock and Color Lamp.
|
||||
|
||||
But Tubelib provides the following basic blocks:
|
||||
However Tubelib provides the following basic nodes:
|
||||
|
||||
### Tubes
|
||||
Tubes allow the item exchange between two blocks. Tube forks are not possible. You have to use chests
|
||||
or other inventory blocks as hubs to build more complex structures.
|
||||
Tubes for itself are passive. For item exchange you have to use pulling/pushing blocks in addition.
|
||||
Tubes allow the item exchange between two nodes. Tube forks are not possible. You have to use chests
|
||||
or other inventory nodes as hubs to build more complex structures.
|
||||
Tubes for itself are passive. For item exchange you have to use pulling/pushing nodes in addition.
|
||||
The maximum tube length is limited to 100 nodes.
|
||||
|
||||
### Pusher
|
||||
The Pusher is able to pull one item out of one inventory block and pushing it into another inventory block directly or by means of tubes.
|
||||
It the source block is empty or the destination block full, the Pusher goes into STANDBY state for some seconds.
|
||||
The Pusher is able to pull one item out of one inventory node and pushing it into another inventory node directly or by means of tubes.
|
||||
It the source node is empty or the destination node full, the Pusher goes into STANDBY state for some seconds.
|
||||
|
||||
### Distributor
|
||||
The Distributor works as filter and pusher. It allows to divide and distribute incoming items into 4 tube channels.
|
||||
|
@ -23,15 +25,15 @@ items and restrains all others. To increase the throughput, one item can be adde
|
|||
An unconfigured but activated filter allows to pass up to 6 remaining items.
|
||||
|
||||
### Button/Switch
|
||||
The Button/Switch is a simple communication block for the Tubelib wireless communication.
|
||||
This block can be configured as button and switch. For the button configuration different switching
|
||||
times from 2 to 16 seconds are possible. The Button/Switch block has to be configured with the destination
|
||||
number of the receiving block (e.g. Lamp). This block allows to address several receivers by means or their numbers.
|
||||
All numbers of the receiving block have to be added a configuration time.
|
||||
The Button/Switch is a simple communication node for the Tubelib wireless communication.
|
||||
This node can be configured as button and switch. For the button configuration different switching
|
||||
times from 2 to 16 seconds are possible. The Button/Switch node has to be configured with the destination
|
||||
number of the receiving node (e.g. Lamp). This node allows to address several receivers by means or their numbers.
|
||||
All numbers of the receiving nodes have to be added a configuration time.
|
||||
|
||||
### Lamp
|
||||
The Lamp is a receiving block, showing its destination/communication number via "infotext".
|
||||
The Lamp is a receiving node, showing its destination/communication number via "infotext".
|
||||
The Lamp can be switched on/off by means of the right mouse button (use function) or by means of messages commands
|
||||
from a Button/Switch or any other command sending block.
|
||||
from a Button/Switch or any other command sending node.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue