### Execute script and observe output Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Example console output when running the local variable script. ```text lua.exe helloWorld.lua nil 3.14159 nil ``` -------------------------------- ### Hello World Lua Script Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/installation A simple script to verify the Lua interpreter installation. ```lua --- --- Simple Hello World Example to test the Lua Interpreter --- print("Hello World") ``` -------------------------------- ### Python Syntax Highlighting Source: https://jonathanturnock.github.io/civ-vi-modding/docs/reference Example of Python code block with syntax highlighting. ```python s = "Python syntax highlighting" print(s) ``` -------------------------------- ### Function Highlighting Example Source: https://jonathanturnock.github.io/civ-vi-modding/docs/reference A code block containing a function definition. ```javascript function highlightMe() { console.log('This line can be highlighted!'); } ``` -------------------------------- ### JavaScript Syntax Highlighting Source: https://jonathanturnock.github.io/civ-vi-modding/docs/reference Example of JavaScript code block with syntax highlighting. ```javascript var s = 'JavaScript syntax highlighting'; alert(s); ``` -------------------------------- ### Configure AppOptions.txt for FireTuner Source: https://jonathanturnock.github.io/civ-vi-modding/docs/fire-tuner Set FullScreen to 0 (windowed) and EnableTuner to 1 in AppOptions.txt to allow FireTuner to connect. ```ini ;0 : windowed, 1 : fullscreen, 2 : windowed with no title bar FullScreen 0 ... [Debug] ;Enable FireTuner. EnableTuner 1 ... ``` -------------------------------- ### Print Hello World from the FireTuner Lua Console Source: https://jonathanturnock.github.io/civ-vi-modding/docs/hello-world-lua-mod Paste this line into the FireTuner Lua Console to send 'Hello World from the Lua Console' to the Lua.log file located at %USERPROFILE%\Documents\My Games\Sid Meier's Civilization VI\Logs\Lua.log. ```Lua print("Hello World from the Lua Console") ``` -------------------------------- ### Print Hello World in FireTuner Lua Console Source: https://jonathanturnock.github.io/civ-vi-modding/docs/fire-tuner Execute this Lua command in the FireTuner console to print 'Hello World' in the running game. ```lua print("Hello World") ``` -------------------------------- ### HelloWorldMod .MODINFO File with InGameActions Source: https://jonathanturnock.github.io/civ-vi-modding/docs/hello-world-lua-mod The generated .MODINFO file for the HelloWorldMod. It contains the InGameActions section with AddGameplayScripts that loads HelloWorld.Lua, which is required for the script to run. ```XML Hello World Mod A Simple Hello World Modification to print Hello World to the game logs 1605041890 A Simple Hello World Modification to print Hello World to the game logs Jonathan Turnock 1.2,2.0 HelloWorld.Lua HelloWorld.Lua ``` -------------------------------- ### HelloWorld.Lua Script with Print Statement Source: https://jonathanturnock.github.io/civ-vi-modding/docs/hello-world-lua-mod The Lua script file created in ModBuddy for the HelloWorldMod project. It includes a header comment and prints 'Hello World from the Lua Script' to the game logs. ```Lua -- HelloWorld -- Author: jonat -- DateCreated: 11/10/2020 7:57:33 PM -------------------------------------------------------------- print("Hello World from the Lua Script") ``` -------------------------------- ### Declare and print a global variable Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Demonstrates declaring a global variable and printing its value. ```lua helloWorldMessage = "Hello World" print(helloWorldMessage) -->> Hello World ``` -------------------------------- ### Define a global constant in a file Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Creating a file to hold a global constant. ```lua --- constants.lua PI = 3.14159 ``` -------------------------------- ### Import and use a global constant Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Using dofile to import a global variable from another file. ```lua ---printPi.lua -- Reference Before Import print(PI) -->> nil -- Import Constants dofile("constants.lua") -- Reference after import print(PI) -->> 3.14159 ``` -------------------------------- ### Execute Lua Script via Command Prompt Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/installation Command to run a Lua file using the standalone interpreter. ```bash lua.exe helloWorld.lua ``` -------------------------------- ### Demonstrate variable scope in functions Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Shows how variables defined inside a function scope behave compared to global variables. ```lua --<< Top Level Scope Starts print(pi) -->> nil print(localPi) -->> nil function definePI() --<< Function Scope Starts pi = 3.14 local localPi = 3.14 print(pi) -->> 3.14 print(localPi) -->> 3.14 end --<< Function Scope Ends definePI() print(pi) -->> 3.14 print(localPi) -->> nil --<< Top Level Scope Ends ``` -------------------------------- ### VS Code Lua Extension Metadata Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/installation Details for the sumneko.lua extension used for Lua language support in Visual Studio Code. ```text Name: Lua Id: sumneko.lua Description: Lua Language Server coded by Lua Version: 1.0.4 Publisher: sumneko VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=sumneko.lua ``` -------------------------------- ### VS Code Code Runner Extension Metadata Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/installation Details for the Code Runner extension, which enables running Lua files directly from the VS Code right-click menu. ```text Name: Code Runner Id: formulahendry.code-runner Description: Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Obj-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim, Version: 0.11.1 Publisher: Jun Han VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner ``` -------------------------------- ### Attempt to access a local variable from another file Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Local variables defined in one file cannot be accessed in another, even after importing. ```lua ---printPi.lua -- Reference Before Import print(PI) -->> nil -- Import Constants dofile("constants.lua") -- Reference after import print(PI) -->> nil ``` -------------------------------- ### Define a local constant in a file Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Defining a local variable within a file, making it inaccessible outside that file. ```lua --- constants.lua local PI = 3.14159 print(PI) -->> 3.14159 ``` -------------------------------- ### Declare a local variable Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Using the local keyword to restrict variable scope. ```lua local halfPi = PI/2 print(halfPi) ``` -------------------------------- ### Reference an undeclared variable Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Referencing a variable that has not been declared results in a nil value. ```lua print(nothingHere) -->> nil ``` -------------------------------- ### Delete a variable by assigning nil Source: https://jonathanturnock.github.io/civ-vi-modding/docs/lua-reference/variables-and-assignment Assigning nil to a variable removes its value and allows memory management to clean it up. ```lua helloWorldMessage = "Hello World" print(helloWorldMessage) -->> Hello World helloWorldMessage = nil print(helloWorldMessage) -->> nil ``` -------------------------------- ### Unspecified Language Code Block Source: https://jonathanturnock.github.io/civ-vi-modding/docs/reference A code block without a specified language, demonstrating how HTML tags are rendered within plain text blocks. ```text No language indicated, so no syntax highlighting. But let's throw in a tag. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.