code tide, rename textures
105
init.lua
|
@ -19,10 +19,12 @@ local dist = tonumber(minetest.settings:get("map_generation_limit") or 31000)
|
||||||
|
|
||||||
-- creative check
|
-- creative check
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
|
|
||||||
local function is_creative(name)
|
local function is_creative(name)
|
||||||
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- make sure coordinates are valid
|
||||||
local check_coordinates = function(str)
|
local check_coordinates = function(str)
|
||||||
|
|
||||||
if not str or str == "" then
|
if not str or str == "" then
|
||||||
|
@ -55,9 +57,9 @@ local check_coordinates = function(str)
|
||||||
return {x = x, y = y, z = z}
|
return {x = x, y = y, z = z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- particle effects
|
-- particle effects
|
||||||
local function tp_effect(pos)
|
local function tp_effect(pos)
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 20,
|
amount = 20,
|
||||||
time = 0.25,
|
time = 0.25,
|
||||||
|
@ -71,7 +73,7 @@ local function tp_effect(pos)
|
||||||
maxexptime = 1,
|
maxexptime = 1,
|
||||||
minsize = 0.5,
|
minsize = 0.5,
|
||||||
maxsize = 1.5,
|
maxsize = 1.5,
|
||||||
texture = "particle.png",
|
texture = "teleport_potion_particle.png",
|
||||||
glow = 15,
|
glow = 15,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -79,22 +81,21 @@ end
|
||||||
local teleport_destinations = {}
|
local teleport_destinations = {}
|
||||||
|
|
||||||
local function set_teleport_destination(playername, dest)
|
local function set_teleport_destination(playername, dest)
|
||||||
|
|
||||||
teleport_destinations[playername] = dest
|
teleport_destinations[playername] = dest
|
||||||
|
|
||||||
tp_effect(dest)
|
tp_effect(dest)
|
||||||
|
|
||||||
minetest.sound_play("portal_open", {
|
minetest.sound_play("portal_open", {
|
||||||
pos = dest,
|
pos = dest, gain = 1.0, max_hear_distance = 10}, true)
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 10
|
|
||||||
}, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
--- Teleport portal
|
--- Teleport portal
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
minetest.register_node("teleport_potion:portal", {
|
minetest.register_node("teleport_potion:portal", {
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
tiles = {
|
tiles = {
|
||||||
{name="portal.png",
|
{
|
||||||
|
name = "teleport_potion_portal.png",
|
||||||
animation = {
|
animation = {
|
||||||
type = "vertical_frames",
|
type = "vertical_frames",
|
||||||
aspect_w = 16,
|
aspect_w = 16,
|
||||||
|
@ -122,18 +123,14 @@ minetest.register_node("teleport_potion:portal", {
|
||||||
on_timer = function(pos)
|
on_timer = function(pos)
|
||||||
|
|
||||||
minetest.sound_play("portal_close", {
|
minetest.sound_play("portal_close", {
|
||||||
pos = pos,
|
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 10
|
|
||||||
}, true)
|
|
||||||
|
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end,
|
end,
|
||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
drop = {},
|
drop = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Throwable potion
|
-- Throwable potion
|
||||||
local function throw_potion(itemstack, player)
|
local function throw_potion(itemstack, player)
|
||||||
|
|
||||||
|
@ -164,21 +161,23 @@ local function throw_potion(itemstack, player)
|
||||||
obj:get_luaentity().player = player
|
obj:get_luaentity().player = player
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- potion entity
|
||||||
local potion_entity = {
|
local potion_entity = {
|
||||||
physical = true,
|
physical = true,
|
||||||
visual = "sprite",
|
visual = "sprite",
|
||||||
visual_size = {x = 1.0, y = 1.0},
|
visual_size = {x = 1.0, y = 1.0},
|
||||||
textures = {"potion.png"},
|
textures = {"teleport_potion_potion.png"},
|
||||||
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
||||||
lastpos = {},
|
lastpos = {},
|
||||||
player = "",
|
player = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
potion_entity.on_step = function(self, dtime)
|
potion_entity.on_step = function(self, dtime)
|
||||||
|
|
||||||
if not self.player then
|
if not self.player then
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -221,58 +220,63 @@ end
|
||||||
|
|
||||||
minetest.register_entity("teleport_potion:potion_entity", potion_entity)
|
minetest.register_entity("teleport_potion:potion_entity", potion_entity)
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
--- Teleport potion
|
--- Teleport potion
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
minetest.register_node("teleport_potion:potion", {
|
minetest.register_node("teleport_potion:potion", {
|
||||||
tiles = {"potion.png"},
|
tiles = {"teleport_potion_potion.png"},
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
description = S("Teleport Potion (use to set destination; place to open portal)"),
|
description = S("Teleport Potion (use to set destination; place to open portal)"),
|
||||||
inventory_image = "potion.png",
|
inventory_image = "teleport_potion_potion.png",
|
||||||
wield_image = "potion.png",
|
wield_image = "teleport_potion_potion.png",
|
||||||
groups = {dig_immediate = 3, vessel = 1},
|
groups = {dig_immediate = 3, vessel = 1},
|
||||||
selection_box = {type = "wallmounted"},
|
selection_box = {type = "wallmounted"},
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
set_teleport_destination(user:get_player_name(), pointed_thing.above)
|
set_teleport_destination(user:get_player_name(), pointed_thing.above)
|
||||||
else
|
else
|
||||||
throw_potion(itemstack, user)
|
throw_potion(itemstack, user)
|
||||||
|
|
||||||
if not is_creative(user:get_player_name()) then
|
if not is_creative(user:get_player_name()) then
|
||||||
|
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
|
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
local dest = teleport_destinations[name]
|
local dest = teleport_destinations[name]
|
||||||
|
|
||||||
if dest then
|
if dest then
|
||||||
|
|
||||||
minetest.set_node(pos, {name = "teleport_potion:portal"})
|
minetest.set_node(pos, {name = "teleport_potion:portal"})
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
-- Set portal destination
|
-- Set portal destination
|
||||||
meta:set_int("x", dest.x)
|
meta:set_int("x", dest.x)
|
||||||
meta:set_int("y", dest.y)
|
meta:set_int("y", dest.y)
|
||||||
meta:set_int("z", dest.z)
|
meta:set_int("z", dest.z)
|
||||||
|
|
||||||
-- Portal open effect and sound
|
-- Portal open effect and sound
|
||||||
tp_effect(pos)
|
tp_effect(pos)
|
||||||
|
|
||||||
minetest.sound_play("portal_open", {
|
minetest.sound_play("portal_open", {
|
||||||
pos = pos,
|
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 10
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Potion failed!"))
|
minetest.chat_send_player(name, S("Potion failed!"))
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
minetest.add_item(pos, "teleport_potion:potion")
|
minetest.add_item(pos, "teleport_potion:potion")
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- teleport potion recipe
|
-- teleport potion recipe
|
||||||
|
@ -296,13 +300,11 @@ minetest.register_craft({
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
--- Teleport pad
|
--- Teleport pad
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
local teleport_formspec_context = {}
|
local teleport_formspec_context = {}
|
||||||
|
|
||||||
minetest.register_node("teleport_potion:pad", {
|
minetest.register_node("teleport_potion:pad", {
|
||||||
tiles = {"padd.png", "padd.png^[transformFY"},
|
tiles = {"teleport_potion_pad.png", "teleport_potion_pad.png^[transformFY"},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -310,8 +312,8 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
walkable = true,
|
walkable = true,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
description = S("Teleport Pad (use to set destination; place to open portal)"),
|
description = S("Teleport Pad (use to set destination; place to open portal)"),
|
||||||
inventory_image = "padd.png",
|
inventory_image = "teleport_potion_pad.png",
|
||||||
wield_image = "padd.png",
|
wield_image = "teleport_potion_pad.png",
|
||||||
light_source = 5,
|
light_source = 5,
|
||||||
groups = {snappy = 3},
|
groups = {snappy = 3},
|
||||||
node_box = {
|
node_box = {
|
||||||
|
@ -325,6 +327,7 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
|
|
||||||
-- Save pointed nodes coordinates as destination for further portals
|
-- Save pointed nodes coordinates as destination for further portals
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
set_teleport_destination(user:get_player_name(), pointed_thing.above)
|
set_teleport_destination(user:get_player_name(), pointed_thing.above)
|
||||||
end
|
end
|
||||||
|
@ -332,12 +335,15 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
|
|
||||||
-- Initialize teleport to saved location or the current position
|
-- Initialize teleport to saved location or the current position
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
local dest = teleport_destinations[name]
|
local dest = teleport_destinations[name]
|
||||||
|
|
||||||
if not dest then
|
if not dest then
|
||||||
dest = pos
|
dest = pos
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set coords
|
-- Set coords
|
||||||
meta:set_int("x", dest.x)
|
meta:set_int("x", dest.x)
|
||||||
meta:set_int("y", dest.y)
|
meta:set_int("y", dest.y)
|
||||||
|
@ -347,18 +353,18 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
dest.x, dest.y, dest.z))
|
dest.x, dest.y, dest.z))
|
||||||
|
|
||||||
minetest.sound_play("portal_open", {
|
minetest.sound_play("portal_open", {
|
||||||
pos = pos,
|
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 10
|
|
||||||
}, true)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- Show formspec depending on the players privileges.
|
-- Show formspec depending on the players privileges.
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
|
|
||||||
if minetest.is_protected(pos, name) then
|
if minetest.is_protected(pos, name) then
|
||||||
|
|
||||||
minetest.record_protection_violation(pos, name)
|
minetest.record_protection_violation(pos, name)
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -370,8 +376,10 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
}
|
}
|
||||||
local coords = coords.x .. "," .. coords.y .. "," .. coords.z
|
local coords = coords.x .. "," .. coords.y .. "," .. coords.z
|
||||||
local desc = meta:get_string("desc")
|
local desc = meta:get_string("desc")
|
||||||
|
|
||||||
formspec = "field[desc;" .. S("Description") .. ";"
|
formspec = "field[desc;" .. S("Description") .. ";"
|
||||||
.. minetest.formspec_escape(desc) .. "]"
|
.. minetest.formspec_escape(desc) .. "]"
|
||||||
|
|
||||||
-- Only allow privileged players to change coordinates
|
-- Only allow privileged players to change coordinates
|
||||||
if minetest.check_player_privs(name, "teleport") then
|
if minetest.check_player_privs(name, "teleport") then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
|
@ -383,23 +391,32 @@ minetest.register_node("teleport_potion:pad", {
|
||||||
coords = coords,
|
coords = coords,
|
||||||
desc = desc,
|
desc = desc,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.show_formspec(name, "teleport_potion:set_destination", formspec)
|
minetest.show_formspec(name, "teleport_potion:set_destination", formspec)
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Check and set coordinates
|
-- Check and set coordinates
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
if formname ~= "teleport_potion:set_destination" then
|
if formname ~= "teleport_potion:set_destination" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local context = teleport_formspec_context[name]
|
local context = teleport_formspec_context[name]
|
||||||
|
|
||||||
if not context then return false end
|
if not context then return false end
|
||||||
|
|
||||||
teleport_formspec_context[name] = nil
|
teleport_formspec_context[name] = nil
|
||||||
|
|
||||||
local meta = minetest.get_meta(context.pos)
|
local meta = minetest.get_meta(context.pos)
|
||||||
|
|
||||||
-- Coordinates were changed
|
-- Coordinates were changed
|
||||||
if fields.coords and fields.coords ~= context.coords then
|
if fields.coords and fields.coords ~= context.coords then
|
||||||
|
|
||||||
local coords = check_coordinates(fields.coords)
|
local coords = check_coordinates(fields.coords)
|
||||||
|
|
||||||
if coords then
|
if coords then
|
||||||
meta:set_int("x", coords.x)
|
meta:set_int("x", coords.x)
|
||||||
meta:set_int("y", coords.y)
|
meta:set_int("y", coords.y)
|
||||||
|
@ -408,15 +425,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
minetest.chat_send_player(name, S("Teleport Pad coordinates failed!"))
|
minetest.chat_send_player(name, S("Teleport Pad coordinates failed!"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update infotext
|
-- Update infotext
|
||||||
if fields.desc and fields.desc ~= "" then
|
if fields.desc and fields.desc ~= "" then
|
||||||
meta:set_string("desc", fields.desc)
|
meta:set_string("desc", fields.desc)
|
||||||
meta:set_string("infotext", S("Teleport to @1", fields.desc))
|
meta:set_string("infotext", S("Teleport to @1", fields.desc))
|
||||||
else
|
else
|
||||||
local coords = minetest.string_to_pos("(" .. context.coords .. ")")
|
local coords = minetest.string_to_pos("(" .. context.coords .. ")")
|
||||||
|
|
||||||
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
|
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
|
||||||
coords.x, coords.y, coords.z))
|
coords.x, coords.y, coords.z))
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -514,15 +534,14 @@ minetest.register_abm({
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- add lucky blocks
|
-- lucky blocks
|
||||||
|
|
||||||
-- Teleport Potion mod
|
|
||||||
if minetest.get_modpath("lucky_block") then
|
if minetest.get_modpath("lucky_block") then
|
||||||
|
|
||||||
lucky_block:add_blocks({
|
lucky_block:add_blocks({
|
||||||
{"dro", {"teleport_potion:potion"}, 2},
|
{"dro", {"teleport_potion:potion"}, 2},
|
||||||
{"tel"},
|
{"tel"},
|
||||||
{"dro", {"teleport_potion:pad"}, 1},
|
{"dro", {"teleport_potion:pad"}, 1},
|
||||||
{"lig"},
|
{"lig"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 171 B |