05-11-24, 19:43 | #1 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
TEN - Scripting: mechanism, forms, settings
Made using Tomb Editor 1.7.2. pack (including Tomb Engine 1.5.)
Last update to TE/TEN: - In the tutorial about the script files I started a tutorial sequence about TEN scripting techniques. The further parts of the sequence so far: functions, basic scripting, advanced scripting. So this current tutorial is the fifth - and, for the time being, surely the last - part about scripting techniques in TEN. It helps you to feel comfortable while scripting, eg. introducing the script settings in TIDE, etc. CONTENTS: 1. Scripting Studio layout 2. The script reading mechanism in the game 3. Writing script 4. Settings for the appearance 5. Building issues and the error log ---------- Notes:
Last edited by AkyV; 18-11-24 at 20:31. |
05-11-24, 20:12 | #2 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
1. Scripting Studio layout
The scripting for TEN (or for any engines of TE) is made in Scripting Studio page of TIDE. The big window to edit the script and the dropdown menu are constant in the Scripting Studio layout, but you can open/close the other parts, if you wish:
---------- Note: In dropdown menu/Options/Text Editor Settings you have an option to set the required background color. But the feature is not added yet. Last edited by AkyV; 08-11-24 at 18:07. |
05-11-24, 20:13 | #3 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
2. The script reading mechanism in the game
The game will read a specific script file when it just needs that. Eg. the level script file of level X naturally will be read when the current level running is level X. Whatever script file is just open in the big window, then you can see that its lines are numbered, in an ascending order: 1, 2, 3, 4, 5 etc. - Naturally it is really useful, because now you can easily identify each line of the current script file. The game reads the script lines from top to bottom, but the game never reads the line ID numbers to identify its current position. Instead, it tries to find specific signs to identify its position. Let's see this example (which should be familiar from the previous tutorial of this tutorial sequence), from a level script file: The signs (in the order of reading it) which will tell the game how to continue reading the script:
Code:
function FlameAmbience() local flameOn = 0 for i = 1, 10 do if GetMoveableByName("flame_emitter_" .. i):GetActive() == true then flameOn = flameOn + 1 end end EmitLight(Vec3(12288, -1280, 10086), Color(200 * flameOn / 10, 100 * flameOn / 10, 20 * flameOn / 10), 20) end ---------- Note: In dropdown menu/Options/Text Editor Settings you can untick "Show line numbers" if you feel the line ID numbers which are unnecessary to the game, are also disturbing to you. Last edited by AkyV; 12-11-24 at 20:40. |
06-11-24, 18:58 | #4 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
3. Writing script
Just type the characters the same way as you type your text in a Word document - this is the main thing you need to know when you type your code in the script. But there are some additional things you also need to know:
In the previous chapter, you could see the function typed only in one line. If you find that ugly, then you can split the function into more lines, eg.: Code:
function FlameAmbience() local flameOn = 0 for i = 1, 10 do if GetMoveableByName("flame_emitter_" .. i):GetActive() == true then flameOn = flameOn + 1 end end EmitLight(Vec3(12288, -1280, 10086), Color(200 * flameOn / 10, 100 * flameOn / 10, 20 * flameOn / 10), 20) end For a nice look, keep these rules in your mind:
Notes:
Last edited by AkyV; 13-11-24 at 19:22. |
07-11-24, 00:29 | #5 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
4. Settings for the appearance
These settings (for all your LUA script files) can be done in dropdown menu/Options/Text Editor Settings:
Notes:
Last edited by AkyV; 12-11-24 at 20:18. |
07-11-24, 00:43 | #6 |
Moderator
Joined: Dec 2011
Posts: 5,075
|
5. Building issues and the error log
As I said above, sometimes the wrong text color is enough to identify the issue in the script, which makes that script file useless in the game. But sometimes it is not so obvious. I mean, you will surely realize that when you hit New Game in the game title, to start testing your freshly edited level, then the game won't load that level. Instead, it will load you back into the title. This means there is an error somewhere in your script (even if the character colors are all the proper ones). Open the Engine folder now in your project folder. Here yo can find Logs folder, with TENLog.txt in it. Open the TXT, and scroll down the lines. Soon you will find a line here with the text of "A Lua error occurred while running a level". The problematic script file and its problematic line are identified in this log line. You can also identify here where is the issue in that line. ---------- Notes:
Last edited by AkyV; 12-11-24 at 20:14. |
Bookmarks |
Thread Tools | |
|
|