Updated Tomb Engine Setting Up A New Level Tutorial (markdown)

Stranger1992 2022-07-06 22:41:44 +01:00
parent 450b2411bb
commit c713d704cf

@ -79,7 +79,110 @@ For the TEN, the level samples have undergone a massive overhaul below I will li
In this section we are going to add the sounds to the level and then override all of Lara's sounds from TR4 to their TR1 counterparts.
```tbc```
# How To Create A New Level Script
To start off with, this section will explain, in simple terms how actually create and program Lua Scripts specifically for Tomb Engine. For those who are familiar with Tomb Raider Next Generation (TRNG) or even Tomb Raider Level Editor (TRLE) then this guide as a gateway for veteran and new builders understand how Lua defines level scripts and how to program things in Lua for Tomb Engine.
## Scripting A New Level
To first illustrate what files are what: see the table below.
| TRLE File | Lua File |
| ----------- | ----------- |
| ```Script.txt``` | ```Gameflow.Lua```|
| ```English.txt```<sup>*</sup>| ```Strings.Lua``` |
<sup>*Or another language.txt depending on your preferences. For this tutorial I will refer to the file as English.txt as its the one I use.</sup>
```Gameflow.Lua``` is the file where you put all the parameters so that you can play your new level and ```Strings.Lua``` is where you add any text that you need inside. A "STRING" is just programming term for "Text" by the way. The same as before where ```Script.txt``` would be the level block and ```English.txt``` would be where you are putting the level names and the names of puzzles, keys and so on and so forth.
Now let's move on and go into the comparison a bit more deeply by taking a look at some original Tomb Raider 4 scripts and then their new Lua equivalents.
See this script from Tomb Raider IV. This will be a familiar site to many who have used the level editor or subsequent improvements. In this script, you can see that there are some puzzle items, the sky clouds' colour and speed, the level name, and the data file for the level.
```
[Level]
Puzzle= 1,Nitrous Oxide Feeder, $0004,$0300,$0000,$0000,$0000,$0002
Puzzle= 2,Car-Jack, $0000,$0400,$4000,$8000,$4000,$0002
Puzzle= 4,Roof Key, $0000,$0300,$4000,$d000,$b000,$0002
Puzzle= 5,Weapon Code Key, $0000,$0200,$8000,$c000,$0000,$0002
Puzzle= 8,Mine Detonator, $0008,$0400,$8000,$0000,$0000,$2002
PuzzleCombo= 1,1,Valve Pipe, $0004,$0300,$0000,$0000,$0000,$000a
PuzzleCombo= 1,2,Nitrous Oxide Cannister, $0002,$0300,$0000,$0000,$0000,$0002
PuzzleCombo= 2,1,Car-Jack Body, $0000,$0400,$4000,$8000,$4000,$0002
PuzzleCombo= 2,2,Handle, $0000,$0300,$4000,$8000,$
4000,$0002
PuzzleCombo= 8,1,Mine Detonator Body, $0008,$0400,$8000,$0000,$0000,$0002
PuzzleCombo= 8,2,Mine Position Data, $0004,$0280,$8000,$c000,$0000,$0002
Layer1= 56,72,8,16
LoadCamera= 62359,-4966,62296,63155,-4380,63208,3
ResetHUB= 27
Name= Citadel Gate
Horizon= ENABLED
Level= DATA\HIGHSTRT,102
```
Within the ```English.txt``` file you can expect to see the puzzle names and level names listed somewhere as ```STRINGS```:
```Nitrous Oxide Feeder
Car-Jack
Roof Key
Weapon Code Key
Mine Detonator
Valve Pipe
Nitrous Oxide Cannister
Car-Jack Body
Handle
Mine Detonator Body
Mine Position Data
Citadel Gate
```
No matter where you have them, as long as they are there in the English.txt file then they are in the right place.
Now lets take a look at the Lua equivalent and then I will explain what each one means. Please note that at this stage, as I have not discussed about proper indentation and formatting of your Lua scripts, I have removed the ```TABS``` and condensed things down.
### Strings.Lua
```
city = {"Citadel Gate",},
cjack = { "Car-Jack",},
roofK = { "Roof Key",},
code1 = { "Weapon Code Key",},
mine = { "Mine Detonator",},
valve1 = {"Valve Pipe",},
nitro2 = {"Nitrous Oxide Cannister",},
cjackb = {"Car-Jack Body",},
chandle = {"Handle",},
mine1 = { "Mine Detonator Body",},
```
### Gameflow.Lua
```
city = Level.new();
city.nameKey = "city";
city.scriptFile = "Scripts\\city.lua";
city.ambientTrack = "102";
city.levelFile = "Data\\city.ten";
city.loadScreenFile = "Screens\\rome.jpg";
city.horizon = true
city.layer1 = Flow.SkyLayer.new(Color.new(56,72,8),16)
city.farView = 20
city.objects = {
InventoryItem.new("nitro1",InvID.PUZZLE_ITEM1,0,1,Rotation.new(0, 0, 0),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("cjack",InvID.PUZZLE_ITEM2,-25,1,Rotation.new(0, 0, 90),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("roofK",InvID.PUZZLE_ITEM4,0,1,Rotation.new(-45, 180, 90),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("code1",InvID.PUZZLE_ITEM5,50,1,Rotation.new(-90, 0, 90),RotationAxis.Y,2,ItemAction.USE),
InventoryItem.new("mine",InvID.PUZZLE_ITEM8,50,0.5,Rotation.new(0, 0, 0),RotationAxis.Y,2,ItemAction.USE),
InventoryItem.new("valve1",InvID.PUZZLE_ITEM1_COMBO1,50,0.5,Rotation.new(0, 0, 0),RotationAxis.Y,2,ItemAction.USE),
InventoryItem.new("nitro2",InvID.PUZZLE_ITEM1_COMBO2,0,1,Rotation.new(0, 0, 0),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("cjackb",InvID.PUZZLE_ITEM2_COMBO1,0,1,Rotation.new(0, 0, 0),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("chandle",InvID.PUZZLE_ITEM2_COMBO2,0,1,Rotation.new(0, 0, 0),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("mine1",InvID.PUZZLE_ITEM8_COMBO1,0,1,Rotation.new(0, 0, 0),RotationAxis.Y,-1,ItemAction.USE),
InventoryItem.new("mine2",InvID.PUZZLE_ITEM8_COMBO2,0,1,Rotation.new(0, 0, 90),RotationAxis.Y,-1,ItemAction.USE),
Flow.AddLevel(city);
```