mirror of
https://codeberg.org/tenplus1/teleport_potion.git
synced 2025-03-14 21:51:24 +00:00
Added formspec checks and switch to for old pad texture (thanks mazes 80)
This commit is contained in:
parent
6a9d10397b
commit
836562498e
6 changed files with 25 additions and 14 deletions
|
@ -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
|
||||
|
|
32
init.lua
32
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 .. ")")
|
||||
|
|
|
@ -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!"
|
||||
|
|
|
@ -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 !
|
||||
|
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
|
@ -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
|
BIN
textures/teleport_potion_pad_v1.png
Normal file
BIN
textures/teleport_potion_pad_v1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 201 B |
Loading…
Add table
Reference in a new issue