kaplin86 Cocrea: https://cocrea.world/@Kaplin86
Hey guys! Welcome to kaplin’s cooking show! Today we are making AI Salesman Spice cookies!!
This delicious meal includes AI text generation and even a working selling system! Lets get started!
This dish requires basic knowledge on how to use the AI extension, here is a tutorial by Jamin on how to use ai hub extension.
AI Hub, GPT Chatbot in Your Scratch Game - Gandi IDE
AI Hub Extension is the generative AI tool center in Gandi IDE, providing you with AI technologies that can be used in Scratch games.
This tutorial is also recommended to be made in an EMPTY project before getting added/recreated in any games.
- Default Scratch Block (Baking Kit)
- Arkos Extension (Cinnamon)
- Syntactic Sugar Extension (Icing)
- AI Hub Extension (Dough)
Once you have all your ingredients in your kitchen, it should look like this.
Once you have your ingredients, we can begin mixing!!!
- Start by adding a “When green flag clicked” brand bowl. Here we are going to set all of the default info for our AI hub dough! You can freely edit this however you want, but it should end up looking something like this:
- Now that our dough has now been fully set up for proper baking, Add a “wait until touching mouse and mouse down” egg to your bowl.
- Now that we have that, lets finish our work on the dough! Cut the dough with “Assistant/AI” cookie cutters, if you want too you can add variable salt to help remember information such as the name for our batch of cookies!
- Here is a small trick that can make sure your ai dough is perfectly cooked to your liking! Use the “update background info” cookie cutter for our ai dough so we can start this trick. Then take out a edible ink list from the scratch baking kit, call it instructions, may even want to set it to “for this sprite only” , and put the reporter into the block.
- Now to finally fill out our instructions. Lets start off with giving the npc what items it can sell. Do something along the lines of: “Things you can sell: Great sword (30 currency) Ice wand (57 currency) arrow bundle (10 currency)”.
- Lets get straight to talking now. You could use something like WitCat’s Input Chocolate, But the budget i have wouldn’t allow that. So for now we are just going to be using the “Ask and wait” packets from the baking kit.
- Add a “Repeat Until” Brand mixer and put it into your “Green flag” brand bowl. You can make the condition for it whatever you like, i will go with pressing Q OR type “leave”.
Create another line that gives examples of the proper selling system, like: “To give players items, do <Item name> (currency), like ‘Here ya go! <great sword>(20)’ and ‘Deal! <ice wand>(50) “
To further make sure the ai will give the items add: “After you make a deal, if you dont give the item using <item name> (currency) you would have scammed the player and failed.”
Your final list should look like this:
First start the conversation by making the AI dough say hi, use this:
Test it out by running your project!
- Conversations? Yes please! So far we are making a somewhat simple AI Cookies, but we will soon make it AI salesman Spice Cookies!!! Add this simple line of code to make conversations work.
- Time to get real (er- i guess… get fake?)! Add a currency variable and items list. Add a If statement block after the “ask and wait” block. Inside your Arkos Extension Cinnamon, grab the “position of ___ in ___, start from ___” grinder to grind the cinnamon. You can also use the Arkos Blank Utility block to see if the message contains the “<” character, like this:
- You may have noticed thats something off, how are we going to get what the ai said? Move the “chat with ___:___ and wait” to a variable. To get the item that we purchased, we can use a combination of the “Position of” and syntactic sugar’s “Letters ___ to ___ in ___”. First we will get the item then currency. Dont forget to add 1 to the first “position of” to get the right places. Add a “Add ___ to [list]” block and put in the item finder:
- Now, lets do the same with currency, make sure to turn it into a negative using * -1! Copy the ‘Item Finder’ into a variable then swap all the “<” and “>” to “(“ and “)”
- To finish up our AI Salesman Spice Cookies dish, lets add some silverware to go with it. At the very top of your bowl, add “set currency to 300” and “delete all inventory”.
- Quick little bugfix before we go, to make sure the ai salesman knows how much currency you have, add this code inside the loop:
Now enjoy this freshly made Ai salesman spice cookies! Make sure to send this cooking guide to all your scratch friends (if you want)!!!!!
GOOD THINGS TO CHANGE
Some good things you can change to fit your project:
- The actual chat system. You can use witcat’s input extension to make working textboxes and then have a button to send messages.
- Response display. Using the Animated Text Extension, you can easily show what NPCs are saying
- Visuals. Make it so when the player clicks on the store, it opens up a GUI and the person starts talking.
- Instructions. If you want, you could tell the ai to “always try to make really high prices” inside the instructions, or the opposite.
- Personality. Similar to the last one, you can change the ai’s personality trait inside the “create a npc named ___” block.
Lazy? Here is a link to the project so you can remix it:
AI Salesman Template/Tutorial by @Kaplin86 /Scratch project hosted on Cocrea.
A VERY cool use of the ai hub extension :) Hosted on Cocrea.world, powered by Gandi IDE.
His name is mr. Sellington /\