Initial upload

This commit is contained in:
ForbiddenJ 2017-03-01 19:02:15 -06:00 committed by GitHub
parent ed81c028e9
commit b526b95573
4 changed files with 71 additions and 0 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# Meseport
This mod allows you to teleport by means of Mese and Gold structures.
You punch a gold block that's next to Mese to teleport 100 meters in the
direction that the Mese is located relative to the gold block. Each
additional Mese added in a straight line adds an additional 100 meters.
You can also add Mese to multiple sides in such a way to go in diagonal
directions! However, Mese on opposing sides cancel each other. Thanks to
oscar14 for the Gold-Mese-Transport idea!
### License: Unlicense

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default

2
description.txt Normal file
View File

@ -0,0 +1,2 @@
Meseportation system.
The properties of Mese allows for teleportation systems made of gold and Mese. When a player punches a gold block which is next to Mese, he/she is teleported 100 blocks in the direction of the Mese block relative to the gold block. More Mese placed in a line adds to the transport distance. You can also place lines of mese on more than one side of the gold block to create diagonal transports! However, Mese on opposing sides cancel each other.

57
init.lua Normal file
View File

@ -0,0 +1,57 @@
local on_punch_old = ItemStack("default:goldblock"):get_definition().on_punch -- Added to avoid conflict with other mods
local NodePowers = {["default:mese"] = 100}
local PunchDebounces = {}
minetest.override_item("default:goldblock", {
on_punch = (function(pos, node, puncher, pointed_thing)
if (not PunchDebounces[puncher]) then
local direction = {x = 0, y = 0, z = 0}
local ReadPos = {x = pos.x, y = pos.y, z = pos.z}
for d,v in pairs(direction) do -- D stands for dimension.
-- Go positive
local LoopFirst, ReadNode
LoopFirst = true
ReadNode = nil
while (LoopFirst or NodePowers[ReadNode] ~= nil) do
if not LoopFirst then
direction[d] = direction[d] + NodePowers[ReadNode]
else
LoopFirst = false
end
ReadPos[d] = ReadPos[d] + 1
ReadNode = minetest.get_node(ReadPos)["name"]
end
ReadPos[d] = pos[d]
-- Go negative
LoopFirst = true
ReadNode = nil
while (LoopFirst or NodePowers[ReadNode] ~= nil) do
if not LoopFirst then
direction[d] = direction[d] - NodePowers[ReadNode]
else
LoopFirst = false
end
ReadPos[d] = ReadPos[d] - 1
ReadNode = minetest.get_node(ReadPos)["name"]
end
ReadPos[d] = pos[d]
end
-- Teleport the player
-- Condition added to avoid jumpiness after punching unpowered gold.
if (direction.x ~= 0 or direction.y ~= 0 or direction.z ~= 0) then
local puncherPos = puncher:getpos()
puncher:setpos({x = puncherPos.x + direction.x, y = puncherPos.y + direction.y, z = puncherPos.z + direction.z})
PunchDebounces[puncher] = true
minetest.after(0.5, function(...)
PunchDebounces[puncher] = nil
end)
end
end
return on_punch_old(pos, node, puncher, pointed_thing) -- Added to avoid conflict with other mods
end)
})