tidy code

This commit is contained in:
tenplus1 2024-07-28 10:32:30 +01:00
parent 9e89d3918d
commit 92c883ba75
2 changed files with 38 additions and 45 deletions

View file

@ -1,7 +1,7 @@
--= Teleport Potion mod by TenPlus1 --= Teleport Potion mod by TenPlus1
-- Craft teleport potion or pad, use to bookmark location, place to open -- Craft teleport potion or pad, use on node to bookmark location, place to open
-- portal or place pad, portals show a blue flame that you can walk into -- portal or place pad, portals show a blue flame that you can walk into
-- before it closes (10 seconds), potions can also be thrown for local teleport. -- before it closes (10 seconds), potions can also be thrown for local teleport.
@ -289,23 +289,24 @@ minetest.register_node("teleport_potion:potion", {
-- teleport potion recipe -- teleport potion recipe
if mcl then if mcl then
minetest.register_craft({
output = "teleport_potion:potion", minetest.register_craft({
recipe = { output = "teleport_potion:potion",
{"", "mcl_core:diamond", ""}, recipe = {
{"mcl_core:diamond", "mcl_potions:glass_bottle", "mcl_core:diamond"}, {"", "mcl_core:diamond", ""},
{"", "mcl_core:diamond", ""} {"mcl_core:diamond", "mcl_potions:glass_bottle", "mcl_core:diamond"},
} {"", "mcl_core:diamond", ""}
}) }
})
else else
minetest.register_craft({ minetest.register_craft({
output = "teleport_potion:potion", output = "teleport_potion:potion",
recipe = { recipe = {
{"", "default:diamond", ""}, {"", "default:diamond", ""},
{"default:diamond", "vessels:glass_bottle", "default:diamond"}, {"default:diamond", "vessels:glass_bottle", "default:diamond"},
{"", "default:diamond", ""} {"", "default:diamond", ""}
} }
}) })
end end
--- Teleport pad --- Teleport pad
@ -357,8 +358,7 @@ minetest.register_node("teleport_potion:pad", {
meta:set_int("y", dest.y) meta:set_int("y", dest.y)
meta:set_int("z", dest.z) meta:set_int("z", dest.z)
meta:set_string("infotext", S("Pad Active (@1,@2,@3)", meta:set_string("infotext", S("Pad Active (@1,@2,@3)", dest.x, dest.y, dest.z))
dest.x, dest.y, dest.z))
effect(pos, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15) effect(pos, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
@ -453,23 +453,24 @@ end)
-- teleport pad recipe -- teleport pad recipe
if mcl then if mcl then
minetest.register_craft({
output = "teleport_potion:pad", minetest.register_craft({
recipe = { output = "teleport_potion:pad",
{"teleport_potion:potion", "mcl_core:glass", "teleport_potion:potion"}, recipe = {
{"mcl_core:glass", "mesecons:redstone", "mcl_core:glass"}, {"teleport_potion:potion", "mcl_core:glass", "teleport_potion:potion"},
{"teleport_potion:potion", "mcl_core:glass", "teleport_potion:potion"} {"mcl_core:glass", "mesecons:redstone", "mcl_core:glass"},
} {"teleport_potion:potion", "mcl_core:glass", "teleport_potion:potion"}
}) }
})
else else
minetest.register_craft({ minetest.register_craft({
output = "teleport_potion:pad", output = "teleport_potion:pad",
recipe = { recipe = {
{"teleport_potion:potion", "default:glass", "teleport_potion:potion"}, {"teleport_potion:potion", "default:glass", "teleport_potion:potion"},
{"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"}
} }
}) })
end end
-- check portal & pad, teleport any entities on top -- check portal & pad, teleport any entities on top
@ -506,11 +507,7 @@ minetest.register_abm({
-- play sound on portal end -- play sound on portal end
minetest.sound_play("portal_close", { minetest.sound_play("portal_close", {
pos = pos, pos = pos, gain = 1.0, max_hear_distance = 5}, true)
gain = 1.0,
max_hear_distance = 5
}, true)
pos.y = pos.y + 1 pos.y = pos.y + 1
@ -525,10 +522,7 @@ minetest.register_abm({
-- play sound on destination end -- play sound on destination end
minetest.sound_play("portal_close", { minetest.sound_play("portal_close", {
pos = target_coords, pos = target_coords, gain = 1.0, max_hear_distance = 5}, true)
gain = 1.0,
max_hear_distance = 5
}, true)
-- rotate player to look in pad placement direction -- rotate player to look in pad placement direction
local rot = node.param2 local rot = node.param2

View file

@ -1,5 +1,4 @@
name = teleport_potion name = teleport_potion
description = Adds craftable teleport potions (throwable) and teleport pads. description = Adds craftable teleport potions (throwable) and teleport pads.
depends =
optional_depends = default, lucky_block, mcl_core optional_depends = default, lucky_block, mcl_core
min_minetest_version = 5.0 min_minetest_version = 5.0