Event Sequence Tutorial : Basics

Updated on 16 April 2024

Introduction

In this tutorial: I will walk you through how to trigger events to happen in succession. This is the TombEngine equivalent of TRNG Organisers. This tutorial will cover the basic steps required to trigger such events and will hopefully leave you open to experiment further.

The sections to complete are as follows:

1) Create the events that you want to trigger inside the Node Editor of Tomb Editor,

2) Create an Event Set,

3) Trigger it in-game.

Lua Theory

Firstly: lets jump over to the TEN Lua API

This shows the basic syntax for the scripting we will be doing. However, each step will come with the provided code and more information but is handy as a reference in the future. 

Section 1 : Tomb Editor Setup.

In this first section, we will create the setup used for this tutorial. This section assumes you have basic knowledge of how to use Tomb Editor.

  • The textures we will be using are by Delca: https://www.trsearch.org/item/5569
  • The project will use the base TombEngine WAD2 that comes with Tomb Editor (located at Tomb Editor\Assets\Wads)
  • I have also provided some further assets taken from Tomb Raider I (link to download)

In your project file, I have created a simple few rooms where I have placed three doors that will open and close, in sequence, one after the other. The aim is for the player to pick the right path.

To give an object a unique Lua name: right-click the object and select “rename object”. Please do this for all three doors and give them the names “door1”, “door2”, and “door3”.

Exporting Nodes into TombIDE Script Editor

The next step is where we will begin scripting within TombIDE . You can use any coding program you like (I use Visual Studio). Please open your application of choice and open the level script file ( located in Engine\Scripts\Levels )

First you can start off in the node editor and create a node like the example below. 

Afterwards: we are going to export this out to the clipboard. The result will look like this:

LevelFuncs.ExportedNodeFunction = function(activator)
	LevelFuncs.Engine.Node.EnableMoveable("door1")
end

However: this will get confusing as we stacking many of these exported nodes out together. Therefore I have amended then name to:

LevelFuncs.Door1Open = function()
	LevelFuncs.Engine.Node.EnableMoveable("door1")
end

This is important to do as each action needs to be contained inside a function in order to work and as they all have the same name: this will not run.

The easy thing about this as, as we have named our objects in Tomb Editor: you can edit the code easily to produce an open and close event for each door:

-- Door Open
LevelFuncs.Door1Open = function()
    LevelFuncs.Engine.Node.EnableMoveable("door1")
end


LevelFuncs.Door2Open = function()
    LevelFuncs.Engine.Node.EnableMoveable("door2")
end


LevelFuncs.Door3Open = function()
    LevelFuncs.Engine.Node.EnableMoveable("door3")
end

-- Door Close
LevelFuncs.Door1Close = function()
    LevelFuncs.Engine.Node.DisableMoveable("door1")
end


LevelFuncs.Door2Close = function()
    LevelFuncs.Engine.Node.DisableMoveable("door2")
end


LevelFuncs.Door3Close = function()
    LevelFuncs.Engine.Node.DisableMoveable("door3")
end

Notice how I have just changed the number of each door for each line.

Creating the Event Sequence

Now we have all the events we want to happen in our sequence: its now time to put them all together and see our work in game.

Jump back over to your code editor of choice and create a new function in a format that Tomb Editor can understand. This is in this format:

LevelFuncs.DoorSequence = function()

The below code shows how to set up the event sequence:

 local doorTime = 2.0 -- how many seconds each door is open for (used below)

local doorOpening = EventSequence.Create
    (
    "door_sequence", -- Lua name for event sequence
    true, -- If sequence loops then true, if not: false.
    false, -- We will not show the in-game timer for this example.


    -- The below section is where you put all the events you want
    -- in your sequence, in the order you want them,
    -- with the timings between)

    doorTime, -- I made an enumerator for this so I don't have to change all manually
    LevelFuncs.Door1Open,
    doorTime,
    LevelFuncs.Door1Close,
    doorTime,
    LevelFuncs.Door2Open,
    doorTime,
    LevelFuncs.Door2Close,
    doorTime,
    LevelFuncs.Door3Open,
    doorTime,
    LevelFuncs.Door3Close
    )

   -- last : now we have created the Event Sequence: you must Start it:
    doorOpening:Start()
end

Please ensure you SAVE your file before the next step.

Setting up in Tomb Editor

Next: lets complete the final section and set up Tomb Editor to run this script. There are a few methods for this. For this first example, we will be using a volume.

1) In 3D mode: select a row of sectors press the V key to create a new volume and open the Event Sets editor. 

2) Create a new event set and make sure it is set to “On Enter” (top right)

3) Right-click the main window, and a box will pop up with various nodes. Navigate to the “Run Script Function” found in the Gameflow section:

4) In the drop down box: you should see a list of functions that are inside your script file. If you do not: then either your functions are not in the proper format as shown above, or you have not saved your file. If you have saved and you aren’t seeing them then please close the node editor, save your script again and re-open.

5) You must select the sequence that contains your Event. In this example: I have name the function as “DoorSequence” . This is why naming is so important. 

6) Press “OK” and the volume you created will have this event assigned to it.

7) Build your level and view in-game.

Conclusion

To summarise: we have created a custom sequence (known as an Event Sequence) , completed all scripting for it and ran it in-game. This tutorial only does scratch the surface to what is possible. The second part of this tutorial will show more examples and add in some conditions of the sequence to play out.

If you have any feedback or require further help: please reach out on our dedicated Discord server.