From cc2201beb32a0294b18ff680ac2533df810faa47 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 22 Dec 2018 11:19:34 +0100 Subject: [PATCH] WiFi pairing improved --- internal1.lua | 10 +++++++--- locale/de.mo | Bin 526 -> 686 bytes locale/de.po | 23 +++++++++++++++++------ locale/template.pot | 12 ++++++++++-- tube_api.lua | 12 +++++++----- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/internal1.lua b/internal1.lua index c1a92d6..a8489a9 100644 --- a/internal1.lua +++ b/internal1.lua @@ -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 diff --git a/locale/de.mo b/locale/de.mo index d7fa725d3b9b1b10fc3680b6a26a913bfd1295f3..c769b79dab16daeccb7c4c46d42de9f3d8378e7d 100644 GIT binary patch delta 403 zcmYk0yGq1B6ow~jRtpy|D=32KS(F7YMPjA4D%uDlVk@)RV=}Nik;w!v&2|Ffg z{XcE-Sg{^!&4J}6ohTbouUD}q8`&Ds0FZtQq(S=s0cjv&U;$zn0NN?ZzzpOufkd41^YT)YOHxx5 z$}>wc6ehmZ;1118h6zqKVD#WIP%t#JGPKk-Ff=fjyo@npax0_KWIiUX$?;6u0)Cmv R86^s3sYOYpc`2!R3;^QpCjbBd diff --git a/locale/de.po b/locale/de.po index 767e80b..b19d36e 100644 --- a/locale/de.po +++ b/locale/de.po @@ -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" diff --git a/locale/template.pot b/locale/template.pot index 7abdda1..fa6cc33 100644 --- a/locale/template.pot +++ b/locale/template.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/tube_api.lua b/tube_api.lua index a7ffc55..f7e1585 100644 --- a/tube_api.lua +++ b/tube_api.lua @@ -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