mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
fix p.6
This commit is contained in:
parent
cedeaa68ad
commit
1040a3a183
4 changed files with 40 additions and 10 deletions
|
|
@ -501,16 +501,10 @@ void SlotView::performRightClick(ItemStack& stack, ItemStack& grabbed) {
|
|||
}
|
||||
|
||||
void SlotView::performMiddleClick(ItemStack& stack, ItemStack& grabbed) {
|
||||
auto indices = *content->getIndices();
|
||||
if (!grabbed.isEmpty()) {
|
||||
if (stack.isEmpty()) {
|
||||
stack.set(grabbed);
|
||||
stack.maximizeCount(indices);
|
||||
}
|
||||
return;
|
||||
}
|
||||
grabbed.set(stack);
|
||||
grabbed.maximizeCount(indices);
|
||||
scripting::on_slot_middle_click(
|
||||
inventoryId,
|
||||
layout.index
|
||||
);
|
||||
}
|
||||
|
||||
void SlotView::clicked(Mousecode button) {
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ namespace scripting {
|
|||
void on_inventory_closed(const Player* player, const Inventory& inventory);
|
||||
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);
|
||||
|
||||
/// @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(
|
||||
const scriptenv& senv,
|
||||
const std::string& packid,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue