Add additional documentation.
This commit is contained in:
parent
6f353ebc1e
commit
ab611db99b
@ -1,2 +1,7 @@
|
||||
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.
|
||||
Allows for the creation of Meseportation systems.
|
||||
|
||||
Grants special effects to Mese blocks allowing for teleporters made of gold and Mese. When a player punches a gold block which is next to a Mese block, 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.
|
||||
|
||||
Lines of Mese can be placed on more than one side of a gold block to create diagonal teleporters! However, Mese blocks on opposing sides cancel each other's power.
|
||||
|
||||
If used carefully, complex teleportation networks can be set up allowing for teleporting around the land or for traveling up and down vertical mineshafts quickly.
|
60
init.lua
60
init.lua
@ -1,48 +1,38 @@
|
||||
local on_punch_old = ItemStack("default:goldblock"):get_definition().on_punch -- Added to avoid conflict with other mods
|
||||
local ActionBlockType = "default:goldblock"
|
||||
local NodePowers = {["default:mese"] = 100}
|
||||
|
||||
local on_punch_old = ItemStack(ActionBlockType):get_definition().on_punch -- Added to avoid conflicts with other mods
|
||||
local PunchDebounces = {}
|
||||
|
||||
minetest.override_item("default:goldblock", {
|
||||
on_punch = (function(pos, node, puncher, pointed_thing)
|
||||
if (not PunchDebounces[puncher]) then
|
||||
minetest.override_item(ActionBlockType, {
|
||||
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
|
||||
local function doAction(d, polarity) -- D stands for dimension.
|
||||
local LoopFirst = true
|
||||
local ReadNode = nil
|
||||
while LoopFirst or NodePowers[ReadNode] ~= nil do
|
||||
if LoopFirst then
|
||||
LoopFirst = false
|
||||
else
|
||||
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"]
|
||||
ReadPos[d] = ReadPos[d] + polarity
|
||||
ReadNode = minetest.get_node(ReadPos).name
|
||||
end
|
||||
ReadPos[d] = pos[d]
|
||||
end
|
||||
|
||||
|
||||
doAction("x", 1)
|
||||
doAction("x", -1)
|
||||
doAction("y", 1)
|
||||
doAction("y", -1)
|
||||
doAction("z", 1)
|
||||
doAction("z", -1)
|
||||
|
||||
-- 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
|
||||
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
|
||||
@ -53,5 +43,5 @@ minetest.override_item("default:goldblock", {
|
||||
end
|
||||
|
||||
return on_punch_old(pos, node, puncher, pointed_thing) -- Added to avoid conflict with other mods
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 370 KiB |
Loading…
x
Reference in New Issue
Block a user