WiFi pairing improved

This commit is contained in:
Joachim Stolberg 2018-12-22 11:19:34 +01:00
parent 0f2d062238
commit cc2201beb3
5 changed files with 41 additions and 16 deletions

@ -98,8 +98,12 @@ end
-- pos/dir are the pos of the secondary nodes pointing to the head tube nodes.
function Tube:update_secondary_node(pos1, dir1, pos2, dir2)
local _, node = self:get_node(pos1)
if self.secondary_node_names[node.name] and self.clbk_update_secondary_node then
self.clbk_update_secondary_node(node, pos1, dir1, pos2, Turn180Deg[dir2])
if self.secondary_node_names[node.name] then
if minetest.registered_nodes[node.name].tubelib2_on_update then
minetest.registered_nodes[node.name].tubelib2_on_update(node, pos1, dir1, pos2, Turn180Deg[dir2])
elseif self.clbk_update_secondary_node then
self.clbk_update_secondary_node(node, pos1, dir1, pos2, Turn180Deg[dir2])
end
end
end
@ -123,7 +127,7 @@ function Tube:store_teleport_data(pos, peer_pos)
meta:set_string("tele_pos", S(peer_pos))
meta:set_string("channel", nil)
meta:set_string("formspec", nil)
meta:set_string("infotext", I("Connected with ")..S(peer_pos))
meta:set_string("infotext", I("Paired with ")..S(peer_pos))
return meta:get_int("tube_dir")
end

Binary file not shown.

@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-20 16:17+0100\n"
"PO-Revision-Date: 2018-12-20 16:19+0100\n"
"POT-Creation-Date: 2018-12-22 11:16+0100\n"
"PO-Revision-Date: 2018-12-22 11:19+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.0.6\n"
#: tube_api.lua
@ -22,8 +22,12 @@ msgid "Maximum length reached!"
msgstr "Maximale Länge erreicht!"
#: tube_api.lua
msgid "Unconnected"
msgstr "Nicht verbunden"
msgid "Pairing is missing"
msgstr "Das Pairing fehlt noch"
#: tube_api.lua
msgid "Connection to a tube is missing!"
msgstr "Eine Verbindung zu einer Röhre fehlt!"
#: internal1.lua
msgid "Not connected!"
@ -32,3 +36,10 @@ msgstr "Nicht verbunden!"
#: internal1.lua internal2.lua
msgid "Connected with "
msgstr "Verbunden mit "
#: internal1.lua
msgid "Paired with "
msgstr "Gepaart mit "
#~ msgid "Unconnected"
#~ msgstr "Nicht verbunden"

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-20 16:17+0100\n"
"POT-Creation-Date: 2018-12-22 11:16+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -22,7 +22,11 @@ msgid "Maximum length reached!"
msgstr ""
#: tube_api.lua
msgid "Unconnected"
msgid "Pairing is missing"
msgstr ""
#: tube_api.lua
msgid "Connection to a tube is missing!"
msgstr ""
#: internal1.lua
@ -32,3 +36,7 @@ msgstr ""
#: internal1.lua internal2.lua
msgid "Connected with "
msgstr ""
#: internal1.lua
msgid "Paired with "
msgstr ""

@ -244,16 +244,18 @@ function Tube:prepare_pairing(pos, tube_dir, sFormspec)
if meta:get_int("tube_dir") ~= 0 then -- already prepared?
-- update tube_dir only
meta:set_int("tube_dir", tube_dir)
else
elseif tube_dir then
meta:set_int("tube_dir", tube_dir)
meta:set_string("channel", nil)
meta:set_string("infotext", I("Unconnected"))
meta:set_string("infotext", I("Pairing is missing"))
meta:set_string("formspec", sFormspec)
else
meta:set_string("infotext", I("Connection to a tube is missing!"))
end
end
function Tube:pairing(pos, channel)
if self.pairingList[channel] and pos ~= self.pairingList[channel] then
if self.pairingList[channel] and not vector.equals(pos, self.pairingList[channel]) then
-- store peer position on both nodes
local peer_pos = self.pairingList[channel]
local tube_dir1 = self:store_teleport_data(pos, peer_pos)
@ -265,7 +267,7 @@ function Tube:pairing(pos, channel)
self.pairingList[channel] = pos
local meta = M(pos)
meta:set_string("channel", channel)
meta:set_string("infotext", I("Unconnected").." ("..channel..")")
meta:set_string("infotext", I("Pairing is missing").." ("..channel..")")
return false
end
end
@ -281,7 +283,7 @@ function Tube:stop_pairing(pos, oldmetadata, sFormspec)
peer_meta:set_string("channel", nil)
peer_meta:set_string("tele_pos", nil)
peer_meta:set_string("formspec", sFormspec)
peer_meta:set_string("infotext", I("Unconnected"))
peer_meta:set_string("infotext", I("Pairing is missing"))
end
elseif oldmetadata.fields.channel then
self.pairingList[oldmetadata.fields.channel] = nil