mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-15 03:23:22 +08:00
JS: 食材加工添加回收 (#2287)
This commit is contained in:
@@ -183,10 +183,14 @@ function recognizeImage(templatePath, xMin, yMin, width, height, timeout = 2000)
|
||||
try {
|
||||
let template = file.ReadImageMatSync(templatePath);
|
||||
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
||||
let result = captureGameRegion().find(recognitionObject);
|
||||
let ra = captureGameRegion();
|
||||
let result = ra.find(recognitionObject);
|
||||
template.dispose();
|
||||
ra.dispose();
|
||||
if (result.isExist()) {
|
||||
return { success: true, x: result.x, y: result.y, width: result.width, height: result.height };
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
log.error(`识别图像时发生异常: ${error.message}`);
|
||||
return null;
|
||||
@@ -213,6 +217,7 @@ function performOcr(targetText, xRange, yRange, tolerance, timeout = 2000) {
|
||||
adjustedXMin, adjustedYMin,
|
||||
adjustedXMax - adjustedXMin, adjustedYMax - adjustedYMin
|
||||
));
|
||||
ra.dispose();
|
||||
|
||||
// 遍历识别结果,检查是否找到目标文本
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
@@ -326,6 +331,7 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames)
|
||||
async function checkNpcAndFAlignment(npcName, fDialogueRo) {
|
||||
let ra = captureGameRegion();
|
||||
let fRes = ra.find(fDialogueRo);
|
||||
ra.dispose();
|
||||
if (!fRes.isExist()) {
|
||||
let f_attempts = null; // 初始化尝试次数
|
||||
while (f_attempts < 5) { // 最多尝试 4 次
|
||||
@@ -352,6 +358,7 @@ async function checkNpcAndFAlignment(npcName, fDialogueRo) {
|
||||
// 检查是否找到 F 图标
|
||||
ra = captureGameRegion();
|
||||
fRes = ra.find(fDialogueRo); // 重新查找 F 图标
|
||||
ra.dispose();
|
||||
if (fRes.isExist()) {
|
||||
log.info("找到 F 图标");
|
||||
break; // 找到后退出循环
|
||||
@@ -410,6 +417,7 @@ async function checkNpcAndFAlignment(npcName, fDialogueRo) {
|
||||
// 重新检查 F 图标和 NPC 名称是否对齐
|
||||
let ra = captureGameRegion();
|
||||
let fRes = ra.find(fDialogueRo);
|
||||
ra.dispose();
|
||||
if (!fRes.isExist()) {
|
||||
log.warn("未找到 F 图标");
|
||||
continue; // 如果未找到 F 图标,继续下一次循环
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "选择购买食材OCR",
|
||||
"version": "1.30516",
|
||||
"version": "1.4",
|
||||
"description": "至少需要0.48版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买。\nv1.30513修复循环套叠,优化F未识别后的尝试方案。",
|
||||
"authors": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user