← Documentation Home

LunarBasic Language Reference

This guide explains the main parts of the LunarBasic language in a simple, beginner-friendly way.

Use the topics below to learn the basics first, then explore statements, functions, and expressions as you build more advanced programs.

Back to Welcome


Start Here

  • Arrays - Learn what arrays are, how to declare them with Dim, and how to read and write elements with indexes.
  • Source Files, Continuations, and Comments - Learn how LunarBasic joins lines with _, ignores blank lines, and handles apostrophe and Rem comments.
  • Names and Values - Learn about identifiers, numbers, strings, booleans, and the basic coordinate rules used by the runtime.
  • Operators and Keywords - See the punctuation, operators, and reserved words the language currently recognizes.

Working with Programs

You can combine these core topics. For example, a custom type can include array fields:

Type Player
    Field InventorySlots(8) As Integer
End Type

Dim p As Player
p = New Player
p.InventorySlots[0] = 3

See Types and Objects for object syntax and Arrays for indexing and length helpers such as ArrayLen.

  • Imports - Learn how to include other LunarBasic source files with Import.
  • System Functions - Discover built-in runtime functions, helpers, and constants such as Graphics, Flip, DrawText, KeyDown, and text input helpers like GetTextInput$.
  • Program Shape and Statements - Understand what a LunarBasic program is made of and which top-level statements are currently supported.
  • Types and Objects - Learn how to declare `Type` blocks, allocate objects with `New`, and access fields with `.` or `\`.
  • Variables, Constants, and Assignment - Learn how Const, Dim, and assignment statements are written.
  • Labels and Goto - Learn how labels work, where Goto is allowed, and how label scope is checked.

Control Flow and Routines

Expressions and Troubleshooting

  • Expressions - Covers calls, member access, indexing, unary operators, binary operators, and precedence.
  • Errors and Current Support - A practical summary of common parser errors and what the language currently supports.

Tip for New Users

If you are just getting started, read the pages in this order:

  • Arrays
  • Source Files and Comments
  • Names and Values
  • Imports
  • System Functions
  • Types and Objects
  • Variables, Constants, and Assignment
  • Control Flow
  • Functions, Subs, and Return
  • Expressions