Megalo: Coding in RVT

  • Views Views: 51
  • Last updated Last updated:

  • This article is part of a series on


    Introduction to Megalo & RVT • Coding in RVT

    Common Practices • Optimization

    Common Practices • Optimization

    Using the ReachVariantTool (RVT) to code can be a somewhat confusing task for those unfamiliar with coding. RVT uses Bolt, a language derived from Lua, and not the Megalo language itself. Instead, the code written in Bolt is compiled and "translated" into Megalo. The tool itself offers a help tab, with documentation included, as well as a window to paste and type scripts into. However, there's a lot more to making a gametype script than reading some documentation and going from there.

    Source Code

    While RVT offers its own window for coding, many experienced gametype scripters will suggest to use an external program, such as Notepad++, to create a source code version of the scripts written. The script can then be copy-pasted into the window in RVT, and compiled to the gametype. The reasons for keeping a source code version of scripts are:
    • Preservation of comments and aliases
    When a script is compiled, any comments or aliases used are lost, even if the gametype is decompiled again. This makes it harder to organize code and figure out what it does when going back to it later.
    • Reusing scripts
    You've already made that script that turns holograms into suicide bombers, so why not just save it separately? There's no point in remaking it later and wasting time.
    • Sharing scripts
    Sharing is caring! If you made a script, and other people want to use it, it's far easier to hand them an isolated source code than to hand them a gametype and tell them to find it inside. Just make sure to get credited, and to credit others, if scripts are shared.

    Comments and Aliases

    Comments and aliases are used to help users in organizing and making notes on what certain aspects of their scripts do. The two function quite differently, yet also quite similarly.

    Comments are part of any coding language, and Bolt is no different. Using two dashes ( -- ) will "comment out" the rest of that one line of code, which means the compiler doesn't read it. This can be used to add comments after lines of code, or dedicate lines to comments for easier code organization. An example is shown below.

    Aliases are nicknames for variables, due to the lack of symbolic variables. Aliases can be declared at any point in the script, though if declared inside a block of code, the alias will not work outside of that block. Aliases are a great way to organize variables, since the nicknames can be easier to remember for temporary variables, or they can be used on variables to help in reading what a section of code does. Some examples are shown below.

    • Setting up Lua Language in Notepad++ Setting up Lua Language in Notepad++
    • Script example with comments and aliases Script example with comments and aliases
    • Another example from the same script Another example from the same script