mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 07:21:51 +00:00
fix p.6
This commit is contained in:
parent
cedeaa68ad
commit
1040a3a183
4 changed files with 40 additions and 10 deletions
|
|
@ -5,6 +5,27 @@ function on_hud_open()
|
||||||
local invid = hud.get_exchange_inventory()
|
local invid = hud.get_exchange_inventory()
|
||||||
base_util.drop_from_slot(invid, 0, mode)
|
base_util.drop_from_slot(invid, 0, mode)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
events.on("core:slot_middle_click", function(invid, slot)
|
||||||
|
if not player.is_infinite_items(hud.get_player()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local itemid = inventory.get(invid, slot)
|
||||||
|
local exc_invid = hud.get_exchange_inventory()
|
||||||
|
local exc_itemid = inventory.get(exc_invid, 0)
|
||||||
|
if itemid == 0 then
|
||||||
|
if exc_itemid ~= 0 then
|
||||||
|
local stack_size = item.stack_size(exc_itemid)
|
||||||
|
inventory.set(invid, slot, exc_itemid, stack_size)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if exc_itemid == 0 then
|
||||||
|
local stack_size = item.stack_size(itemid)
|
||||||
|
inventory.set(exc_invid, 0, itemid, stack_size)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
input.add_callback("player.drop", function()
|
input.add_callback("player.drop", function()
|
||||||
if hud.is_paused() or hud.is_inventory_open() then
|
if hud.is_paused() or hud.is_inventory_open() then
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -501,16 +501,10 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotView::performMiddleClick(ItemStack& stack, ItemStack& grabbed) {
|
void SlotView::performMiddleClick(ItemStack& stack, ItemStack& grabbed) {
|
||||||
auto indices = *content->getIndices();
|
scripting::on_slot_middle_click(
|
||||||
if (!grabbed.isEmpty()) {
|
inventoryId,
|
||||||
if (stack.isEmpty()) {
|
layout.index
|
||||||
stack.set(grabbed);
|
);
|
||||||
stack.maximizeCount(indices);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
grabbed.set(stack);
|
|
||||||
grabbed.maximizeCount(indices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotView::clicked(Mousecode button) {
|
void SlotView::clicked(Mousecode button) {
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ namespace scripting {
|
||||||
void on_inventory_closed(const Player* player, const Inventory& inventory);
|
void on_inventory_closed(const Player* player, const Inventory& inventory);
|
||||||
void on_inventory_interact(int invid, int slot, int action, int mode);
|
void on_inventory_interact(int invid, int slot, int action, int mode);
|
||||||
|
|
||||||
|
void on_slot_middle_click(int invid, int slot);
|
||||||
|
|
||||||
void on_player_tick(Player* player, int tps);
|
void on_player_tick(Player* player, int tps);
|
||||||
|
|
||||||
/// @brief Called on RMB click with the item selected
|
/// @brief Called on RMB click with the item selected
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,19 @@ void scripting::on_inventory_interact(int invid, int slot, int action, int mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scripting::on_slot_middle_click(int invid, int slot) {
|
||||||
|
auto L = lua::get_main_state();
|
||||||
|
lua::emit_event(
|
||||||
|
L,
|
||||||
|
"core:slot_middle_click",
|
||||||
|
[&](lua::State* L) {
|
||||||
|
lua::pushinteger(L, invid);
|
||||||
|
lua::pushinteger(L, slot);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void scripting::load_hud_script(
|
void scripting::load_hud_script(
|
||||||
const scriptenv& senv,
|
const scriptenv& senv,
|
||||||
const std::string& packid,
|
const std::string& packid,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue