Adding Lua Script Components
You add three more components, all Lua Script components, to the TimerStart entity. You then add the following scripts and make the following changes:
-
Lua Script component #1:
-
Script –
Timer.lua
-
TimerElementName –
Timer
-
-
Lua Script component #2:
-
Script –
TriggerEvent.lua
-
EventName –
TimerStart
-
-
Lua Script component #3:
-
Script –
TriggerEvent.lua
-
EventName –
TimerStop
-
You then use the Move tool to adjust the TimerStart entity's position in the viewport so that it is just inside the maze entrance.
To add and configure Lua Script components
-
In the Entity Outliner, select the TimerStart entity.
-
In the Entity Inspector, click Add Component.
Select Lua Script.
Repeat twice more so that you have a total of three Lua Script components on the TimerStart entity.
-
On the first Lua Script component, do the following:
-
Click Browse (...) next to the Script box. Navigate to
StarterGame\Scripts\General
and selectTimer.lua
. -
In the TimerElementName property, enter
Timer
.
-
-
On the second Lua Script component:
-
Click Browse (...) next to the Script box. Navigate to
StarterGame\Scripts\Triggers
and selectTriggerEvent.lua
. -
In the EventName property, enter
TimerStart
.
-
-
On the third Lua Script component:
-
Click Browse (...) next to the Script box. Navigate to
StarterGame\Scripts\Triggers
and selectTriggerEvent.lua
. -
In the EventName property, enter
TimerStop
.
-
-
In the viewport, use the Move tool to adjust the position of the TimerStart entity so that it is just inside the maze entrance. That way, the timer starts when the player enters the maze.
-
Press Ctrl+S to save your level.
Next, you add and configure a similar set of entities and components at the maze's exit to trigger the timer to stop.