Skip to content

Commit

Permalink
refactor: Update function descriptions and authors in functions.json
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkePilon committed Jul 28, 2024
1 parent 1f5311a commit 70b6e84
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 52 deletions.
52 changes: 32 additions & 20 deletions flow_functions/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"y": "text",
"z": "text"
},
"author": "Assistant"
"author": "AI model"
},
"craft_item": {
"name": "craft_item",
Expand All @@ -90,7 +90,7 @@
"hasInput": true,
"description": "Craft a specified amount of an item",
"input": { "itemName": "text", "amount": "number" },
"author": "Assistant"
"author": "AI model"
},
"equip_item": {
"name": "equip_item",
Expand All @@ -100,7 +100,7 @@
"hasInput": true,
"description": "Equip a specified item to a destination (e.g., 'hand')",
"input": { "itemName": "text", "destination": "text" },
"author": "Assistant"
"author": "AI model"
},
"look_at": {
"name": "look_at",
Expand All @@ -110,7 +110,7 @@
"hasInput": true,
"description": "Make the bot look at a specific coordinate",
"input": { "x": "number", "y": "number", "z": "number" },
"author": "Assistant"
"author": "AI model"
},
"eat_food": {
"name": "eat_food",
Expand All @@ -120,7 +120,7 @@
"hasInput": true,
"description": "Make the bot eat a specified food item",
"input": { "foodName": "text" },
"author": "Assistant"
"author": "AI model"
},
"attack_entity": {
"name": "attack_entity",
Expand All @@ -130,7 +130,7 @@
"hasInput": true,
"description": "Attack a specified entity or player within a given range",
"input": { "entityName": "text", "range": "number" },
"author": "Assistant"
"author": "AI model"
},
"collect_items": {
"name": "collect_items",
Expand All @@ -140,18 +140,26 @@
"hasInput": true,
"description": "Collect dropped items within a specified range",
"input": { "range": "number" },
"author": "Assistant",
"author": "AI model",
"badges": ["Not Working"]
},
"toggle_sneak": {
"name": "toggle_sneak",
"file": "toggle_sneak.js",
"id": "toggle_sneak",
"label": "Toggle Sneak",
"toggle_options": {
"name": "toggle_options",
"file": "toggle_options.js",
"id": "toggle_options",
"label": "Toggle Player Options",
"hasInput": true,
"description": "Toggle sneak mode on or off",
"input": { "sneak": "switch" },
"author": "Assistant"
"description": "Toggle player options on or off",
"input": {
"sneak": "switch",
"sprint": "switch",
"jump": "switch",
"forward": "switch",
"back": "switch",
"left": "switch",
"right": "switch"
},
"author": "AI model"
},
"use_block": {
"name": "use_block",
Expand All @@ -161,7 +169,7 @@
"hasInput": true,
"description": "Use (right-click) a block at a relative position",
"input": { "x": "number", "y": "number", "z": "number" },
"author": "Assistant"
"author": "AI model"
},
"place_block_nearby": {
"name": "place_block_nearby",
Expand All @@ -174,7 +182,7 @@
"blockName": "text",
"range": "number"
},
"author": "Assistant",
"author": "AI model",
"badges": ["Not Working"]
},
"smelt_item": {
Expand All @@ -184,8 +192,12 @@
"label": "Smelt Item",
"hasInput": true,
"description": "Smelt an item in a nearby furnace",
"input": { "itemName": "text", "fuelName": "text" },
"author": "Assistant"
"input": {
"itemName": "text",
"fuelName": "text",
"skip completion check": "switch"
},
"author": "AI model"
},
"drop_item": {
"name": "drop_item",
Expand All @@ -195,6 +207,6 @@
"hasInput": true,
"description": "Drop a specified amount of an item",
"input": { "itemName": "text", "amount": "number" },
"author": "Assistant"
"author": "AI model"
}
}
27 changes: 14 additions & 13 deletions flow_functions/smelt_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@ async function main(data) {
await furnaceBlock.putFuel(fuel.type, null, fuel.count);
await furnaceBlock.putInput(item.type, null, item.count);
console.log(`Started smelting ${itemName}`);

await new Promise((resolve) => {
furnaceBlock.on("update", () => {
if (furnaceBlock.slots[2]?.count === item.count) {
console.log("Smelting complete");
resolve();
}
if (!furnaceBlock.slots[1]?.count) {
if (!furnaceBlock.slots[0]?.count) {
console.log("Fuel depleted");
if (data["wait for completion"]) {
await new Promise((resolve) => {
furnaceBlock.on("update", () => {
if (furnaceBlock.slots[2]?.count === item.count) {
console.log("Smelting complete");
resolve();
}
}
if (!furnaceBlock.slots[1]?.count) {
if (!furnaceBlock.slots[0]?.count) {
console.log("Fuel depleted");
resolve();
}
}
});
});
});
const output = await furnaceBlock.takeOutput();
}

const output = await furnaceBlock.takeOutput();
await furnaceBlock.close();
console.log(`Finished smelting ${output.name}`);
} catch (error) {
Expand Down
19 changes: 19 additions & 0 deletions flow_functions/toggle_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// toggle_sneak.js
const { getBot } = require("../main.js");

async function main(data) {
const bot = getBot();
for (const key in data) {
try {
if (data.hasOwnProperty(key)) {
const value = data[key];
await bot.setControlState(key, value);
console.log(`Toggled ${key} to ${value}`);
}
} catch (error) {
console.error(`Error toggling ${key}`);
}
}
}

module.exports = { main };
17 changes: 0 additions & 17 deletions flow_functions/toggle_sneak.js

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/app/flow/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,9 @@ export default function Dashboard() {
<Button
variant="default"
size="sm"
onClick={(e) => {
onClick={async (e) => {
e.preventDefault();
addNode(nodeType);
await addNode(nodeType);
}}
>
Add Node
Expand Down

0 comments on commit 70b6e84

Please sign in to comment.