(Request) Chest script help
-
if (mc.currentScreen instanceof GuiContainer && mc.thePlayer.openContainer.getLowerChestInventory().getDisplayName().getUnformattedText().contains("Chest")) {
for (i = 27; i < 65; i++) { mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, i, 0, 1, mc.thePlayer)
Above is my code
Essentially, what it does is move items from inventory to chest. I'm new to scripting this stuff is very complex to understand.
Problems:-
When item is moved from inventory to chest it just appears back in inventory (im thinking problem is mode in windowclick but not sure, what other mode to use)
-
Adding a delay for statement, make it so each item move at a delay
if anyone can help me it'll be wonderful i've been struggling for hours.
-
-
I use core lib
-
@hookie Since noone replied, I'll help you.
Lets start with the simple one, the delay.
You can create a MSTimer instance and check if .hasTimePassed(delay)
///api_version=2 (script = registerScript({ name: "Script", authors: ["Author"], version: "1.0" })).import("Core.lib"); module = { onUpdate: function () { if (timer.hasTimePassed(1000)) { dosomething(); timer.reset(); } } } timer = new MSTimer();
For inventory interactions, you should debug what original packet sends and then try to replicate it.
onPacket: function (e) { if (e.getPacket() instanceof C0EPacketClickWindow) { p = e.getPacket(); print(p.getMode(), p.getSlotId(), p.getUsedButton()); } }
-
@czechhek
i'm very grateful bro, the packet debug has been very convenient to me and timer you've made it very explicable you've been a big help but one problem remains.In this video i've set the script to move the last slot in inventory into the chest and remain there but for some reason it doesn't stay there
I use (mc.thePlayer.inventoryContainer.windowId for window id, slot 64 for last slot in inventory, left mouse click 0, and mode 1, mc.thePlayer)
-
@czechhek
i can only move stuff out of chest but not into chest -
@hookie If you send completely same packets, there is no way that it won't work.
-
I just found out it's because it was using the wrong window id, thank you for being there when i needed you, appreciate it brother.
mc.thePlayer.openContainer.windowId is correct one
not
mc.thePlayer.inventoryContainer.windowId