Add core mods
2
mods/lzr_core/init.lua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dofile(minetest.get_modpath("lzr_core").."/nodes.lua")
|
||||||
|
dofile(minetest.get_modpath("lzr_core").."/mapgen.lua")
|
8
mods/lzr_core/mapgen.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
--
|
||||||
|
-- Aliases for map generators
|
||||||
|
--
|
||||||
|
|
||||||
|
minetest.register_alias("mapgen_stone", "lzr_core:wood")
|
||||||
|
minetest.register_alias("mapgen_water_source", "air")
|
||||||
|
minetest.register_alias("mapgen_river_water_source", "air")
|
||||||
|
|
2
mods/lzr_core/mod.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = lzr_core
|
||||||
|
depends = lzr_sounds
|
21
mods/lzr_core/nodes.lua
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
local S = minetest.get_translator("lzr_core")
|
||||||
|
|
||||||
|
minetest.register_node("lzr_core:tree", {
|
||||||
|
description = S("Tree Trunk"),
|
||||||
|
tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1},
|
||||||
|
sounds = lzr_sounds.node_sound_wood_defaults(),
|
||||||
|
|
||||||
|
on_place = minetest.rotate_node
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("lzr_core:wood", {
|
||||||
|
description = S("Wood Planks"),
|
||||||
|
tiles = {"default_wood.png"},
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, wood = 1},
|
||||||
|
sounds = lzr_sounds.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
BIN
mods/lzr_core/textures/default_tree.png
Normal file
After Width: | Height: | Size: 533 B |
BIN
mods/lzr_core/textures/default_tree_top.png
Normal file
After Width: | Height: | Size: 526 B |
BIN
mods/lzr_core/textures/default_wood.png
Normal file
After Width: | Height: | Size: 516 B |
7
mods/lzr_gui/init.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
player:hud_set_flags({minimap = false, minimap_radar = false, healthbar = false, breathbar = false})
|
||||||
|
player:hud_set_hotbar_itemcount(8)
|
||||||
|
player:set_inventory_formspec(
|
||||||
|
"formspec_version[4]size[11,6]list[current_player;main;0.5,0.5;8,4]"
|
||||||
|
)
|
||||||
|
end)
|
1
mods/lzr_gui/mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = lzr_gui
|
BIN
mods/lzr_gui/textures/crosshair.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
mods/lzr_gui/textures/object_crosshair.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
mods/lzr_gui/textures/smoke_puff.png
Normal file
After Width: | Height: | Size: 126 B |
8
mods/lzr_hand/init.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
minetest.override_item("", {
|
||||||
|
wield_scale = {x=1,y=1,z=2.5},
|
||||||
|
tool_capabilities = {
|
||||||
|
max_drop_level = 0,
|
||||||
|
groupcaps = {
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
1
mods/lzr_hand/mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = lzr_hand
|
BIN
mods/lzr_hand/textures/wieldhand.png
Normal file
After Width: | Height: | Size: 377 B |
5
mods/lzr_player/init.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
inv:set_size("main", 8)
|
||||||
|
inv:set_size("craft", 0)
|
||||||
|
end)
|
1
mods/lzr_player/mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = lzr_player
|
70
mods/lzr_sounds/init.lua
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
lzr_sounds = {}
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "", gain = 1.0}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_dug_node", gain = 0.25}
|
||||||
|
table.place = table.place or
|
||||||
|
{name = "default_place_node_hard", gain = 1.0}
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_stone_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "default_hard_footstep", gain = 0.3}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_hard_footstep", gain = 1.0}
|
||||||
|
lzr_sounds.node_sound_defaults(table)
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_dirt_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "default_dirt_footstep", gain = 0.4}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_dirt_footstep", gain = 1.0}
|
||||||
|
table.place = table.place or
|
||||||
|
{name = "default_place_node", gain = 1.0}
|
||||||
|
lzr_sounds.node_sound_defaults(table)
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_wood_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "default_wood_footstep", gain = 0.3}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_wood_footstep", gain = 1.0}
|
||||||
|
lzr_sounds.node_sound_defaults(table)
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_glass_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "default_glass_footstep", gain = 0.3}
|
||||||
|
table.dig = table.dig or
|
||||||
|
{name = "default_glass_footstep", gain = 0.5}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_break_glass", gain = 1.0}
|
||||||
|
lzr_sounds.node_sound_defaults(table)
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
|
function lzr_sounds.node_sound_metal_defaults(table)
|
||||||
|
table = table or {}
|
||||||
|
table.footstep = table.footstep or
|
||||||
|
{name = "default_metal_footstep", gain = 0.4}
|
||||||
|
table.dig = table.dig or
|
||||||
|
{name = "default_dig_metal", gain = 0.5}
|
||||||
|
table.dug = table.dug or
|
||||||
|
{name = "default_dug_metal", gain = 0.5}
|
||||||
|
table.place = table.place or
|
||||||
|
{name = "default_place_node_metal", gain = 0.5}
|
||||||
|
lzr_sounds.node_sound_defaults(table)
|
||||||
|
return table
|
||||||
|
end
|
1
mods/lzr_sounds/mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = lzr_sounds
|
11
mods/no_fall_damage/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Disable Fall Damage [`no_fall_damage`]
|
||||||
|
Version: 1.0.0
|
||||||
|
|
||||||
|
This mod disables fall damage completely.
|
||||||
|
|
||||||
|
## Technical notes
|
||||||
|
This mod only works if no other mod overwrites the
|
||||||
|
`fall_damage_add_percent` group (unlikely).
|
||||||
|
|
||||||
|
## License
|
||||||
|
This mod is licenced under the MIT License.
|
14
mods/no_fall_damage/init.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- Removing fall damage is done by overwriting the group
|
||||||
|
-- fall_damage_add_percent of all nodes. ]]
|
||||||
|
function remove_fall_damage()
|
||||||
|
for itemstring, def in pairs(minetest.registered_nodes) do
|
||||||
|
local groups = def.groups and table.copy(def.groups)
|
||||||
|
if groups then
|
||||||
|
groups.fall_damage_add_percent = -100
|
||||||
|
-- Let's hack the node!
|
||||||
|
minetest.override_item(itemstring, { groups = groups })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(remove_fall_damage)
|
2
mods/no_fall_damage/mod.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = no_fall_damage
|
||||||
|
description = Disables fall damage.
|
5
mods/no_multiplayer/init.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
local S = minetest.get_translator("no_multiplayer")
|
||||||
|
|
||||||
|
if not minetest.is_singleplayer() then
|
||||||
|
error(S("This is not a multiplayer game! Please disable server hosting and try again."))
|
||||||
|
end
|
1
mods/no_multiplayer/mod.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
name = no_multiplayer
|
27
mods/player_api/README.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Minetest Game mod: player_api
|
||||||
|
=============================
|
||||||
|
See license.txt for license information.
|
||||||
|
|
||||||
|
Provides an API to allow multiple mods to set player models and textures.
|
||||||
|
Also sets the default model, texture, and player flags.
|
||||||
|
This mod is only for content related to the Player API and the player object.
|
||||||
|
|
||||||
|
Authors of source code
|
||||||
|
----------------------
|
||||||
|
Originally by celeron55, Perttu Ahola <celeron55@gmail.com> (LGPLv2.1+)
|
||||||
|
Various Minetest developers and contributors (LGPLv2.1+)
|
||||||
|
|
||||||
|
Authors of media (textures, models and sounds)
|
||||||
|
----------------------------------------------
|
||||||
|
Original model by MirceaKitsune (CC BY-SA 3.0).
|
||||||
|
Various alterations and fixes by kilbith, sofar, xunto, Rogier-5, TeTpaAka, Desour,
|
||||||
|
stujones11, An0n3m0us (CC BY-SA 3.0):
|
||||||
|
character.b3d
|
||||||
|
character.blend
|
||||||
|
|
||||||
|
Jordach (CC BY-SA 3.0):
|
||||||
|
character.png
|
||||||
|
|
||||||
|
celeron55, Perttu Ahola <celeron55@gmail.com> (CC BY-SA 3.0):
|
||||||
|
player.png
|
||||||
|
player_back.png
|
146
mods/player_api/api.lua
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
-- Minetest 0.4 mod: player
|
||||||
|
-- See README.txt for licensing and other information.
|
||||||
|
|
||||||
|
player_api = {}
|
||||||
|
|
||||||
|
-- Player animation blending
|
||||||
|
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||||
|
local animation_blend = 0
|
||||||
|
|
||||||
|
player_api.registered_models = { }
|
||||||
|
|
||||||
|
-- Local for speed.
|
||||||
|
local models = player_api.registered_models
|
||||||
|
|
||||||
|
function player_api.register_model(name, def)
|
||||||
|
models[name] = def
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Player stats and animations
|
||||||
|
local player_model = {}
|
||||||
|
local player_textures = {}
|
||||||
|
local player_anim = {}
|
||||||
|
local player_sneak = {}
|
||||||
|
player_api.player_attached = {}
|
||||||
|
|
||||||
|
function player_api.get_animation(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
return {
|
||||||
|
model = player_model[name],
|
||||||
|
textures = player_textures[name],
|
||||||
|
animation = player_anim[name],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Called when a player's appearance needs to be updated
|
||||||
|
function player_api.set_model(player, model_name)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local model = models[model_name]
|
||||||
|
if model then
|
||||||
|
if player_model[name] == model_name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
player:set_properties({
|
||||||
|
mesh = model_name,
|
||||||
|
textures = player_textures[name] or model.textures,
|
||||||
|
visual = "mesh",
|
||||||
|
visual_size = model.visual_size or {x = 1, y = 1},
|
||||||
|
collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
||||||
|
stepheight = model.stepheight or 0.6,
|
||||||
|
eye_height = model.eye_height or 1.47,
|
||||||
|
})
|
||||||
|
player_api.set_animation(player, "stand")
|
||||||
|
else
|
||||||
|
player:set_properties({
|
||||||
|
textures = {"player.png", "player_back.png"},
|
||||||
|
visual = "upright_sprite",
|
||||||
|
visual_size = {x = 1, y = 2},
|
||||||
|
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3},
|
||||||
|
stepheight = 0.6,
|
||||||
|
eye_height = 1.625,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
player_model[name] = model_name
|
||||||
|
end
|
||||||
|
|
||||||
|
function player_api.set_textures(player, textures)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local model = models[player_model[name]]
|
||||||
|
local model_textures = model and model.textures or nil
|
||||||
|
player_textures[name] = textures or model_textures
|
||||||
|
player:set_properties({textures = textures or model_textures})
|
||||||
|
end
|
||||||
|
|
||||||
|
function player_api.set_animation(player, anim_name, speed)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if player_anim[name] == anim_name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local model = player_model[name] and models[player_model[name]]
|
||||||
|
if not (model and model.animations[anim_name]) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local anim = model.animations[anim_name]
|
||||||
|
player_anim[name] = anim_name
|
||||||
|
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
player_model[name] = nil
|
||||||
|
player_anim[name] = nil
|
||||||
|
player_textures[name] = nil
|
||||||
|
player_sneak[name] = nil
|
||||||
|
player_api.player_attached[name] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Localize for better performance.
|
||||||
|
local player_set_animation = player_api.set_animation
|
||||||
|
local player_attached = player_api.player_attached
|
||||||
|
|
||||||
|
-- Prevent knockback for attached players
|
||||||
|
local old_calculate_knockback = minetest.calculate_knockback
|
||||||
|
function minetest.calculate_knockback(player, ...)
|
||||||
|
if player_attached[player:get_player_name()] then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return old_calculate_knockback(player, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check each player and apply animations
|
||||||
|
minetest.register_globalstep(function()
|
||||||
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local model_name = player_model[name]
|
||||||
|
local model = model_name and models[model_name]
|
||||||
|
if model and not player_attached[name] then
|
||||||
|
local controls = player:get_player_control()
|
||||||
|
local animation_speed_mod = model.animation_speed or 30
|
||||||
|
|
||||||
|
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||||
|
if controls.sneak then
|
||||||
|
animation_speed_mod = animation_speed_mod / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Apply animations based on what the player is doing
|
||||||
|
if player:get_hp() == 0 then
|
||||||
|
player_set_animation(player, "lay")
|
||||||
|
-- Determine if the player is walking
|
||||||
|
elseif controls.up or controls.down or controls.left or controls.right then
|
||||||
|
if player_sneak[name] ~= controls.sneak then
|
||||||
|
player_anim[name] = nil
|
||||||
|
player_sneak[name] = controls.sneak
|
||||||
|
end
|
||||||
|
if controls.LMB or controls.RMB then
|
||||||
|
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||||
|
else
|
||||||
|
player_set_animation(player, "walk", animation_speed_mod)
|
||||||
|
end
|
||||||
|
elseif controls.LMB or controls.RMB then
|
||||||
|
player_set_animation(player, "mine", animation_speed_mod)
|
||||||
|
else
|
||||||
|
player_set_animation(player, "stand", animation_speed_mod)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
34
mods/player_api/init.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
-- player/init.lua
|
||||||
|
|
||||||
|
dofile(minetest.get_modpath("player_api") .. "/api.lua")
|
||||||
|
|
||||||
|
-- Default player appearance
|
||||||
|
player_api.register_model("character.b3d", {
|
||||||
|
animation_speed = 30,
|
||||||
|
textures = {"character.png"},
|
||||||
|
animations = {
|
||||||
|
-- Standard animations.
|
||||||
|
stand = {x = 0, y = 79},
|
||||||
|
lay = {x = 162, y = 166},
|
||||||
|
walk = {x = 168, y = 187},
|
||||||
|
mine = {x = 189, y = 198},
|
||||||
|
walk_mine = {x = 200, y = 219},
|
||||||
|
sit = {x = 81, y = 160},
|
||||||
|
},
|
||||||
|
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
||||||
|
stepheight = 0.6,
|
||||||
|
eye_height = 1.47,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Update appearance when the player joins
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
player_api.player_attached[player:get_player_name()] = false
|
||||||
|
player_api.set_model(player, "character.b3d")
|
||||||
|
player:set_local_animation(
|
||||||
|
{x = 0, y = 79},
|
||||||
|
{x = 168, y = 187},
|
||||||
|
{x = 189, y = 198},
|
||||||
|
{x = 200, y = 219},
|
||||||
|
30
|
||||||
|
)
|
||||||
|
end)
|
60
mods/player_api/license.txt
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
License of source code
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
GNU Lesser General Public License, version 2.1
|
||||||
|
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
Copyright (C) 2011 Various Minetest developers and contributors
|
||||||
|
|
||||||
|
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 program 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:
|
||||||
|
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
|
||||||
|
|
||||||
|
|
||||||
|
Licenses of media (textures, models and sounds)
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
Copyright (C) 2012 MirceaKitsune
|
||||||
|
Copyright (C) 2012 Jordach
|
||||||
|
Copyright (C) 2015 kilbith
|
||||||
|
Copyright (C) 2016 sofar
|
||||||
|
Copyright (C) 2016 xunto
|
||||||
|
Copyright (C) 2016 Rogier-5
|
||||||
|
Copyright (C) 2017 TeTpaAka
|
||||||
|
Copyright (C) 2017 Desour
|
||||||
|
Copyright (C) 2018 stujones11
|
||||||
|
Copyright (C) 2019 An0n3m0us
|
||||||
|
|
||||||
|
You are free to:
|
||||||
|
Share — copy and redistribute the material in any medium or format.
|
||||||
|
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||||
|
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||||
|
|
||||||
|
Under the following terms:
|
||||||
|
|
||||||
|
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||||
|
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||||
|
that suggests the licensor endorses you or your use.
|
||||||
|
|
||||||
|
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||||
|
your contributions under the same license as the original.
|
||||||
|
|
||||||
|
No additional restrictions — You may not apply legal terms or technological measures that
|
||||||
|
legally restrict others from doing anything the license permits.
|
||||||
|
|
||||||
|
Notices:
|
||||||
|
|
||||||
|
You do not have to comply with the license for elements of the material in the public
|
||||||
|
domain or where your use is permitted by an applicable exception or limitation.
|
||||||
|
No warranties are given. The license may not give you all of the permissions necessary
|
||||||
|
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||||
|
rights may limit how you use the material.
|
||||||
|
|
||||||
|
For more details:
|
||||||
|
http://creativecommons.org/licenses/by-sa/3.0/
|
2
mods/player_api/mod.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
name = player_api
|
||||||
|
description = Minetest Game mod: player_api
|
BIN
mods/player_api/models/character.b3d
Normal file
BIN
mods/player_api/models/character.blend
Normal file
BIN
mods/player_api/models/character.png
Normal file
After Width: | Height: | Size: 1021 B |
BIN
mods/player_api/textures/player.png
Normal file
After Width: | Height: | Size: 141 B |
BIN
mods/player_api/textures/player_back.png
Normal file
After Width: | Height: | Size: 140 B |
19
mods/show_wielded_item/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Show Wielded Item [`show_wielded_item`]
|
||||||
|
This Minetest mod displays the name of the wielded item above the hotbar and
|
||||||
|
statbars.
|
||||||
|
|
||||||
|
This mod is compatible with the HUD Bars [`hudbars`] mod.
|
||||||
|
Compability with other HUD-related mods is possible, but not guaranteed.
|
||||||
|
|
||||||
|
Version: 1.2.0
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
Released by Wuzzy.
|
||||||
|
The original mod code was taken from the file “`item_names.lua`”
|
||||||
|
found in the Unified Inventory mod maintained by VanessaE. This code
|
||||||
|
has been later modified.
|
||||||
|
Original author: 4aiman
|
||||||
|
|
||||||
|
## License
|
||||||
|
This mod is licensed under GNU LGPLv2 or later
|
||||||
|
(see <https://www.gnu.org/licenses/lgpl-2.1.html>).
|
1
mods/show_wielded_item/depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hudbars?
|
135
mods/show_wielded_item/init.lua
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
-- Based on 4itemnames mod by 4aiman
|
||||||
|
|
||||||
|
local wield = {}
|
||||||
|
local wieldindex = {}
|
||||||
|
local huds = {}
|
||||||
|
local dtimes = {}
|
||||||
|
local dlimit = 3 -- HUD element will be hidden after this many seconds
|
||||||
|
|
||||||
|
local hudbars_mod = minetest.get_modpath("hudbars")
|
||||||
|
|
||||||
|
local function set_hud(player)
|
||||||
|
if not player:is_player() then return end
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
-- Fixed offset in config file
|
||||||
|
local fixed = tonumber(minetest.settings:get("show_wielded_item_y_offset"))
|
||||||
|
local off
|
||||||
|
if fixed and fixed ~= -1 then
|
||||||
|
-- Manual offset
|
||||||
|
off = {x=0, y=-fixed}
|
||||||
|
else
|
||||||
|
-- Default offset
|
||||||
|
off = {x=0, y=-101}
|
||||||
|
|
||||||
|
if hudbars_mod then
|
||||||
|
-- Tweak offset if hudbars mod was found
|
||||||
|
|
||||||
|
local rows = math.floor((#hb.get_hudbar_identifiers()-1) / 2) + 1
|
||||||
|
local vmargin = tonumber(minetest.settings:get("hudbars_vmargin")) or 24
|
||||||
|
off.y = -76 - vmargin*rows
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Dirty trick to avoid collision with Minetest's status text (e.g. “Volume changed to 0%”)
|
||||||
|
if off.y >= -167 and off.y <= -156 then
|
||||||
|
off.y = -181
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
huds[player_name] = player:hud_add({
|
||||||
|
hud_elem_type = "text",
|
||||||
|
position = {x=0.5, y=1},
|
||||||
|
offset = off,
|
||||||
|
alignment = {x=0, y=0},
|
||||||
|
number = 0xFFFFFF ,
|
||||||
|
text = "",
|
||||||
|
z_index = 100,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
set_hud(player)
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
wield[name] = player:get_wielded_item():get_name()
|
||||||
|
wieldindex[name] = player:get_wield_index()
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
wield[name] = nil
|
||||||
|
wieldindex[name] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function get_first_line(text)
|
||||||
|
-- Cut off text after first newline
|
||||||
|
local firstnewline = string.find(text, "\n")
|
||||||
|
if firstnewline then
|
||||||
|
text = string.sub(text, 1, firstnewline-1)
|
||||||
|
end
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
local wstack = player:get_wielded_item()
|
||||||
|
local wname = wstack:get_name()
|
||||||
|
local windex = player:get_wield_index()
|
||||||
|
|
||||||
|
if dtimes[player_name] and dtimes[player_name] < dlimit then
|
||||||
|
dtimes[player_name] = dtimes[player_name] + dtime
|
||||||
|
if dtimes[player_name] > dlimit and huds[player_name] then
|
||||||
|
player:hud_change(huds[player_name], 'text', "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update HUD when wielded item or wielded index changed
|
||||||
|
if wname ~= wield[player_name] or windex ~= wieldindex[player_name] then
|
||||||
|
wieldindex[player_name] = windex
|
||||||
|
wield[player_name] = wname
|
||||||
|
dtimes[player_name] = 0
|
||||||
|
|
||||||
|
if huds[player_name] then
|
||||||
|
|
||||||
|
-- Get description (various fallback checks for old Minetest versions)
|
||||||
|
local def = minetest.registered_items[wname]
|
||||||
|
local desc
|
||||||
|
if wstack.get_short_description then
|
||||||
|
-- get_short_description()
|
||||||
|
desc = wstack:get_short_description()
|
||||||
|
end
|
||||||
|
if (not desc or desc == "") and wstack.get_description then
|
||||||
|
-- get_description()
|
||||||
|
desc = wstack:get_description()
|
||||||
|
desc = get_first_line(desc)
|
||||||
|
end
|
||||||
|
if (not desc or desc == "") and not wstack.get_description then
|
||||||
|
-- Metadata (old versions only)
|
||||||
|
local meta = wstack:get_meta()
|
||||||
|
desc = meta:get_string("description")
|
||||||
|
desc = get_first_line(desc)
|
||||||
|
end
|
||||||
|
if not desc or desc == "" then
|
||||||
|
-- Item definition
|
||||||
|
desc = def.description
|
||||||
|
desc = get_first_line(desc)
|
||||||
|
end
|
||||||
|
if not desc or desc == "" then
|
||||||
|
-- Final fallback: itemstring
|
||||||
|
desc = wname
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Print description
|
||||||
|
if desc then
|
||||||
|
-- Optionally append the 'technical' itemname
|
||||||
|
local tech = minetest.settings:get_bool("show_wielded_item_itemname", false)
|
||||||
|
if tech and desc ~= "" then
|
||||||
|
desc = desc .. " ["..wname.."]"
|
||||||
|
end
|
||||||
|
player:hud_change(huds[player_name], 'text', desc)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
3
mods/show_wielded_item/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = show_wielded_item
|
||||||
|
description = Displays the name of the wielded item.
|
||||||
|
optional_depends = hudbars
|
BIN
mods/show_wielded_item/screenshot.png
Normal file
After Width: | Height: | Size: 12 KiB |
8
mods/show_wielded_item/settingtypes.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#If true, also append the 'technical' itemname.
|
||||||
|
show_wielded_item_itemname (Show technical itemname) bool false
|
||||||
|
|
||||||
|
#Use this setting to manually set the vertical offset of the label which shows
|
||||||
|
#the name of the wielded item. The offset is in pixels from the bottom of the
|
||||||
|
#screen.
|
||||||
|
#Set this to -1 to let the mod guess the offset automatically (recommended).
|
||||||
|
show_wielded_item_y_offset (Vertical offset of wielded item name display) int -1 -1
|