XaiJu
__ess__
__ess__

patreon


Cooking minigame script is now COMPLETED and available for download!

So the cooking minigame I was talking about and showed a preview of earlier is now completed and available for download in this post! 

How it works

So with this minigame the goal is to make sandwiches according to customers orders. The orders are notes with each ingredient in the order they should be added to the plate. You drag and drop and ingredient to the plate, which will cause a new draggable ingredient to spawn on the plate.

Once you're done with the order, you click on the order note it belongs to. If the ingredients are correct, the order note will disappear and a notification will appear saying "correct order".

If it's instead incorrect, a notification will tell you so and you have to correct it by removing ingredients by dragging them to the trash and then adding the correct ones.

When an order is completed, another one will spawn in its place according to a randomized timer which is intended to make it seem like some time pass between new orders.

There's a shift timer that shows how much time there is left on the current shift. Once the time is up, no new order will spawn anymore, but you are free to finish up the orders that are left.

There's also a money counter that will add $15 every time an order is completed. But you can of course customize that and anything else.

You can then use this script as a base and expand with further functionality if you want.

The code

The code has been commented to help you out with what everything does.

It contains a function that generates orders, called "generate_orders". This will populate a dictionary with an order-number and ingredients that goes with it. You specify the amount of orders that should be generated and the max and min ingredients an order is allowed to have. The function will then pick a random number between so each order will have a random number of ingredients.

This function should be called before showing the minigame screen to the player. An example is shown in the script.rpy file in the start label.

Drag and drop ingredients

The ingredients are drag and drop objects created with Python and have been added to a drag group. The drag group has then been added to the minigame screen (cooking_minigame). These are defined as global variables at the bottom of the script together with the other global variables.

They contain a function triggered when dropped (ingredient_drop) which checks if the drag has been dropped on the plate. If it has then it creates a new drag of the same type and adds it on top of the plate while the original snaps back to its original location.

These plated ingredients are also drags which can be dragged to the trash if added by mistake. The function that controls this is added to the drags spawned in the "ingredient_drop" function (dragged = ingredient_drag).

Using the script in your own project

To use the script in your own project you can copy the cooking_game.rpy file and add it to your projects script files.

That's about it for now. You can download the script below. If you're wondering something about it or if it's not working as expected you can leave a comment below.

Enjoy!

Comments

I was thinking of making a drag and drop mini game involving chocolate but couldn't find a tutorial or anything like it -- then I was stalking your patreon (from Youtube) and saw this!!! This is exactly the mechanic I was looking for LOL. I couldn't even put it into words LOL. Thank you so much Ess!!!

VeryFatCat

Hello! Well, the only way for the script to know if the ingredients are correct is to click on an order note. This triggers the function "check_order" which checks the ingredients placed on the plate. If the ingredients are correct, the drag group that contains the ingredients is emptied and therefore the images on the plate disappears. This is so the next order can be completed. There's no time to show another image after clicking the order note.

Sara

I'm making a game jam game, and this was exactly what i was looking for! thank you so much! question, if you have a moment: is there a way to change the final image of the (in this case, sandwich) once all of the ingredients are added?

Lady Goggles


More Creators