Added the Limiter buff for all tool types

master
Alexand(er|ra) Yst 2021-01-15 17:56:34 -08:00
parent cc3404739c
commit 273a81818e
6 changed files with 175 additions and 165 deletions

View File

@ -1,5 +1,5 @@
-- runes mod for Minetest
-- Copyright © 2020 Alex Yst <mailto:copyright@y.st>
-- Copyright © 2020-2021 Alex Yst <mailto:copyright@y.st>
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
@ -24,20 +24,20 @@
return {
axe = {
sand = "toter",
coal_lump = "toter",
sand = "soulbound",
coal_lump = "lumberjack",
iron_lump = "toter",
sapling = "lumberjack",
mese_crystal = "durable",
copper_lump = "toter",
copper_lump = "rapid",
diamond = "durable",
gold_lump = "toter",
gold_lump = "limiter",
junglesapling = "lumberjack",
seed_cotton = "rapid",
seed_wheat = "rapid",
string = "rapid",
wheat = "rapid",
cotton = "rapid",
wheat = "limiter",
cotton = "limiter",
pine_sapling = "lumberjack",
acacia_sapling = "lumberjack",
mushroom_brown = "toter",
@ -46,25 +46,25 @@ return {
mushroom_spores_red = "soulbound",
aspen_sapling = "lumberjack",
flint = "lumberjack",
coral_skeleton = "toter",
coral_skeleton = "soulbound",
acacia_bush_sapling = "termite",
bush_sapling = "termite",
tin_lump = "toter",
tin_lump = "rapid",
blueberries = "soulbound",
blueberry_bush_sapling = "lumberjack",
ice = "toter",
ice = "limiter",
pine_bush_sapling = "termite",
dry_dirt = "toter",
dry_dirt = "limiter",
},
fire_starter = {
sand = "soulbound",
coal_lump = "soulbound",
iron_lump = "soulbound",
coal_lump = "limiter",
iron_lump = "limiter",
sapling = "gardener",
mese_crystal = "durable",
copper_lump = "soulbound",
copper_lump = "limiter",
diamond = "durable",
gold_lump = "soulbound",
gold_lump = "limiter",
junglesapling = "gardener",
seed_cotton = "gardener",
seed_wheat = "gardener",
@ -73,29 +73,29 @@ return {
cotton = "soulbound",
pine_sapling = "gardener",
acacia_sapling = "gardener",
mushroom_brown = "soulbound",
mushroom_red = "soulbound",
mushroom_spores_brown = "gardener",
mushroom_spores_red = "gardener",
mushroom_brown = "limiter",
mushroom_red = "limiter",
mushroom_spores_brown = "limiter",
mushroom_spores_red = "limiter",
aspen_sapling = "gardener",
flint = "soulbound",
flint = "limiter",
coral_skeleton = "soulbound",
acacia_bush_sapling = "gardener",
bush_sapling = "gardener",
tin_lump = "soulbound",
tin_lump = "limiter",
blueberries = "soulbound",
blueberry_bush_sapling = "gardener",
ice = "soulbound",
pine_bush_sapling = "gardener",
dry_dirt = "soulbound",
dry_dirt = "gardener",
},
pick = {
sand = "rapid",
sand = "soulbound",
coal_lump = "rapid",
iron_lump = "rapid",
iron_lump = "cobbleeater",
sapling = "rapid",
mese_crystal = "durable",
copper_lump = "rapid",
copper_lump = "cobbleeater",
diamond = "durable",
gold_lump = "rapid",
junglesapling = "rapid",
@ -111,26 +111,26 @@ return {
mushroom_spores_brown = "soulbound",
mushroom_spores_red = "soulbound",
aspen_sapling = "rapid",
flint = "rapid",
coral_skeleton = "rapid",
acacia_bush_sapling = "rapid",
bush_sapling = "rapid",
tin_lump = "rapid",
blueberries = "soulbound",
blueberry_bush_sapling = "rapid",
ice = "rapid",
pine_bush_sapling = "rapid",
flint = "limiter",
coral_skeleton = "limiter",
acacia_bush_sapling = "limiter",
bush_sapling = "limiter",
tin_lump = "cobbleeater",
blueberries = "limiter",
blueberry_bush_sapling = "limiter",
ice = "limiter",
pine_bush_sapling = "limiter",
dry_dirt = "rapid",
},
hoe = {
sand = "soulbound",
coal_lump = "soulbound",
iron_lump = "soulbound",
coal_lump = "spreader",
iron_lump = "breaker",
sapling = "breaker",
mese_crystal = "durable",
copper_lump = "soulbound",
copper_lump = "breaker",
diamond = "durable",
gold_lump = "soulbound",
gold_lump = "breaker",
junglesapling = "breaker",
seed_cotton = "soulbound",
seed_wheat = "soulbound",
@ -148,22 +148,22 @@ return {
coral_skeleton = "soulbound",
acacia_bush_sapling = "mosser",
bush_sapling = "mosser",
tin_lump = "soulbound",
blueberries = "soulbound",
blueberry_bush_sapling = "soulbound",
ice = "soulbound",
tin_lump = "breaker",
blueberries = "limiter",
blueberry_bush_sapling = "limiter",
ice = "breaker",
pine_bush_sapling = "mosser",
dry_dirt = "soulbound",
dry_dirt = "spreader",
},
screwdriver = {
sand = "adjuster",
coal_lump = "soulbound",
iron_lump = "soulbound",
coal_lump = "limiter",
iron_lump = "limiter",
sapling = "adjuster",
mese_crystal = "durable",
copper_lump = "soulbound",
copper_lump = "limiter",
diamond = "durable",
gold_lump = "soulbound",
gold_lump = "limiter",
junglesapling = "adjuster",
seed_cotton = "soulbound",
seed_wheat = "soulbound",
@ -172,16 +172,16 @@ return {
cotton = "soulbound",
pine_sapling = "adjuster",
acacia_sapling = "adjuster",
mushroom_brown = "soulbound",
mushroom_red = "soulbound",
mushroom_spores_brown = "soulbound",
mushroom_spores_red = "soulbound",
mushroom_brown = "limiter",
mushroom_red = "limiter",
mushroom_spores_brown = "limiter",
mushroom_spores_red = "limiter",
aspen_sapling = "adjuster",
flint = "soulbound",
coral_skeleton = "soulbound",
acacia_bush_sapling = "adjuster",
bush_sapling = "adjuster",
tin_lump = "soulbound",
tin_lump = "limiter",
blueberries = "soulbound",
blueberry_bush_sapling = "adjuster",
ice = "soulbound",
@ -189,7 +189,7 @@ return {
dry_dirt = "soulbound",
},
shovel = {
sand = "rapid",
sand = "soulbound",
coal_lump = "rapid",
iron_lump = "rapid",
sapling = "thirst",
@ -205,24 +205,24 @@ return {
cotton = "rapid",
pine_sapling = "thirst",
acacia_sapling = "thirst",
mushroom_brown = "soulbound",
mushroom_brown = "limiter",
mushroom_red = "soulbound",
mushroom_spores_brown = "soulbound",
mushroom_spores_brown = "limiter",
mushroom_spores_red = "soulbound",
aspen_sapling = "thirst",
flint = "thirst",
coral_skeleton = "rapid",
coral_skeleton = "limiter",
acacia_bush_sapling = "thirst",
bush_sapling = "thirst",
tin_lump = "rapid",
blueberries = "transplanter",
blueberry_bush_sapling = "thirst",
ice = "rapid",
ice = "limiter",
pine_bush_sapling = "thirst",
dry_dirt = "rapid",
dry_dirt = "transplanter",
},
sword = {
sand = "rapid",
sand = "soulbound",
coal_lump = "rapid",
iron_lump = "rapid",
sapling = "thirst",
@ -238,20 +238,20 @@ return {
cotton = "rapid",
pine_sapling = "thirst",
acacia_sapling = "thirst",
mushroom_brown = "pruner",
mushroom_brown = "limiter",
mushroom_red = "pruner",
mushroom_spores_brown = "pruner",
mushroom_spores_brown = "limiter",
mushroom_spores_red = "pruner",
aspen_sapling = "thirst",
flint = "thirst",
coral_skeleton = "rapid",
coral_skeleton = "pruner",
acacia_bush_sapling = "thirst",
bush_sapling = "thirst",
tin_lump = "rapid",
blueberries = "soulbound",
blueberry_bush_sapling = "thirst",
ice = "rapid",
ice = "pruner",
pine_bush_sapling = "thirst",
dry_dirt = "rapid",
dry_dirt = "pruner",
},
}

View File

@ -0,0 +1,39 @@
-- runes mod for Minetest
-- Copyright © 2021 Alex Yst <mailto:copyright@y.st>
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- This software is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <https://www.gnu.org./licenses/>.
local is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
local player = minetest.get_player_by_name(name)
-- minetest.is_protected() can be called with an empty string for a
-- player name, and if that happens, I think
-- minetest.get_player_by_name() probably wouldn't return a player
-- object. Likewise, I think a player object might not be returned if
-- the player the protection check is performed on isn't logged in.
-- Just to be sure, let's check to see if a player object is even
-- returned before trying to call one of its methods.
if player then
local tool = player:get_wielded_item()
if tool:get_wear() > 61440 and tool:get_name():sub(1, 6) == "runes:" then
if tool:get_meta():get("limiter") then
minetest.chat_send_player(name, "Your tool is too damaged to use without risking breaking it.")
return true
end
end
end
return is_protected(pos, name)
end

View File

@ -1,37 +0,0 @@
minetest.register_chatcommand("updatetool", {
description = "Fix a shovel or sword that has the debug buff.",
func = function(name, arg)
local player = minetest.get_player_by_name(name)
local tool = player:get_wielded_item()
local tool_type = tool:get_name()
local meta = tool:get_meta()
-- Currently, a feature in the stable version but not the development
-- version of Minetest prevents setting the value to integer zero from
-- working correctly, but setting to string zero should work just fine.
local debug_level = tonumber(meta:get_string("debug"))
if debug_level then
if tool_type == "runes:shovel" then
meta:set_string("thirst", debug_level)
meta:set_string("debug") -- set to nil to remove key/value pair
local description = minetest.registered_tools["runes:shovel"].description.."\nRepair count: "..meta:get_int("repair").."\nThirst ("..debug_level..")"
meta:set_string("description", description)
player:set_wielded_item(tool)
elseif tool_type == "runes:sword" then
local thirst = math.ceil((debug_level - 1) / 2)
local pruner = math.floor((debug_level - 1) / 2)
local description = minetest.registered_tools["runes:shovel"].description.."\nRepair count: "..meta:get_int("repair")
if thirst > -1 then
meta:set_string("thirst", thirst)
description = description.."\nThirst ("..thirst..")"
end
if pruner > -1 then
meta:set_string("pruner", pruner)
description = description.."\nPruner ("..pruner..")"
end
meta:set_string("debug") -- set to nil to remove key/value pair
meta:set_string("description", description)
player:set_wielded_item(tool)
end
end
end,
})

View File

@ -18,7 +18,7 @@
dofile(minetest.get_modpath("runes").."/runes.lua")
dofile(minetest.get_modpath("runes").."/tools.lua")
dofile(minetest.get_modpath("runes").."/tool_crafting.lua")
dofile(minetest.get_modpath("runes").."/buffs/toter.lua")
dofile(minetest.get_modpath("runes").."/buffs/limiter.lua")
dofile(minetest.get_modpath("runes").."/buffs/lumberjack.lua")
dofile(minetest.get_modpath("runes").."/buffs/soulbound.lua")
dofile(minetest.get_modpath("runes").."/debug.lua")
dofile(minetest.get_modpath("runes").."/buffs/toter.lua")

View File

@ -1,5 +1,5 @@
-- runes mod for Minetest
-- Copyright © 2020 Alex Yst <mailto:copyright@y.st>
-- Copyright © 2020-2021 Alex Yst <mailto:copyright@y.st>
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
@ -47,22 +47,23 @@ local S = minetest.get_translator("runes")
local rune_and_tool_to_buff = dofile(minetest.get_modpath("runes").."/buff_table.lua")
local buff_name = {
debug = S("Debug Buff"),
thirst = S("Level Thirst"),
pruner = S("Pruner"),
spreader = S("Spreader"),
durable = S("Durable"),
rapid = S("Rapid Digger"),
toter = S("Toter"),
transplanter = S("Transplanter"),
lumberjack = S("Lumberjack"),
termite = S("Termite"),
cobbleeater = S("Cobble Eater"),
soulbound = S("Soulbound"),
adjuster = S("Kelp Adjuster"),
breaker = S("Breaker"),
mosser = S("Mosser"),
cobbleeater = S("Cobble Eater"),
debug = S("Debug Buff"),
durable = S("Durable"),
gardener = S("Gardener"),
limiter = S("Limiter"),
lumberjack = S("Lumberjack"),
mosser = S("Mosser"),
pruner = S("Pruner"),
rapid = S("Rapid Digger"),
soulbound = S("Soulbound"),
spreader = S("Spreader"),
termite = S("Termite"),
thirst = S("Level Thirst"),
toter = S("Toter"),
transplanter = S("Transplanter"),
}
local rune_element_modname = {

View File

@ -1,5 +1,5 @@
-- runes mod for Minetest
-- Copyright © 2020 Alex Yst <mailto:copyright@y.st>
-- Copyright © 2020-2021 Alex Yst <mailto:copyright@y.st>
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
@ -239,16 +239,19 @@ minetest.register_tool("runes:sword", {
y = pointed_thing.under.y + prunable_trunk[potential_log.name].range,
z = pointed_thing.under.z + prunable_trunk[potential_log.name].range,
}, prunable_trunk[potential_log.name].leaves)
local player_name = user:get_player_name()
for _, pos in next, to_prune do
local node = minetest.get_node(pos)
minetest.node_dig(pos, node, user)
-- Apple marks are dealt with separately because minetest.node_dig()
-- doesn't work on them. It's probably because players can't normally
-- dig them. We also assume that apples have left behind apple marks
-- and remove those as well.
if node.name == "default:apple_mark"
or node.name == "default:apple" then
minetest.remove_node(pos)
if not minetest.is_protected(pos, player_name) then
local node = minetest.get_node(pos)
minetest.node_dig(pos, node, user)
-- Apple marks are dealt with separately because minetest.node_dig()
-- doesn't work on them. It's probably because players can't normally
-- dig them. We also assume that apples have left behind apple marks
-- and remove those as well.
if node.name == "default:apple_mark"
or node.name == "default:apple" then
minetest.remove_node(pos)
end
end
end
-- This seems a bit unclean, but I'm not sure how else to handle the
@ -341,48 +344,52 @@ minetest.register_tool("runes:screwdriver", {
wield_overlay = "runes.tool_stone_screwdriver.png",
groups = {tool = 1, disable_repair = 1},
on_use = function(itemstack, user, pointed_thing)
local uses = 500
local meta = itemstack:get_meta()
if meta:get("durability") then
uses = 750
if not minetest.is_protected(pointed_thing.under, user:get_player_name()) then
local uses = 500
local meta = itemstack:get_meta()
if meta:get("durability") then
uses = 750
end
local node = minetest.get_node(pointed_thing.under)
if meta:get("adjuster")
and minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].paramtype2 == "leveled"
and minetest.registered_nodes[node.name].drawtype == "plantlike_rooted" then
minetest.swap_node(pointed_thing.under, {
name = node.name,
param1 = node.param1,
param2 = (node.param2 + 1) % 256,
})
itemstack:add_wear(math.floor(65536 / uses))
else
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, uses)
end
return itemstack
end
local node = minetest.get_node(pointed_thing.under)
if meta:get("adjuster")
and minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].paramtype2 == "leveled"
and minetest.registered_nodes[node.name].drawtype == "plantlike_rooted" then
minetest.swap_node(pointed_thing.under, {
name = node.name,
param1 = node.param1,
param2 = (node.param2 + 1) % 256,
})
itemstack:add_wear(math.floor(65536 / uses))
else
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, uses)
end
return itemstack
end,
on_place = function(itemstack, user, pointed_thing)
local uses = 500
local meta = itemstack:get_meta()
if itemstack:get_meta():get("durability") then
uses = 750
if not minetest.is_protected(pointed_thing.under, user:get_player_name()) then
local uses = 500
local meta = itemstack:get_meta()
if itemstack:get_meta():get("durability") then
uses = 750
end
local node = minetest.get_node(pointed_thing.under)
if meta:get("adjuster")
and minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].paramtype2 == "leveled"
and minetest.registered_nodes[node.name].drawtype == "plantlike_rooted" then
minetest.swap_node(pointed_thing.under, {
name = node.name,
param1 = node.param1,
param2 = (node.param2 - 1) % 256,
})
itemstack:add_wear(math.floor(65536 / uses))
else
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, uses)
end
return itemstack
end
local node = minetest.get_node(pointed_thing.under)
if meta:get("adjuster")
and minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].paramtype2 == "leveled"
and minetest.registered_nodes[node.name].drawtype == "plantlike_rooted" then
minetest.swap_node(pointed_thing.under, {
name = node.name,
param1 = node.param1,
param2 = (node.param2 - 1) % 256,
})
itemstack:add_wear(math.floor(65536 / uses))
else
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_AXIS, uses)
end
return itemstack
end,
})