Commit 718adac0 authored by TenPlus1's avatar TenPlus1
Browse files

Teleport pads now have descriptions added

parent 4f88bf11
...@@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234 ...@@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234
Changes: Changes:
- 0.7 - Can now enter descriptions for teleport pads e.g. (0,12,0,Home)
- 0.6 - Tweaked and tidied code, added map_generation_limit's - 0.6 - Tweaked and tidied code, added map_generation_limit's
- 0.5 - Added throwable potions - 0.5 - Added throwable potions
- 0.4 - Code tidy and particle effects added - 0.4 - Code tidy and particle effects added
......
--= Teleport Potion mod 0.6 by TenPlus1 --= Teleport Potion mod 0.7 by TenPlus1
-- Create teleport potion or pad, place then right-click to enter coords -- Create teleport potion or pad, place then right-click to enter coords
-- and step onto pad or walk into the blue portal light, portal closes after -- and step onto pad or walk into the blue portal light, portal closes after
...@@ -15,7 +15,7 @@ local check_coordinates = function(str) ...@@ -15,7 +15,7 @@ local check_coordinates = function(str)
end end
-- get coords from string -- get coords from string
local x, y, z = string.match(str, "^(-?%d+),(-?%d+),(-?%d+)") local x, y, z, desc = string.match(str, "^(-?%d+),(-?%d+),(-?%d+),?(.*)$")
-- check coords -- check coords
if x == nil or string.len(x) > 6 if x == nil or string.len(x) > 6
...@@ -37,7 +37,7 @@ local check_coordinates = function(str) ...@@ -37,7 +37,7 @@ local check_coordinates = function(str)
end end
-- return ok coords -- return ok coords
return {x = x, y = y, z = z} return {x = x, y = y, z = z, desc = desc}
end end
-- particle effects -- particle effects
...@@ -210,7 +210,7 @@ minetest.register_node("teleport_potion:pad", { ...@@ -210,7 +210,7 @@ minetest.register_node("teleport_potion:pad", {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
-- text entry formspec -- text entry formspec
meta:set_string("formspec", "field[text;Enter teleport coords (e.g. 200,20,-200);${text}]") meta:set_string("formspec", "field[text;Enter teleport coords (e.g. 200,20,-200,Home);${text}]")
meta:set_string("infotext", "Right-click to enchant teleport location") meta:set_string("infotext", "Right-click to enchant teleport location")
meta:set_string("text", pos.x .. "," .. pos.y .. "," .. pos.z) meta:set_string("text", pos.x .. "," .. pos.y .. "," .. pos.z)
...@@ -241,8 +241,13 @@ minetest.register_node("teleport_potion:pad", { ...@@ -241,8 +241,13 @@ minetest.register_node("teleport_potion:pad", {
meta:set_int("z", coords.z) meta:set_int("z", coords.z)
meta:set_string("text", fields.text) meta:set_string("text", fields.text)
meta:set_string("infotext", "Pad Active (" if coords.desc and coords.desc ~= "" then
.. coords.x .. "," .. coords.y .. "," .. coords.z .. ")")
meta:set_string("infotext", "Teleport to " .. coords.desc)
else
meta:set_string("infotext", "Pad Active ("
.. coords.x .. "," .. coords.y .. "," .. coords.z .. ")")
end
minetest.sound_play("portal_open", { minetest.sound_play("portal_open", {
pos = pos, pos = pos,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment