Getting Ready to Learn Lua Step-By-Step

This entry is part 1 of 11 in the series Learning Lua Step-By-Step

Post Stastics

  • This post has 880 words.
  • Estimated read time is 4.19 minute(s).

This article is part of the Learning Lua Step-By-Step series. It covers the basics of setting up your Lua development environment and toolchain. This includes creating a “projects” directory and installing Git, Lua, and ZeroBrane Studio IDE (Integrated Development Environment) you will use for writing your Lua programs.

Note that the only required software is Lua itself. You can use Notepad on Windows, Text Pad on Mac, and Nano or GEdit on Linux. Or for that matter any Text editor you like. However, you cannot use a document editor like Microsoft Word or MS Office, Open Office, etc. These document editors place hidden formatting and control codes in your text. Lua (and almost all programming languages) will misinterpret this hidden data and it will cause errors in your programs. So only use an IDE or Text Editor for writing code!

If you want to use the setup I am using to write the tutorial series, then follow each step below. If you want a minimal setup and plan to use your favorite text editor or compatible IDE you already have installed, then skip to installing Lua. At the time of this writing, Lua 5.4 is the most recent. But any 5.x version should be fine.

Installing Git, Lua, and ZeroBrane Studio

Windows

  1. Install Git:
  • Go to the official Git website: https://git-scm.com/downloads
  • Click on the “Download” button and select the Windows version.
  • Run the downloaded installer and follow the on-screen instructions to complete the installation.
  1. Install Lua:
  • Go to the official Lua website: https://www.lua.org/download.html
  • Scroll down to the “Lua for Windows” section and click on the latest version.
  • Run the downloaded installer and follow the on-screen instructions to complete the installation.
  1. Create the Projects Directory:
  • Open File Explorer and navigate to your user directory (e.g., C:\Users\YourUsername).
  • Create a new folder called projects.
  • Inside the projects folder, create another folder called Lua.
  • Inside the Lua folder, create a final folder called tutorial.
  • This directory structure (projects/Lua/tutorial) will be your dedicated Lua project directory.
  1. Install ZeroBrane Studio:
  • Open a Git Bash or Command Prompt window.
  • Navigate to the C:\Program Files\Lua\tutorial directory using the cd command or File Explorer.
  • Run the following command to clone the ZeroBrane Studio repository:
    git clone https://github.com/pkulchenko/ZeroBraneStudio.git
  • Once the cloning process is complete, navigate to the ZeroBraneStudio directory:
    cd ZeroBraneStudio
  • To add ZeroBrane Studio to your system PATH, run the following command:
    setx PATH "%PATH%;%CD%"
  • This will add the current directory (where ZeroBrane Studio is located) to your system’s PATH, allowing you to run the zbstudio command from any directory.

macOS

  1. Install Git:
  • Open the Terminal application.
  • Run the following command to install Git using Homebrew (if you don’t have Homebrew installed, you can install it first):
    brew install git
  1. Install Lua:
  • Open the Terminal application.
  • Run the following command to install Lua using Homebrew:
    brew install lua
  1. Create the Projects Directory:
  • Open Finder and navigate to your user directory (e.g., /Users/YourUsername).
  • Create a new folder called projects.
  • Inside the projects folder, create another folder called Lua.
  • Inside the Lua folder, create a final folder called tutorial.
  • This directory structure (projects/Lua/tutorial) will be your dedicated Lua project directory.
  1. Install ZeroBrane Studio:
  • Open the Terminal application.
  • Navigate to the ~/ directory using the cd command.
  • Run the following command to clone the ZeroBrane Studio repository:
    git clone https://github.com/pkulchenko/ZeroBraneStudio.git
  • Once the cloning process is complete, navigate to the ZeroBraneStudio directory:
    cd ZeroBraneStudio
  • To add ZeroBrane Studio to your user’s PATH, run the following command:
    echo 'export PATH="$PATH:$HOME/projects/Lua/tutorial/ZeroBraneStudio"' >> ~/.bash_profile
  • This will add the current directory (where ZeroBrane Studio is located) to your user’s PATH, allowing you to run the zbstudio command from any directory.
  • Restart your terminal for the changes to take effect.

Linux (Ubuntu/Debian-based)

  1. Install Git:
  • Open the Terminal application.
  • Run the following command to install Git:
    sudo apt-get update sudo apt-get install git
  1. Install Lua:
  • Open the Terminal application.
  • Run the following command to install Lua:
    sudo apt-get update sudo apt-get install lua5.4
  1. Create the Projects Directory:
  • Open the Terminal application.
  • Run the following commands to create the project directory structure:
    cd ~ mkdir -p projects/Lua/tutorial
  • This will create the projects/Lua/tutorial directory in your user’s home directory.
  1. Install ZeroBrane Studio:
  • Open the Terminal application.
  • Navigate to the ~/ directory using the cd command.
  • Run the following command to clone the ZeroBrane Studio repository:
    git clone https://github.com/pkulchenko/ZeroBraneStudio.git
  • Once the cloning process is complete, navigate to the ZeroBraneStudio directory:
    cd ZeroBraneStudio
  • To add ZeroBrane Studio to your user’s PATH, run the following command:
    echo 'export PATH="$PATH:$HOME/projects/Lua/tutorial/ZeroBraneStudio"' >> ~/.bashrc
  • This will add the current directory (where ZeroBrane Studio is located) to your user’s PATH, allowing you to run the zbstudio command from any directory.
  • Restart your terminal for the changes to take effect.

After completing these steps, you should have Git, Lua, and ZeroBrane Studio installed on your system, and your Lua project directory should be set up as projects/Lua/tutorial. You can now start using these tools to learn and practice Lua programming.

Series NavigationLearning Lua Step-By=Step >>

Leave a Reply

Your email address will not be published. Required fields are marked *