mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 07:21:51 +00:00
fix middle click on access panel
This commit is contained in:
parent
1040a3a183
commit
047f050364
4 changed files with 34 additions and 5 deletions
|
|
@ -6,13 +6,18 @@ function on_hud_open()
|
||||||
base_util.drop_from_slot(invid, 0, mode)
|
base_util.drop_from_slot(invid, 0, mode)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
events.on("core:access_panel_slot_middle_click", function(itemid)
|
||||||
|
local exc_invid = hud.get_exchange_inventory()
|
||||||
|
inventory.set(exc_invid, 0, itemid, item.stack_size(itemid))
|
||||||
|
end)
|
||||||
|
|
||||||
events.on("core:slot_middle_click", function(invid, slot)
|
events.on("core:slot_middle_click", function(invid, slot)
|
||||||
if not player.is_infinite_items(hud.get_player()) then
|
if not player.is_infinite_items(hud.get_player()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local itemid = inventory.get(invid, slot)
|
|
||||||
local exc_invid = hud.get_exchange_inventory()
|
local exc_invid = hud.get_exchange_inventory()
|
||||||
local exc_itemid = inventory.get(exc_invid, 0)
|
local exc_itemid = inventory.get(exc_invid, 0)
|
||||||
|
local itemid = inventory.get(invid, slot)
|
||||||
if itemid == 0 then
|
if itemid == 0 then
|
||||||
if exc_itemid ~= 0 then
|
if exc_itemid ~= 0 then
|
||||||
local stack_size = item.stack_size(exc_itemid)
|
local stack_size = item.stack_size(exc_itemid)
|
||||||
|
|
@ -22,6 +27,11 @@ function on_hud_open()
|
||||||
if exc_itemid == 0 then
|
if exc_itemid == 0 then
|
||||||
local stack_size = item.stack_size(itemid)
|
local stack_size = item.stack_size(itemid)
|
||||||
inventory.set(exc_invid, 0, itemid, stack_size)
|
inventory.set(exc_invid, 0, itemid, stack_size)
|
||||||
|
else
|
||||||
|
if exc_itemid == itemid then
|
||||||
|
local stack_size = item.stack_size(exc_itemid)
|
||||||
|
inventory.set(invid, slot, exc_itemid, stack_size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "InventoryView.hpp"
|
#include "InventoryView.hpp"
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <iostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "assets/Assets.hpp"
|
#include "assets/Assets.hpp"
|
||||||
|
|
@ -501,10 +502,14 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotView::performMiddleClick(ItemStack& stack, ItemStack& grabbed) {
|
void SlotView::performMiddleClick(ItemStack& stack, ItemStack& grabbed) {
|
||||||
scripting::on_slot_middle_click(
|
if (layout.itemSource) {
|
||||||
inventoryId,
|
scripting::on_access_panel_slot_middle_click(stack.getItemId());
|
||||||
layout.index
|
} else {
|
||||||
);
|
scripting::on_slot_middle_click(
|
||||||
|
inventoryId,
|
||||||
|
layout.index
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlotView::clicked(Mousecode button) {
|
void SlotView::clicked(Mousecode button) {
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ namespace scripting {
|
||||||
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_slot_middle_click(int invid, int slot);
|
||||||
|
void on_access_panel_slot_middle_click(const itemid_t itemid);
|
||||||
|
|
||||||
void on_player_tick(Player* player, int tps);
|
void on_player_tick(Player* player, int tps);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "lua/libs/api_lua.hpp"
|
#include "lua/libs/api_lua.hpp"
|
||||||
#include "lua/lua_engine.hpp"
|
#include "lua/lua_engine.hpp"
|
||||||
#include "scripting.hpp"
|
#include "scripting.hpp"
|
||||||
|
#include "typedefs.hpp"
|
||||||
|
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
|
|
@ -123,6 +124,18 @@ void scripting::on_slot_middle_click(int invid, int slot) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scripting::on_access_panel_slot_middle_click(const itemid_t itemid) {
|
||||||
|
auto L = lua::get_main_state();
|
||||||
|
lua::emit_event(
|
||||||
|
L,
|
||||||
|
"core:access_panel_slot_middle_click",
|
||||||
|
[&](lua::State* L) {
|
||||||
|
lua::pushinteger(L, itemid);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
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