Back to list

The Power of GamecraftScripting,

Or Why You Should Learn Python for Gamecraft

You should learn Python.

If you're not interested in learning a programming language, you should reconsider. Computers are steadily taking over every industry (that they haven't already taken over), and their potential doesn't stop at work. To completely unlock the potential of computers, you have to be able to tell the computer exactly what you want it to do. Running a program restricts you to existing computer applications and to existing computer potential, but a computer language removes that restriction. With that sort of power at your fingertips, you can do anything from making a rocket fly (model and full-scale) to hacking the Pentagon (not recommended) to annoying your siblings (true story). Python is one of the easiest programming languages to learn, which makes it a great first language to grasp the basics of programming. In fact, it's the first programming language I learned. Python is also the second most popular programming language, according to StackOverflow's latest developer survey. The most popular language, according to that survey, is JavaScript, but that's a strange beast that I try to stay away from. If work and play aren't enough to make you interested in learning Python, I'm not sure what is.

GamecraftScripting provides Python integration for Gamecraft using IronPython, allowing for Python code to use C# APIs like the GamecraftModdingAPI. That means you can write a Python script to do anything that mods like Pixi and ExtraCommands do. I usually use Python to test my C# mods before I release them publicly, so I call tell you first-hand that Python is just as powerful as C# without its complexity. I've also used GamecraftScripting to prototype functionality, since Python is easy to write. But you don't even need to know C# to write a Python script for Gamecraft.

The abilities that Python offers don't end at mods, either. I've heard a few people expressing the desire for actual variables in Gamecraft, which can be done with one line of code in Python. You can run a Python script to do things that in-game logic gates can't accomplish on their own. Python scripts can even interface seamlessly with signals and wires using the GamecraftModdingAPI, and you can run a script from any console block for seamless integration. This can be a powerful tool for gamemakers, with uses from teleporting a player to another player's location to creating automatically-generated game sections. Gamecraft circuit system is Turing complete (just like PowerPoint!), but it's limited to accessing in-game information. But you could write a script to access the internet or to play a minigame using a level stored as a text file! If you're feeling brave, you could even pass that information as data to be processed by Gamecraft logic circuits. As a real-world example, I'm currently working on adding animations into a game using a combination of in-game logic, Pixi and Python to make it work. The power of programming offers infinite capabilities for gamemakers and tinkerers alike.

Usually, when writing code, I use an Integrated Development Environment (IDE) to make the task easier. An IDE provides the user with an all-in-one solution to program and run code with sprinkles on top, like auto-complete and spell-checking. Recently, I added some similar functionality to GamecraftScripting. Using the ToggleIDE command, in modded Gamecraft, GamecraftScripting will enable some of the features an IDE would normally have. The ToggleIDE functionality is still a work in progress, but right now it offers improved command auto-complete but you'll still need to use an external text-editor to write your code. In the future, hopefully I can expand its functionality to editing text directly in Gamecraft, to make it a truly integrated IDE experience. Once you've developed a script that you want to include with your game, there's also a tool to package the Python code into the game. This tool simplifies distribution so you don't have to worry about getting another file to players somehow. Using built-in tools, GamecraftScripting can make learning Python easy by replacing the IDE with the familiarity of Gamecraft and your preferred text editor.

Now that your head is bursting with the amazing possibilities that Python and GamecraftScripting offer, let me bring you back to Earth with some of its limitations. GamecraftScripting's Python support is held back by IronPython's development speed, so GamecraftScripting only supports Python2.7, which is officially unsupported by the Python Software Foundation as of January 2020, unfortunately. This shouldn't affect you, but you'll have to avoid tutorials and functionality for Python3 and instead seek out stuff that supports Python2.7 versions. Hopefully in the near future I'll be able to upgrade to IronPython3 to remove this limitation. The other notable issue with GamecraftScripting's Python is it can't use most external Python libraries. All of Python's standard libraries are supported, but a lot of Python's amazing package library doesn't like Python running in Gamecraft (or any other C# app that uses IronPython). So far I haven't had any problems with those limitations, so I'm sure you won't be limited by them either.

So what are you waiting for? Python and GamecraftScripting are out there, waiting for you to dive in and learn something that you'll be able to use for years to come. If you're lucky, you'll even have make some cool Gamecraft creations while you're at it!