Compare commits

...

5 Commits

Author SHA1 Message Date
Milan* eeb912c105 remove potion recipe 2017-09-14 22:29:41 +02:00
Milan* 1a150b3ddb re-addd potion recipe and remove pad recipe 2017-08-03 11:23:16 +02:00
Milan* 5d1c07e195 restrict pads to owner, comment recipe for pads away 2017-03-19 12:49:30 +01:00
tchncs 8c54c845a6 use own texture on sides 2016-10-11 11:24:18 +02:00
TenPlus1 b50b700e61 Added pad facing direction after use 2016-10-03 10:42:37 +01:00
4 changed files with 83 additions and 34 deletions

View File

@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234
Change log:
- 0.8 - Teleport pads now have arrows showing direction player will face after use
- 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.5 - Added throwable potions

116
init.lua
View File

@ -1,5 +1,5 @@
--= Teleport Potion mod 0.7 by TenPlus1
--= Teleport Potion mod 0.8 by TenPlus1
-- 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
@ -193,7 +193,7 @@ minetest.register_node("teleport_potion:potion", {
end
end,
})
--[[
-- teleport potion recipe
minetest.register_craft({
output = "teleport_potion:potion",
@ -203,13 +203,13 @@ minetest.register_craft({
{"", "default:diamond", ""},
},
})
]]
-- teleport pad
minetest.register_node("teleport_potion:pad", {
tiles = {"padd.png"},
drawtype = 'nodebox',
tiles = {"padd.png", "padd_side.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "wallmounted",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = true,
sunlight_propagates = true,
@ -219,26 +219,33 @@ minetest.register_node("teleport_potion:pad", {
light_source = 5,
groups = {snappy = 3},
node_box = {
type = "wallmounted",
wall_top = {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
wall_side = {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
},
selection_box = {type = "wallmounted"},
on_construct = function(pos)
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,
on_construct = function(pos, player)
local meta = minetest.get_meta(pos)
meta:set_string("owner", "")
-- text entry formspec
meta:set_string("formspec", "field[text;" .. S("Enter teleport coords (e.g. 200,20,-200,Home)") .. ";${text}]")
meta:set_string("infotext", S("Right-click to enchant teleport location"))
meta:set_string("text", pos.x .. "," .. pos.y .. "," .. pos.z)
-- set default coords
meta:set_int("x", pos.x)
meta:set_int("y", pos.y)
meta:set_int("z", pos.z)
-- text entry formspec
meta:set_string("formspec", "field[text;" .. S("Enter teleport coords (e.g. 200,20,-200,Home)") .. ";${text}]")
meta:set_string("infotext", S("Right-click to enchant teleport location"))
meta:set_string("text", pos.x .. "," .. pos.y .. "," .. pos.z)
-- set default coords
meta:set_int("x", pos.x)
meta:set_int("y", pos.y)
meta:set_int("z", pos.z)
end,
-- once entered, check coords, if ok then return potion
@ -257,18 +264,19 @@ minetest.register_node("teleport_potion:pad", {
local meta = minetest.get_meta(pos)
meta:set_int("x", coords.x)
meta:set_int("y", coords.y)
meta:set_int("z", coords.z)
meta:set_string("text", fields.text)
if teleport_potion.can_access(pos,sender) then
if coords.desc and coords.desc ~= "" then
meta:set_int("x", coords.x)
meta:set_int("y", coords.y)
meta:set_int("z", coords.z)
meta:set_string("text", fields.text)
meta:set_string("infotext", S("Teleport to @1", coords.desc))
else
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
coords.x, coords.y, coords.z))
end
if coords.desc and coords.desc ~= "" then
meta:set_string("infotext", S("Teleport to @1", coords.desc.. " - graceful owner: "..meta:get_string("owner") or ""))
else
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
coords.x, coords.y, coords.z.. " - graceful owner: ".. meta:get_string("owner")))
end
minetest.sound_play("portal_open", {
pos = pos,
@ -277,12 +285,33 @@ minetest.register_node("teleport_potion:pad", {
})
else
minetest.chat_send_player(name, S("Teleport Pad coordinates failed!"))
minetest.chat_send_player(name, S("Teleport Pad coordinates failed, make sure you own this pad / add valid coordinates."))
end
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local owner = meta:get_string('owner');
if ( owner and owner ~= '' and player:get_player_name() ~= owner ) then
return false
end
return true
end,
})
-- teleport pad recipe
teleport_potion = {}
teleport_potion.can_access = function(pos,player)
local meta = minetest.env:get_meta(pos)
local name = player:get_player_name()
local privs = minetest.get_player_privs(name)
if name == meta:get_string("owner") or privs["server"] then
return true
end
return false
end
--[[ teleport pad recipe
minetest.register_craft({
output = 'teleport_potion:pad',
recipe = {
@ -290,7 +319,7 @@ minetest.register_craft({
{"default:glass", "default:mese", "default:glass"},
{"teleport_potion:potion", "default:glass", "teleport_potion:potion"}
}
})
})]]
-- check portal & pad, teleport any entities on top
minetest.register_abm({
@ -343,6 +372,25 @@ minetest.register_abm({
gain = 1.0,
max_hear_distance = 5
})
-- rotate player to look in pad placement direction
if objs[n]:is_player() then
local rot = node.param2
local yaw = 0
if rot == 0 or rot == 20 then
yaw = 0 -- north
elseif rot == 2 or rot == 22 then
yaw = 3.14 -- south
elseif rot == 1 or rot == 23 then
yaw = 4.71 -- west
elseif rot == 3 or rot == 21 then
yaw = 1.57 -- east
end
objs[n]:set_look_yaw(yaw)
end
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 201 B

BIN
textures/padd_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B