Open Fr-Dae opened 8 months ago
i have remplace space by tabulation, to respect coding normes 4 spaces for 1 tab
why not use survey instead?
why not use survey instead?
sorry i don't understand you question
for exemple, this is the python script made by pirus and modified by @Cediner fork of @puruscor work
// A clay differ bot, digs ball-clay from the selected area and puts it in the clay stockpiles in the selected area
// Made by Purus Cor to demonstrate usage of PBot API
// For more information about API, join Purus Pasta discord
// To suggest features into API, suggest them in discord
// Import required Java packages
const ui = Java.type('haven.purus.pbot.PBotAPI').ui();
const PBotUtils = Java.type("haven.purus.pbot.PBotUtils");
const PBotCharacterAPI = Java.type("haven.purus.pbot.PBotCharacterAPI");
const PBotGobAPI = Java.type("haven.purus.pbot.PBotGobAPI");
const PBotWindowAPI = Java.type("haven.purus.pbot.PBotWindowAPI");
// Create a window for the bot and add a start button
const window = PBotUtils.PBotWindow(ui, "Clay Digger", 50, 110, ScriptID);
const startBtn = window.addButton("startBtnCb", "Start", 100, 5, 5);
// Change the start button's color
startBtn.changeColor(255, 200, 255);
// Initialize stop flag
let stop = false;
// Callback function for start button click event
const startBtnCb = () => {
let clayDug = 0;
startBtn.destroy();
PBotUtils.sysMsg(ui, "First, select area to dig ball clay from!");
PBotUtils.selectArea(ui);
const aCoordDig = PBotUtils.getSelectedAreaA();
const bCoordDig = PBotUtils.getSelectedAreaB();
let clayTiles = [];
const maxX = Math.max(aCoordDig.x, bCoordDig.x);
const minX = Math.min(aCoordDig.x, bCoordDig.x);
const maxY = Math.max(aCoordDig.y, bCoordDig.y);
const minY = Math.min(aCoordDig.y, bCoordDig.y);
console.log(maxX + " ja " + minX + " JA " + maxY + " ja " + minY);
for (let i = minY; i < maxY; i += 11) {
for (let j = minX; j < maxX; j += 11) {
// Add shallow water tiles into the claytile list
if (PBotUtils.tileResnameAt(ui, j, i) === "gfx/tiles/water" || PBotUtils.tileResnameAt(ui, j, i) === "gfx/tiles/owater") {
clayTiles.push({ x: j, y: i });
}
}
}
PBotUtils.sysMsg(ui, "Second, select area with stockpiles!");
PBotUtils.selectArea(ui);
let stockpiles = [];
const gobs = PBotUtils.gobsInArea(ui, PBotUtils.getSelectedAreaA(), PBotUtils.getSelectedAreaB());
for (let i = 0; i < gobs.size(); i++) {
if (gobs[i].getResname() === "gfx/terobjs/stockpile-clay") stockpiles.push(gobs[i]);
}
while (!shouldStop()) {
// Dig until inventory full or out of claytiles
if (clayTiles.length === 0) {
PBotUtils.sysMsg(ui, "Out of tiles to dig clay from!");
stop = true;
break;
}
while (clayTiles.length > 0 && PBotUtils.playerInventory(ui).freeSlotsInv() > 1 && !shouldStop()) {
if (PBotCharacterAPI.getStamina(ui) < 70) PBotUtils.drink(ui, true);
PBotUtils.pfLeftClick(ui, clayTiles[0].x, clayTiles[0].y);
PBotCharacterAPI.doAct(ui, "dig");
PBotUtils.mapClick(ui, clayTiles[0].x, clayTiles[0].y, 1, 0);
PBotCharacterAPI.cancelAct(ui);
waitForIdle();
clayTiles.shift();
}
PBotUtils.sleep(100); // Wait a moment for all the clay to appear into the inventory
let clayInInv = PBotUtils.playerInventory(ui).getInventoryItemsByResnames(".*clay-ball").size();
console.log(clayInInv);
// Put clay in stockpiles or out of stockpiles
while (clayInInv > 0) {
if (stockpiles.length == 0) {
stop = true;
PBotUtils.sysMsg(ui, "Ran out of free clay stockpiles!");
break;
}
console.log(stockpiles[0]);
PBotUtils.pfRightClick(ui, stockpiles[0], 0);
PBotWindowAPI.waitForWindow(ui, "Stockpile");
const slots = PBotWindowAPI.getStockpileTotalCapacity(ui);
const used = PBotWindowAPI.getStockpileUsedCapacity(ui);
const count = Math.min(clayInInv, slots - used);
PBotWindowAPI.putItemFromInventoryToStockpile(ui, count);
clayDug += count;
if (count + used === slots) stockpiles.shift();
clayInInv -= count;
while (PBotUtils.playerInventory(ui).getInventoryItemsByResnames(".*clay-ball").size() != clayInInv) {
PBotUtils.sleep(25);
}
}
}
PBotUtils.sysMsg(ui, "Finished! Total clay dug: " + clayDug);
};
const shouldStop = () => {
return stop || window.closed();
};
function getPlayer() {
return PBotGobAPI.player(ui);
}
function waitForIdle() {
const tick = 75;
const maxWaitTicks = 4;
//PBotUtils.waitForHourglass(ui, tick * maxWaitTicks);
let idleCounter = maxWaitTicks;
while (idleCounter >= 0 && !shouldStop()) {
if (PBotUtils.getHourglass(ui) == -1 && !getPlayer().isMoving()) idleCounter--;
else idleCounter = maxWaitTicks;
PBotUtils.sleep(tick);
}
}
so, ok, i understand you don't like python. but rather than taking the time to redo a script from scratch, why not just add python to your launcher and import the existing scripts?
Hello, could you produce a script, which determines an area, in which to harvest clay (or acre clay) that automatically equips the shovel with the best shovel available.
here are the functions that are missing, you are free to code them as you wish, I lack the resources to write what is missing I've done a bit of python and json before, but never java, sorry if it's not great.