Elune
A downloadable tool
Elune is a domain-specific language (DSL) created for the purpose of developing game modifications; it was produced as the subject of my degree's dissertation/final year research project.
Elune is a dynamically typed language, which primarily aims to address the shortcomings of the most dominant programming language currently used for this purpose — Lua. The syntax takes inspiration from Python and C-based languages, and thus aims to follow more standard programming language conventions (e.g. C-style for loops and zero indexing).
Details
The language is made up of several components:
- A grammar defined in an ANTLR g4 format.
- A translator/compiler written in Java that translates the Elune code into the target language.
- A template that defines the output of the translation, which makes use of the StringTemplate template engine. Currently, the only existing template is for Lua, as there are some aspects of the translator that are currently hard-coded which would first need to be abstracted in order to allow for it to be retargetted to other languages.
- Libraries, which provide additional functionality.
A noteworthy library is the Generic API library that was created in order to try and generalise APIs across games. The idea is that a single API Dispatcher exists to handle interaction with the game's API, which connects to an API Adaptor that is handwritten to needs of each game.
For instance, the call:
C_Calendar.GetNumInvites()
in the World of Warcraft API (https://wowpedia.fandom.com/wiki/API_C_Calendar.GetNumInvites) would become:
wow:get("numInvites")
This feature would likely be the primary focus of any future work, since the API and its lack of documentation was by far the most common complaint I heard from modders when performing my research for this project.
GitHub
https://github.com/DanBest21/elune
Acknowledgements
I would like to thank my supervisor Dr Julian Rathke for all his help and support on this project. I would also like to thank Terence Parr for the ANTLR (https://www.antlr.org/) and StringTemplate (https://www.stringtemplate.org/) tools, which were instrumental to this project's success. Finally, I would like to credit Leafo's MoonScript (https://moonscript.org/), which I took inspiration from when designing the grammar.
Download
Install instructions
The attached zip file contains the following contents:
- The Elune.jar translator executable file.
- The Elune.g4 grammar file, which was used to produce the syntax of Elune. It can also be used as pseudo documentation to the syntax of the language (although in the future I aim to include a formal definition).
- The LuaTemplate.stg template file, which shows the specific Lua translations, but can also be used to infer a list of the required templates for the translator.
- Elune Source Files:
- CalendarCounter.elu — A basic example of an addon written for World of Warcraft.
- lib/std elu — Elune's standard library.
- lib/maths.elu — A library containing mathematical functions.
- lib/game.elu — The API dispatcher.
- lib/wow.elu — An incomplete example of an API adaptor written for World of Warcraft.
In order to run the translator, use the following command:
java -jar Elune.jar <source_file> <output_path> <language> <continue_keyword_toggle> <imports_toggle>
where:
- <source_file> is the .elu file that you want to translate.
- <output_path> is the directory you wish the translated file to be generated at.
- <language> is the programming language you desire the file to be translated to (currently only lua will work).
- <continue_keyword_toggle> can be toggled off, which will disable the continue keyword from working in the language, since Lua in some games does not allow for the use of labels.
- <imports_toggle> can be toggled off, which will disable the ability to import libraries, since Lua in some game does not allow for the use of the require keyword.
Leave a comment
Log in with itch.io to leave a comment.