diff --git a/README.md b/README.md index 96f647f..875bb44 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234 Change log: +- 1.3 - Added some formspec checks and switch to enable old teleport pad texture (thanks mazes 80) - 1.2 - New teleport pad texture, code tweaks to work with minetest 5.x - 1.1 - Using 0.4.16+ code changes, can only teleport players now, added MineClone2 crafts and spanish translation - 1.0 - Added changes by maybe_dragon to bookmark teleport destination before using pads and potions diff --git a/init.lua b/init.lua index 67d68da..6be289e 100644 --- a/init.lua +++ b/init.lua @@ -24,6 +24,13 @@ local function is_creative(name) return creative_mode_cache or minetest.check_player_privs(name, {creative = true}) end +-- choose texture for teleport pad +local teleport_pad_texture = "teleport_potion_pad.png" + +if minetest.settings:get_bool("teleport_potion_use_old_texture") == true then + teleport_pad_texture = "teleport_potion_pad_v1.png" +end + -- make sure coordinates are valid local check_coordinates = function(str) @@ -304,7 +311,7 @@ end local teleport_formspec_context = {} minetest.register_node("teleport_potion:pad", { - tiles = {"teleport_potion_pad.png", "teleport_potion_pad.png^[transformFY"}, + tiles = {teleport_pad_texture, teleport_pad_texture .. "^[transformFY"}, drawtype = "nodebox", paramtype = "light", paramtype2 = "facedir", @@ -312,8 +319,8 @@ minetest.register_node("teleport_potion:pad", { walkable = true, sunlight_propagates = true, description = S("Teleport Pad (use to set destination, place to open portal)"), - inventory_image = "teleport_potion_pad.png", - wield_image = "teleport_potion_pad.png", + inventory_image = teleport_pad_texture, + wield_image = teleport_pad_texture, light_source = 5, groups = {snappy = 3}, node_box = { @@ -369,15 +376,9 @@ minetest.register_node("teleport_potion:pad", { end local meta = minetest.get_meta(pos) - local coords = { - x = meta:get_int("x"), - y = meta:get_int("y"), - z = meta:get_int("z") - } - local coords = coords.x .. "," .. coords.y .. "," .. coords.z + local coords = meta:get_int("x") .. "," .. meta:get_int("y") .. "," .. meta:get_int("z") local desc = meta:get_string("desc") - - formspec = "field[desc;" .. S("Description") .. ";" + local formspec = "field[desc;" .. S("Description") .. ";" .. minetest.formspec_escape(desc) .. "]" -- Only allow privileged players to change coordinates @@ -410,6 +411,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) teleport_formspec_context[name] = nil + if fields.control == nil and fields.desc == nil then + return false + end + local meta = minetest.get_meta(context.pos) -- Coordinates were changed @@ -427,8 +432,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end -- Update infotext - if fields.desc and fields.desc ~= "" then + if fields.desc then meta:set_string("desc", fields.desc) + end + + if fields.desc and fields.desc ~= "" then meta:set_string("infotext", S("Teleport to @1", fields.desc)) else local coords = minetest.string_to_pos("(" .. context.coords .. ")") diff --git a/locale/fr.po b/locale/fr.po index 78cd2be..1b0c6ff 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -48,7 +48,7 @@ msgstr "Téléportation vers @1" #: init.lua msgid "Pad Active (@1,@2,@3)" -msgstr "Pad activé (@1,@,2,@3)" +msgstr "Pad activé (@1,@2,@3)" #: init.lua msgid "Teleport Pad coordinates failed!" diff --git a/locale/teleport_potion.fr.tr b/locale/teleport_potion.fr.tr index 46ee711..ab2e99f 100644 --- a/locale/teleport_potion.fr.tr +++ b/locale/teleport_potion.fr.tr @@ -7,5 +7,5 @@ Potion failed!=La potion n'a pas fonctionné ! Teleport Pad (place and right-click to enchant location)=Pad de téléportation (poser puis clic-droit pour enchanter l'emplacement) Enter teleport coords (e.g. 200,20,-200,Home)=Saisissez les coordonnées de téléportation (ex : 200,20,-200,Maison) Teleport to @1=Téléportation vers @1 -Pad Active (@1,@2,@3)=Pad activé (@1,@,2,@3) +Pad Active (@1,@2,@3)=Pad activé (@1,@2,@3) Teleport Pad coordinates failed!=Les coordonnées du pad sont inchangées ! diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..32aa894 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# If enabled texture pad will use the old texture +teleport_potion_use_old_texture (Use old texture for teleport pad) bool false diff --git a/textures/teleport_potion_pad_v1.png b/textures/teleport_potion_pad_v1.png new file mode 100644 index 0000000..0f7c937 Binary files /dev/null and b/textures/teleport_potion_pad_v1.png differ