FSUIPC: Lua Tutorial
For Microsoft Flight Simulator and GoFlight Equipment

 

Home
About Lua
Executing Code
Binary
Hexadecimal
Bits & Bytes
Memory Offsets
Variables
The Code
The Editor
Get Started
FlightSim
Cleaning Up
Assignments

 

Welcome to the FSUIPC: Lua Tutorial

At this point I need to make certain assumptions.

  1. That you know what FSUIPC is and that your copy is REGISTERED.
  2. That you have the latest version.
  3. That you know what Microsoft's Flight Simulator is and whether it's FS2004(FS9) or FSX.  Because that determines if you have FSUIPC 3 or 4.
  4. That you know how the world works in regards to downloading, saving, unzipping files.
  5. The biggest assumption is that you know what you want Lua to do for you.

    At this point, you're asking yourself... "How can I know what I want, if I don't know what Lua can do?"  To answer that, I'll say, there is very little Lua can not do. It can't read your mind, but it can control your sim, environment and equipment.

Let's Prepare

    The first thing you will need is a copy of the FSUIPC: Lua Reference Library. You can obtain the latest documentation HERE. It it suggested you print it out for long-term use. Grab a pad of Post-its so you can "tab" the various sections for quick page turning.

    The second thing is a list of Memory Offsets. If you downloaded the version 3 FSUIPC documentation, you will need Version 4. So in the same place as the other docs, get the FSUIPC4 documentation. In that is a file named "FSUIPC4 Offsets Status.pdf".  You don't have to print it out, but I recommend it.

    This third item is optional, but I highly recommend it. It's FSInterrogate2std. You can get it from the FSUIPC SDK (Software Development Kit) located HERE. Scroll down to the FS2004 section and click on FSUIPC_SDK

     Okay, now that we have our "paperwork", we need an "Editor". There is a application called "LuaEdit" located HERESo far I have found one problem with it. It DELETES my working directory (which happens to be my fs/modules folder) where I save my Lua files.  So keep an eye on that!!!!!  Or you may use notepad.exe. Any text editor will do as long as you can save without ANY formatting. I'm using Notepad++. If you want more about editors see Chapter 9

    So now we have a reference, an interrogator, and editor... what else? How about knowing how FSUIPC and Lua relate to each other?  FSUIPC is just a platform which can execute Lua code. You don't need another program running like GFDisplay or GFKeys. Your Lua script is executed by FSUIPC, within FSUIPC!

A quick comment about fonts... I found a font called "Consolas". I like it for programming because its a fixed width font and slashes the zeros. If you want a copy, you may get it HERE

 

Terminology

    We also need to define some terms.  Using the proper terminology is vital to any operation.  If you tell a Sailor and a Marine to go secure a building, you will get VERY different results. The Sailor will just walk around and make sure the doors are locked. The Marine will bash their way in, waving his rifle, probably popping of a few rounds and shouting at everyone to get on the floor face down, arms behind them and will leave them on the floor in that position until support arrives.

    Now I don't know if I'm using the "proper" terminology compared to the rest of the Flight Sim community but what I use seems to be the most consistent. Besides, during this tutorial,  you only need to know what I'm talking about.

Controller:    This is a joystick or gaming device or GF-Module what what ever you use to press, push or switch, buttons, levers or any other physical gadget.

Module:         This is a more specific term of Controller. To me, a module is a GoFlight module. But it applies to any gadget that's small.

Function:        This is a feature found in an aircraft, Lights, Engines, Doors, Etc.  Functions are activated by the Controller just like, the Lights turned on when the switch is thrown.

Feature:           Another term for Function.

Assignments:    A link between a Function and a Control.  Controls are assigned Functions.  I try to avoid saying "functions are assigned controls" because we don't say "that light is turned on by that switch" we say "that switch turns on that light". It certainly is possible to assign more than one function to a control or to assigned several controls to the same function.  But to avoid confusion, I'll try to say "Function assigned to Control"

Buttons:        A device that send one signal when pressed.

Switches:        A Device that continuously send signals. There are several kinds of switches...  Single throw switches which are ON or OFF.  Three-way switches which send two signal, ON1-OFF-ON2. and Three-way switches that send three signals ON1-ON2-ON3.

Rotary:        It's a knob that turns to select different functions. This has one meaning but two ways to work.  In terms of GoFlight modules, this is just a fancy button. Normally rotaries send continuous signals.

Toggles:        A switch that acts like a button by snapping back to a default position.

Levers:        A physical device that does NOT snap into place, like a throttle. Some people call switches, levers. For clarification I don't.

Axis:        A computer term for joystick lever.

    So to help clarify, a function is assigned to a control.  Functions can be assigned to axis', switches, buttons and/or levers.

File:        Code or data stored on your hard drive.

Lua:        A programming language. C, C+, VB, VB.NET, Pascal, Basic... they are all programming languages.

Code:    Computer commands

Script:    Another term for code, typically referring to a file of code.

Lua file:    A file containing Lua code or script. AKA Lua Script.

So first, let's me discuss Lua and why we NEED it.

 


Written by
Joseph "Skittles" Cardana
skittles(at)anadrac.com
Updated: 2011-08-25 07:58