mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-08 16:19:37 +01:00
Fix some present issues with vl_pickblock
This commit is contained in:
parent
1685f5ce2e
commit
87da975918
5 changed files with 19 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022 ROllerozxa
|
Copyright (c) 2022 ROllerozxa
|
||||||
Copyright (c) 2024 Mikita 'rudzik8' Wiśniewski
|
Copyright (c) 2024-2025 Mikita 'rudzik8' Wiśniewski
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -8,6 +8,6 @@ You select them with the build key (right-click) as compared to with middle-clic
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (C) 2022 ROllerozxa\
|
Copyright (C) 2022 ROllerozxa\
|
||||||
Copyright (C) 2024 Mikita 'rudzik8' Wiśniewski
|
Copyright (C) 2024-2025 Mikita 'rudzik8' Wiśniewski
|
||||||
|
|
||||||
MIT (see `LICENSE` file)
|
MIT (see `LICENSE` file)
|
||||||
|
|
|
@ -1,45 +1,41 @@
|
||||||
local S = minetest.get_translator("vl_pickblock")
|
local function pickblock(_, placer, pointed_thing)
|
||||||
|
|
||||||
local function pickblock(itemstack, placer, pointed_thing)
|
|
||||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||||
if not node then return end
|
if not node then return end
|
||||||
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
if not def then return end
|
if not def then return end
|
||||||
|
|
||||||
local rnode
|
|
||||||
-- if this is an 'illegal' node and there's an explicit `_vl_pickblock` field, then return it
|
|
||||||
-- if the node isn't 'illegal', return it as-is
|
|
||||||
-- (and if it's 'illegal' and no `_vl_pickblock` is defined, well, bad luck)
|
|
||||||
local illegal = (def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0)
|
local illegal = (def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0)
|
||||||
if illegal then
|
|
||||||
if def._vl_pickblock then
|
local rnode
|
||||||
rnode = def._vl_pickblock
|
if def._vl_pickblock then
|
||||||
end
|
rnode = def._vl_pickblock
|
||||||
else
|
elseif not illegal then
|
||||||
rnode = node.name
|
rnode = node.name
|
||||||
|
else
|
||||||
|
-- node is illegal and has no _vl_pickblock, tough luck
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if the picked node is already on the hotbar
|
-- check if the picked node is already on the hotbar
|
||||||
-- if so, notify the player
|
-- if so, remove it!
|
||||||
local inv = placer:get_inventory()
|
local inv = placer:get_inventory()
|
||||||
for i=1,placer:hud_get_hotbar_itemcount() do
|
for i = 1, placer:hud_get_hotbar_itemcount() do
|
||||||
local stack = inv:get_stack("main", i)
|
local stack = inv:get_stack("main", i)
|
||||||
if stack:get_name() == rnode then
|
if stack:get_name() == rnode then
|
||||||
local msg = S("@1 is on slot @2", stack:get_short_description(), minetest.colorize(mcl_colors.YELLOW, i))
|
inv:set_stack("main", i, ItemStack())
|
||||||
mcl_title.set(placer, "actionbar", {text = msg, stay = 30})
|
break -- only remove one
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return rnode
|
return rnode
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local old_on_place = minetest.registered_items[""].on_place
|
||||||
minetest.override_item("", {
|
minetest.override_item("", {
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) then
|
old_on_place(itemstack, placer, pointed_thing)
|
||||||
return
|
if minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
elseif minetest.is_creative_enabled(placer:get_player_name()) then
|
|
||||||
return pickblock(itemstack, placer, pointed_thing)
|
return pickblock(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# textdomain: vl_pickblock
|
|
||||||
@1 is on slot @2=
|
|
|
@ -1,3 +1,3 @@
|
||||||
name = vl_pickblock
|
name = vl_pickblock
|
||||||
description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.
|
description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.
|
||||||
depeds = mcl_util, mcl_colors, mcl_title
|
depends = mcl_util, mcl_meshhand
|
||||||
|
|
Loading…
Reference in a new issue