mirror of
https://codeberg.org/tenplus1/teleport_potion.git
synced 2025-03-15 06:01:24 +00:00
Teleport pads now have descriptions added
This commit is contained in:
parent
4f88bf11d6
commit
718adac01d
2 changed files with 12 additions and 6 deletions
|
@ -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
|
||||||
|
|
17
init.lua
17
init.lua
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
--= 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)
|
||||||
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)
|
||||||
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", {
|
||||||
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", {
|
||||||
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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue