How to create the first Script mod for FS25
How to create the first Script mod for FS25
In this article, you will get your first taste of programming by creating your first script, which is what we call a file that holds code. To add a new script, follow these steps:
- Navigate to the Scripts application menu.
- Select Create New Script.
- You will be prompted to enter a name for your script.
- Enter a name of your choice – perhaps test.
The Script Editor should appear within a new window in the GIANTS Editor and include some comments by default. Comments are lines of code that don’t do anything and simply hold text; in Lua, comments are lines that begin with two dashes (–). After these lines, add a new line with the following content:
print("Hello world!")
Hello world! It is a traditional first line of code for many programmers. With this line written in your script, click Save and then Execute. You should see the output of your program in the GIANTS Editor’s Output window. Note that you can access the Script Editor at any time via the Windows application menu. As mentioned in “The Toolbar” section of this chapter, you can assign a script you create to a button in one of five custom script toolbars. Having a shortcut to a script in the toolbar is a handy way to speed up the modding process. For example, as a map creator, you could create a script that perfectly aligns fences. With the shortcut button in the toolbar, you would simply need one click to align the fences.
To add a script to the toolbar, open it in the Script Editor; at the top of the window, select one of the script button slots from the dropdown menu next to the Toolbar label for your script to be assigned to, as seen in the image below. You can upload an icon so that you can easily identify each of your scripts. Once you’ve done this, simply click the button with your chosen icon in the Toolbar, and you should see the output of the script in the console.
There you go. Your first program is complete! You will learn the fundamentals of Lua and how to make more complex systems in Chapter 3, “The Lua Programming Language.” For now, let’s look at what other editor elements are relevant to writing and running Lua code.
The Console
The Console is a window of the GIANTS Editor that can be used to write and execute Lua code. After writing your code in the textbox of the Console, press Shift+Enter to have that code execute instantly. This is useful when running simple commands or doing math with what’s offered by the Lua libraries, but it also affects things in your scene, such as changing fog or other properties. In the next chapter, you will gain experience with the Console as you execute simple programs to become familiar with the Lua programming language.
In Conclusion
In this tutorial, you learned how to use the GIANTS Editor and what tools and features it offers. You should now feel comfortable creating and changing the properties of new objects, managing application settings, creating and executing a script, and manipulating elements of your environment, like terrain, with built-in tools.
The next article will teach you to program in the Lua programming language and about general programming constructs that will be key components of your future as a mod creator and as a programmer more generally. By the end of the following chapter, you will be able to make your own programs in Lua with proper style and the knowledge to produce optimized code, so subscribe to us to get the latest tutorials.
Author: Zander Brumbaugh, Manuel Leithner