Compare commits
5 Commits
475360b87b
...
eeb912c105
Author | SHA1 | Date |
---|---|---|
|
eeb912c105 | |
|
1a150b3ddb | |
|
5d1c07e195 | |
|
8c54c845a6 | |
|
b50b700e61 |
|
@ -7,6 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234
|
||||||
|
|
||||||
Change log:
|
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.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
|
||||||
|
|
116
init.lua
116
init.lua
|
@ -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
|
-- 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
|
||||||
|
@ -193,7 +193,7 @@ minetest.register_node("teleport_potion:potion", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
--[[
|
||||||
-- teleport potion recipe
|
-- teleport potion recipe
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "teleport_potion:potion",
|
output = "teleport_potion:potion",
|
||||||
|
@ -203,13 +203,13 @@ minetest.register_craft({
|
||||||
{"", "default:diamond", ""},
|
{"", "default:diamond", ""},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
]]
|
||||||
-- teleport pad
|
-- teleport pad
|
||||||
minetest.register_node("teleport_potion:pad", {
|
minetest.register_node("teleport_potion:pad", {
|
||||||
tiles = {"padd.png"},
|
tiles = {"padd.png", "padd_side.png"},
|
||||||
drawtype = 'nodebox',
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "facedir",
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
walkable = true,
|
walkable = true,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
@ -219,26 +219,33 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
light_source = 5,
|
light_source = 5,
|
||||||
groups = {snappy = 3},
|
groups = {snappy = 3},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "wallmounted",
|
type = "fixed",
|
||||||
wall_top = {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
|
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 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},
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
|
||||||
-- text entry formspec
|
-- text entry formspec
|
||||||
meta:set_string("formspec", "field[text;" .. S("Enter teleport coords (e.g. 200,20,-200,Home)") .. ";${text}]")
|
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("infotext", S("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)
|
||||||
|
|
||||||
-- set default coords
|
-- set default coords
|
||||||
meta:set_int("x", pos.x)
|
meta:set_int("x", pos.x)
|
||||||
meta:set_int("y", pos.y)
|
meta:set_int("y", pos.y)
|
||||||
meta:set_int("z", pos.z)
|
meta:set_int("z", pos.z)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- once entered, check coords, if ok then return potion
|
-- 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)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
meta:set_int("x", coords.x)
|
if teleport_potion.can_access(pos,sender) then
|
||||||
meta:set_int("y", coords.y)
|
|
||||||
meta:set_int("z", coords.z)
|
|
||||||
meta:set_string("text", fields.text)
|
|
||||||
|
|
||||||
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))
|
if coords.desc and coords.desc ~= "" then
|
||||||
else
|
meta:set_string("infotext", S("Teleport to @1", coords.desc.. " - graceful owner: "..meta:get_string("owner") or ""))
|
||||||
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
|
else
|
||||||
coords.x, coords.y, coords.z))
|
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
|
||||||
end
|
coords.x, coords.y, coords.z.. " - graceful owner: ".. meta:get_string("owner")))
|
||||||
|
end
|
||||||
|
|
||||||
minetest.sound_play("portal_open", {
|
minetest.sound_play("portal_open", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
|
@ -277,12 +285,33 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
})
|
})
|
||||||
|
|
||||||
else
|
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
|
||||||
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({
|
minetest.register_craft({
|
||||||
output = 'teleport_potion:pad',
|
output = 'teleport_potion:pad',
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -290,7 +319,7 @@ minetest.register_craft({
|
||||||
{"default:glass", "default:mese", "default:glass"},
|
{"default:glass", "default:mese", "default:glass"},
|
||||||
{"teleport_potion:potion", "default:glass", "teleport_potion:potion"}
|
{"teleport_potion:potion", "default:glass", "teleport_potion:potion"}
|
||||||
}
|
}
|
||||||
})
|
})]]
|
||||||
|
|
||||||
-- check portal & pad, teleport any entities on top
|
-- check portal & pad, teleport any entities on top
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -343,6 +372,25 @@ minetest.register_abm({
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
max_hear_distance = 5
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 201 B |
Binary file not shown.
After Width: | Height: | Size: 147 B |
Loading…
Reference in New Issue