Supercharge your minigame experience!
Supercharge the minigame experience!
The latest builds of the Unscripted Extended Demo include a brand new minigame that challenges you to collect all of the coins and navigate to the exit with a series of commands, but did you know that you can take it up a notch and supercharge the minigame with Advanced Mode? Fear not; this devlog will show you some of the perks Advanced Mode has.
What even is advanced mode? 🤔
Advanced Mode is a special mode of the Unscripted minigame that lets you be more in creative in how you solve the puzzles by giving you the ability to write Python code that works with the game. You can take advantage of what Python has to offer with the official interface to access the minigame (API), Fira.
Awesome! How do I get started? 🤩
It’s easy to get started with the Advanced Mode of the minigame! Just go to Settings › Minigame and turn on Advanced Mode to get started. In the minigame settings, you can also open the folder where the Python scripts live and open the documentation that comes with the API.
When a minigame level appears, instead of seeing the buttons to control Masti’s movements, you’ll see a bigger version of the world with buttons in the toolbar to open the scripts folder, get help via the documentation, and run your Python script:
How do I write some code? 🛠
On the minigame screen, click “Open Folder” to open the Python scripts folder in the File Explorer on Windows, Finder on macOS, or your file browser of choice on Linux.
There will be several files for the minigame levels, each numbered by their level. The count starts at zero and increments by one for each level. If you’re unsure of what level you need to write a script for, check the title and level number of the current level you’re on in the minigame’s toolbar.
Each minigame level script comes preloaded with some template code to get you started. Namely, the game attempts to get the player’s information and the world from the minigame’s levels:
# Import the level information APIs. from uvn_fira.api import get_level_information, CSPlayer, CSWorld # Get all of the information for this particular level. game_player, game_world = get_level_information(0, fn_path=renpy.config.savedir + "/minigame/", exists=renpy.loadable, load=renpy.exports.file) # type: (CSPlayer, CSWorld)
In most cases, you should probably not remove the code from these files; otherwise, you may run into some problems when trying to get your player to move!
Solving the first puzzle 🙊
Now let’s get into writing some code to solve the first puzzle! There are two main objects we can currently work with:
game_player, which controls the player, and
game_world, which controls the world. Most of the time, you’ll just need to work with the
game_player object since you need to move the player and collect coins, but you can use
game_world to determine things about the world that may help you.
In the first puzzle, we need to move Masti to the exit at the end of the corridor. In the basic mode, you would need to press “Move east” four times and then press “Exit map”.
game_player has a function called
move that moves the player a given direction that is supplied as a parameter. The
exit function exits the map and also write the respective code for the minigame to read, so make sure that your scripts end with
game_player.exit()! With this knowledge, we can write the following code to achieve the same effect as before:
game_player.move("east") game_player.move("east") game_player.move("east") game_player.move("east") game_player.exit()
Great, we’ve written some code that works! Let’s take advantage of Python’s looping abilities with a
for-loop to run that same code four times:
for _ in range(4): game_player.move("east") game_player.exit()
Run it through the game, and keep experimenting with it to solve the puzzle.
Help! I’m stuck and my code’s not working 😫
If you get stuck, you can always make use of the documentation, which tries to be an informative source of what’s available to you. To access the documentation, you can click “Help” in the minigame toolbar, go to Help › Documentation in the game menu, or click “Open Documentation” in Settings › Minigame. You can also read the documentation on the website for the minigame’s source code: https://fira.marquiskurt.net/api/.
If you need some live help from fellow players or the development team, chat with us on Discord! We’d be more than happy to help you and look at your code. Here’s the invite link if you’re not in the server already: https://discord.gg/CXxnVhX.
Supercharge the coding experience 🚀
Now that you can write Python for the minigame, there are many ways that you can make the experience more comfortable for you as a developer! Here’s a great couple of notes to consider:
- The minigame’s API is available in the Python Package Index (PyPI), letting you install it to your computer or any Python environment just by running
pip install uvn_fira. This works great if you want to use tools like Poetry or
pipenvto create an environment for you to write your code in!
- The API works great with IDEs and text editor like PyCharm and Visual Studio Code! Documentation shows up right in the text editor of your choice and can help you write great code like a champ. 💪
- The API is open-source on GitHub! Check out the source code and learn more about how the minigame works in the backend to make better decisions on how to write your code. Find a bug and want to contribute? Fork the project and make a pull request 😁!
I hope you have fun playing around with what Python has to offer in the Advanced Mode of the minigame. Good luck; now go write some awesome Python code!
Leave a comment
Log in with itch.io to leave a comment.