mirror of
https://codeberg.org/tenplus1/teleport_potion.git
synced 2025-05-19 10:43:16 -04:00
change minetest. to core.
This commit is contained in:
parent
fcc2bf8be3
commit
355be56a2c
1 changed files with 46 additions and 46 deletions
92
init.lua
92
init.lua
|
@ -8,23 +8,23 @@
|
|||
|
||||
-- translation and settings
|
||||
|
||||
local S = minetest.get_translator("teleport_potion")
|
||||
local mcl = minetest.get_modpath("mcl_core")
|
||||
local dist = tonumber(minetest.settings:get("map_generation_limit") or 31000)
|
||||
local S = core.get_translator("teleport_potion")
|
||||
local mcl = core.get_modpath("mcl_core")
|
||||
local dist = tonumber(core.settings:get("map_generation_limit") or 31000)
|
||||
|
||||
-- creative check
|
||||
|
||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||
local creative_mode_cache = core.settings:get_bool("creative_mode")
|
||||
|
||||
local function is_creative(name)
|
||||
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
||||
return creative_mode_cache or core.check_player_privs(name, {creative = true})
|
||||
end
|
||||
|
||||
-- choose texture for teleport pad
|
||||
|
||||
local teleport_pad_texture = "teleport_potion_pad.png"
|
||||
|
||||
if minetest.settings:get_bool("teleport_potion_use_old_texture") == true then
|
||||
if core.settings:get_bool("teleport_potion_use_old_texture") == true then
|
||||
teleport_pad_texture = "teleport_potion_pad_v1.png"
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ local function effect(pos, amount, texture, min_size, max_size, radius, gravity,
|
|||
radius = radius or 2
|
||||
gravity = gravity or -10
|
||||
|
||||
minetest.add_particlespawner({
|
||||
core.add_particlespawner({
|
||||
amount = amount,
|
||||
time = 0.25,
|
||||
minpos = pos,
|
||||
|
@ -91,13 +91,13 @@ local function set_teleport_destination(playername, dest)
|
|||
|
||||
effect(dest, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
|
||||
|
||||
minetest.sound_play("portal_open", {
|
||||
core.sound_play("portal_open", {
|
||||
pos = dest, gain = 1.0, max_hear_distance = 10}, true)
|
||||
end
|
||||
|
||||
--- Teleport portal
|
||||
|
||||
minetest.register_node("teleport_potion:portal", {
|
||||
core.register_node("teleport_potion:portal", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {
|
||||
{
|
||||
|
@ -120,18 +120,18 @@ minetest.register_node("teleport_potion:portal", {
|
|||
|
||||
-- start timer when portal appears
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(10)
|
||||
core.get_node_timer(pos):start(10)
|
||||
end,
|
||||
|
||||
-- remove portal after 10 seconds
|
||||
on_timer = function(pos)
|
||||
|
||||
minetest.sound_play("portal_close", {
|
||||
core.sound_play("portal_close", {
|
||||
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||
|
||||
effect(pos, 25, "teleport_potion_particle.png", 2, 2, 1, -10, 15)
|
||||
|
||||
minetest.remove_node(pos)
|
||||
core.remove_node(pos)
|
||||
end,
|
||||
|
||||
on_blast = function() end,
|
||||
|
@ -143,7 +143,7 @@ local function throw_potion(itemstack, player)
|
|||
|
||||
local playerpos = player:get_pos()
|
||||
|
||||
local obj = minetest.add_entity({
|
||||
local obj = core.add_entity({
|
||||
x = playerpos.x,
|
||||
y = playerpos.y + 1.5,
|
||||
z = playerpos.z
|
||||
|
@ -199,7 +199,7 @@ potion_entity.on_step = function(self, dtime)
|
|||
local oldpos = self.player:get_pos()
|
||||
|
||||
-- play sound and disappearing particle effect at current position
|
||||
minetest.sound_play("portal_close", {
|
||||
core.sound_play("portal_close", {
|
||||
pos = oldpos, gain = 1.0, max_hear_distance = 5}, true)
|
||||
|
||||
oldpos.y = oldpos.y + 1
|
||||
|
@ -209,7 +209,7 @@ potion_entity.on_step = function(self, dtime)
|
|||
-- teleport to new position, play sound and show appear effect
|
||||
self.player:set_pos(self.lastpos)
|
||||
|
||||
minetest.sound_play("portal_close", {
|
||||
core.sound_play("portal_close", {
|
||||
pos = self.lastpos, gain = 1.0, max_hear_distance = 5}, true)
|
||||
|
||||
effect(self.lastpos, 20, "teleport_potion_particle.png", 2, 2, 1, 10, 15)
|
||||
|
@ -225,11 +225,11 @@ potion_entity.on_step = function(self, dtime)
|
|||
self.lastpos = pos
|
||||
end
|
||||
|
||||
minetest.register_entity("teleport_potion:potion_entity", potion_entity)
|
||||
core.register_entity("teleport_potion:potion_entity", potion_entity)
|
||||
|
||||
--- Teleport potion
|
||||
|
||||
minetest.register_node("teleport_potion:potion", {
|
||||
core.register_node("teleport_potion:potion", {
|
||||
tiles = {"teleport_potion_potion.png"},
|
||||
drawtype = "signlike",
|
||||
paramtype = "light",
|
||||
|
@ -265,9 +265,9 @@ minetest.register_node("teleport_potion:potion", {
|
|||
|
||||
if dest then
|
||||
|
||||
minetest.set_node(pos, {name = "teleport_potion:portal"})
|
||||
core.set_node(pos, {name = "teleport_potion:portal"})
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
|
||||
-- Set portal destination
|
||||
meta:set_int("x", dest.x)
|
||||
|
@ -277,12 +277,12 @@ minetest.register_node("teleport_potion:potion", {
|
|||
-- Portal open effect and sound
|
||||
effect(pos, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
|
||||
|
||||
minetest.sound_play("portal_open", {
|
||||
core.sound_play("portal_open", {
|
||||
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||
else
|
||||
minetest.chat_send_player(name, S("Potion failed!"))
|
||||
minetest.remove_node(pos)
|
||||
minetest.add_item(pos, "teleport_potion:potion")
|
||||
core.chat_send_player(name, S("Potion failed!"))
|
||||
core.remove_node(pos)
|
||||
core.add_item(pos, "teleport_potion:potion")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -291,7 +291,7 @@ minetest.register_node("teleport_potion:potion", {
|
|||
|
||||
if mcl then
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "teleport_potion:potion",
|
||||
recipe = {
|
||||
{"", "mcl_core:diamond", ""},
|
||||
|
@ -300,7 +300,7 @@ if mcl then
|
|||
}
|
||||
})
|
||||
else
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "teleport_potion:potion",
|
||||
recipe = {
|
||||
{"", "default:diamond", ""},
|
||||
|
@ -314,7 +314,7 @@ end
|
|||
|
||||
local teleport_formspec_context = {}
|
||||
|
||||
minetest.register_node("teleport_potion:pad", {
|
||||
core.register_node("teleport_potion:pad", {
|
||||
tiles = {teleport_pad_texture, teleport_pad_texture .. "^[transformFY"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
|
@ -345,7 +345,7 @@ minetest.register_node("teleport_potion:pad", {
|
|||
-- Initialize teleport to saved location or the current position
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local name = placer:get_player_name()
|
||||
local dest = teleport_destinations[name]
|
||||
|
||||
|
@ -360,7 +360,7 @@ minetest.register_node("teleport_potion:pad", {
|
|||
|
||||
effect(pos, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
|
||||
|
||||
minetest.sound_play("portal_open", {
|
||||
core.sound_play("portal_open", {
|
||||
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
||||
end,
|
||||
|
||||
|
@ -369,35 +369,35 @@ minetest.register_node("teleport_potion:pad", {
|
|||
|
||||
local name = clicker:get_player_name()
|
||||
|
||||
if minetest.is_protected(pos, name) then
|
||||
if core.is_protected(pos, name) then
|
||||
|
||||
minetest.record_protection_violation(pos, name)
|
||||
core.record_protection_violation(pos, name)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local coords = meta:get_int("x") .. ","
|
||||
.. meta:get_int("y") .. "," .. meta:get_int("z")
|
||||
local desc = meta:get_string("desc")
|
||||
local formspec = "field[desc;" .. S("Description") .. ";"
|
||||
.. minetest.formspec_escape(desc) .. "]"
|
||||
.. core.formspec_escape(desc) .. "]"
|
||||
|
||||
-- Only allow privileged players to change coordinates
|
||||
if minetest.check_player_privs(name, "teleport") then
|
||||
if core.check_player_privs(name, "teleport") then
|
||||
formspec = formspec ..
|
||||
"field[coords;" .. S("Teleport coordinates") .. ";" .. coords .. "]"
|
||||
end
|
||||
|
||||
teleport_formspec_context[name] = {pos = pos, coords = coords, desc = desc}
|
||||
|
||||
minetest.show_formspec(name, "teleport_potion:set_destination", formspec)
|
||||
core.show_formspec(name, "teleport_potion:set_destination", formspec)
|
||||
end
|
||||
})
|
||||
|
||||
-- Check and set coordinates
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname ~= "teleport_potion:set_destination" then return false end
|
||||
|
||||
|
@ -410,7 +410,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
if fields.control == nil and fields.desc == nil then return false end
|
||||
|
||||
local meta = minetest.get_meta(context.pos)
|
||||
local meta = core.get_meta(context.pos)
|
||||
|
||||
-- Coordinates were changed
|
||||
if fields.coords and fields.coords ~= context.coords then
|
||||
|
@ -422,7 +422,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
meta:set_int("y", coords.y)
|
||||
meta:set_int("z", coords.z)
|
||||
else
|
||||
minetest.chat_send_player(name, S("Teleport Pad coordinates failed!"))
|
||||
core.chat_send_player(name, S("Teleport Pad coordinates failed!"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -434,7 +434,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
if fields.desc and fields.desc ~= "" then
|
||||
meta:set_string("infotext", S("Teleport to @1", fields.desc))
|
||||
else
|
||||
local coords = minetest.string_to_pos("(" .. context.coords .. ")")
|
||||
local coords = core.string_to_pos("(" .. context.coords .. ")")
|
||||
|
||||
meta:set_string("infotext", S("Pad Active (@1,@2,@3)",
|
||||
coords.x, coords.y, coords.z))
|
||||
|
@ -447,7 +447,7 @@ end)
|
|||
|
||||
if mcl then
|
||||
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "teleport_potion:pad",
|
||||
recipe = {
|
||||
{"teleport_potion:potion", "mcl_core:glass", "teleport_potion:potion"},
|
||||
|
@ -456,7 +456,7 @@ if mcl then
|
|||
}
|
||||
})
|
||||
else
|
||||
minetest.register_craft({
|
||||
core.register_craft({
|
||||
output = "teleport_potion:pad",
|
||||
recipe = {
|
||||
{"teleport_potion:potion", "default:glass", "teleport_potion:potion"},
|
||||
|
@ -468,7 +468,7 @@ end
|
|||
|
||||
-- check portal & pad, teleport any entities on top
|
||||
|
||||
minetest.register_abm({
|
||||
core.register_abm({
|
||||
label = "Potion/Pad teleportation",
|
||||
nodenames = {"teleport_potion:portal", "teleport_potion:pad"},
|
||||
interval = 2,
|
||||
|
@ -478,12 +478,12 @@ minetest.register_abm({
|
|||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
-- check objects inside pad/portal
|
||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||
local objs = core.get_objects_inside_radius(pos, 1)
|
||||
|
||||
if #objs == 0 then return end
|
||||
|
||||
-- get coords from pad/portal
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
|
||||
if not meta then return end -- errorcheck
|
||||
|
||||
|
@ -499,7 +499,7 @@ minetest.register_abm({
|
|||
if objs[n]:is_player() and not objs[n]:get_attach() then
|
||||
|
||||
-- play sound on portal end
|
||||
minetest.sound_play("portal_close", {
|
||||
core.sound_play("portal_close", {
|
||||
pos = pos, gain = 1.0, max_hear_distance = 5}, true)
|
||||
|
||||
pos.y = pos.y + 1
|
||||
|
@ -514,7 +514,7 @@ minetest.register_abm({
|
|||
effect(target_coords, 20, "teleport_potion_particle.png", 2, 2, 1, 10, 15)
|
||||
|
||||
-- play sound on destination end
|
||||
minetest.sound_play("portal_close", {
|
||||
core.sound_play("portal_close", {
|
||||
pos = target_coords, gain = 1.0, max_hear_distance = 5}, true)
|
||||
|
||||
-- rotate player to look in pad placement direction
|
||||
|
@ -535,7 +535,7 @@ minetest.register_abm({
|
|||
|
||||
-- lucky blocks
|
||||
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
if core.get_modpath("lucky_block") then
|
||||
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"teleport_potion:potion"}, 2},
|
||||
|
|
Loading…
Add table
Reference in a new issue