add more API options, add ability to dig actionblock by sneak-punching
This commit is contained in:
parent
d960bfb04e
commit
3547d1184a
15
README.md
15
README.md
@ -7,8 +7,9 @@ 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!
|
||||
directions! However, Mese on opposing sides cancel each other.
|
||||
|
||||
Sneak-punching the gold block will allow it to be dug normally.
|
||||
|
||||
If Mineclone2 is installed, this mod will instead use gold blocks and Redstone blocks for teleportation.
|
||||
|
||||
@ -18,10 +19,18 @@ If neither of these mods are is not installed, another mod will need to use mese
|
||||
|
||||
``meseport.register_actionblock(node_name)`` - A method that sets a particular node type to trigger a meseport teleport when punched. When the default mod is installed it will automatically be called with ``meseport.register_actionblock("default:goldblock")``.
|
||||
|
||||
``meseport.nodepowers`` - A table that determines how far an adjacent node of a particular type will send the puncher. For example, when the default mod is installed this table will be:
|
||||
``meseport.unregister_actionblock(node_name)`` - The opposite of the above, unregisters a particular node type and restores its old behaviour.
|
||||
|
||||
``meseport.register_nodepower(node_name, power_level)`` - Determines how far an adjacent node of a particular type will send the puncher. Setting a power_level of ``nil`` or ``false`` will disable this node's use with this mod. Setting it to 0 means it can still be part of the chain of nodes that determine the actionblock's teleport range but won't contribute to it.
|
||||
|
||||
``meseport.nodepowers`` - The table storing registered nodepowers. For example, when the default mod is installed this table will be:
|
||||
|
||||
{
|
||||
["default:mese"] = 100
|
||||
}
|
||||
|
||||
Use ``meseport.register_nodepower`` to modify the values here.
|
||||
|
||||
### License: CC0
|
||||
|
||||
Thanks to oscar14 for the Gold-Mese-Transport idea!
|
34
init.lua
34
init.lua
@ -7,6 +7,17 @@ local Polarities = {-1, 1}
|
||||
meseport.nodepowers = {}
|
||||
local NodePowers = meseport.nodepowers
|
||||
|
||||
meseport.register_nodepower = function(node_name, power_level)
|
||||
assert(minetest.registered_nodes[node_name] ~= nil)
|
||||
|
||||
if power_level == nil or power_level == false then
|
||||
meseport.nodepowers[node_name] = nil
|
||||
return
|
||||
end
|
||||
assert(type(power_level) == "number")
|
||||
meseport.nodepowers[node_name] = power_level
|
||||
end
|
||||
|
||||
meseport.register_actionblock = function(ActionBlockType)
|
||||
local action_block_def = minetest.registered_nodes[ActionBlockType]
|
||||
assert(action_block_def ~= nil)
|
||||
@ -14,7 +25,7 @@ meseport.register_actionblock = function(ActionBlockType)
|
||||
|
||||
minetest.override_item(ActionBlockType, {
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
if not PunchDebounces[puncher] then
|
||||
if not PunchDebounces[puncher] and not puncher:get_player_control()["sneak"] then
|
||||
local power = {x = 0, y = 0, z = 0}
|
||||
local readPos = {x = pos.x, y = pos.y, z = pos.z}
|
||||
|
||||
@ -44,11 +55,28 @@ meseport.register_actionblock = function(ActionBlockType)
|
||||
|
||||
return on_punch_old(pos, node, puncher, pointed_thing) -- Added to avoid conflicts with other mods.
|
||||
end,
|
||||
|
||||
_meseport_on_punch_old = on_punch_old,
|
||||
})
|
||||
end
|
||||
|
||||
meseport.unregister_actionblock = function(ActionBlockType)
|
||||
local action_block_def = minetest.registered_nodes[ActionBlockType]
|
||||
assert(action_block_def ~= nil)
|
||||
local on_punch_old = action_block_def._meseport_on_punch_old
|
||||
if on_punch_old == nil then
|
||||
return -- was never registered
|
||||
end
|
||||
|
||||
minetest.override_item(ActionBlockType, {
|
||||
on_punch = on_punch_old,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
meseport.nodepowers["default:mese"] = 100
|
||||
meseport.register_nodepower("default:mese", 100)
|
||||
meseport.register_actionblock("default:goldblock")
|
||||
end
|
||||
|
||||
@ -56,6 +84,6 @@ if minetest.get_modpath("mcl_core")
|
||||
and minetest.get_modpath("mesecons_torch")
|
||||
and minetest.registered_nodes["mesecons_torch:redstoneblock"] then
|
||||
|
||||
meseport.register_nodepower("mesecons_torch:redstoneblock", 100)
|
||||
meseport.register_actionblock("mcl_core:goldblock")
|
||||
meseport.nodepowers["mesecons_torch:redstoneblock"] = 100
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user