www.tombraiderforums.com

Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Tomb Raider Level Editor Tutorials

Closed Thread
 
Thread Tools
Old 02-03-16, 12:28   #1
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 2,225
Default TRNG - Script directives

Made using TRNG 1.2.2.7.+

Script directives are special script commands. Script directives are not controlling the game, script directives are “only” making the script writing easier for you.
Each directive starts with Sign #, which distinguish them from the “normal” script commands.

#INCLUDE directive

#INCLUDE directive is useful if your script would be too long, that is why you detach one or more parts of the script, from the other parts of the script.

From now on, we call these detached parts “subscripts”, and we call the other parts of the script “main script”.

For example, you have five levels in your game, and you want to use the enemy health bar setup for all the five levels. In that case, it is unnecessary to type this setup for all the five levels.
Instead, you type it only once, in a TXT file, and then you type five #INCLUDE directives in the five levels, which will refer to that TXT file.

For example, your “Temple Of Karnak” level script looks this way without an #INCLUDE directive:

Code:
  [Level]
  Name=                       Temple Of Karnak
  ;-------------enemy health bar setup---------------------------------------------------
  ColorRGB= 1, 0, 0, 255
  ColorRGB= 2, 0, 255, 0
  Customize= CUST_BAR, BAR_CUSTOM1, FBAR_SHOW_BAR_NAME, >
  280, 30, 120, 20, 1, 2, #0800
  GlobalTrigger= 1, IGNORE, GT_CONDITION_GROUP, IGNORE, 1, 2, 3
  TriggerGroup= 1, $2000, 244, $1371, $8000, 113, $129
  TriggerGroup= 2, $2000, 271, $71, $2000, 351, $0, $2000, 245, $2FF, $2000, 256, $350, >
  $2000, 118, $4, $2000, 245, $5450, $2000, 293, $950, >
  $2000, 237, $40, $2000, 263, $FF, >
  $2000, 287, $50, $2000, 256, $C50, $2000, 288, $50, $2000, 253, $64FF, >
  $2000, 331, $4
  TriggerGroup= 3, $2000, 332, $4
  TriggerGroup= 4, $8000, 80, $128, $2000, 239, $200E, >
  $8000+TGROUP_ELSE, 80, $228, $2000, 239, $200F
  Parameters= PARAM_BIG_NUMBERS, 10000, 41, 106
  ;------------------------------------------------------------------------------------------------
  Horizon=        ENABLED
  Layer1=                     128,96,64,7
  Puzzle=                      2,Canopic Jar 1,       $0001,$0320,$0000,$0000,$0000,$0002
  Puzzle=                      3,Canopic Jar 2,       $0001,$0320,$0000,$0000,$0000,$0002
  Puzzle=                      1,Sun Talisman,                   $0000,$0500,$0000,$0000,$0000,$0002
  PuzzleCombo=         1,1,Sun Disk,                        $0000,$0180,$0000,$0000,$0000,$0002
  PuzzleCombo=         1,2,Sun Goddess,    $0000,$04b0,$0000,$0000,$0000,$0002
  Puzzle=                      5,Golden Vraeus,     $0003,$0300,$0000,$0000,$0000,$0002
  Puzzle=                      7,Guardian Key,       $0009,$0300,$0000,$0000,$0000,$0002
  Key=                          2,Hypostyle Key,       $0000,$0400,$0000,$c000,$0000,$0002
  LoadCamera=          89366,-258,48077,88372,-1300,45701,0
  Level=                        DATA\KARNAK,110


But if you use an #INCLUDE for the enemy health bar setup, then type that setup in a subscript. This subscript is called Attachment01.txt this time (but you are allowed to name it anyhow), and it contains only the enemy health bar setup:

Code:
  ColorRGB= 1, 0, 0, 255
  ColorRGB= 2, 0, 255, 0
  Customize= CUST_BAR, BAR_CUSTOM1, FBAR_SHOW_BAR_NAME, >
  280, 30, 120, 20, 1, 2, #0800
  GlobalTrigger= 1, IGNORE, GT_CONDITION_GROUP, IGNORE, 1, 2, 3
  TriggerGroup= 1, $2000, 244, $1371, $8000, 113, $129
  TriggerGroup= 2, $2000, 271, $71, $2000, 351, $0, $2000, 245, $2FF, $2000, 256, $350, >
  $2000, 118, $4, $2000, 245, $5450, $2000, 293, $950, >
  $2000, 237, $40, $2000, 263, $FF, >
  $2000, 287, $50, $2000, 256, $C50, $2000, 288, $50, $2000, 253, $64FF, >
  $2000, 331, $4
  TriggerGroup= 3, $2000, 332, $4
  TriggerGroup= 4, $8000, 80, $128, $2000, 239, $200E, >
  $8000+TGROUP_ELSE, 80, $228, $2000, 239, $200F
  Parameters= PARAM_BIG_NUMBERS, 10000, 41, 106



These TXT subscript files must always be placed in Script folder of Level Editor main folder.

In the main script, in “Temple Of Karnak” level script, where you originally wanted to type the enemy health bar setup, you only type an #INCLUDE directive, that will refer to the subscript with Attachment01.txt name (don’t forget the quotation marks!):

Code:
  [Level]
  Name=                       Temple Of Karnak
  #INCLUDE “Attachment01.txt”
  Horizon=        ENABLED
  Layer1=                     128,96,64,7
  Puzzle=                      2,Canopic Jar 1,       $0001,$0320,$0000,$0000,$0000,$0002
  Puzzle=                      3,Canopic Jar 2,       $0001,$0320,$0000,$0000,$0000,$0002
  Puzzle=                      1,Sun Talisman,                   $0000,$0500,$0000,$0000,$0000,$0002
  PuzzleCombo=         1,1,Sun Disk,                        $0000,$0180,$0000,$0000,$0000,$0002
  PuzzleCombo=         1,2,Sun Goddess,    $0000,$04b0,$0000,$0000,$0000,$0002
  Puzzle=                      5,Golden Vraeus,     $0003,$0300,$0000,$0000,$0000,$0002
  Puzzle=                      7,Guardian Key,       $0009,$0300,$0000,$0000,$0000,$0002
  Key=                          2,Hypostyle Key,       $0000,$0400,$0000,$c000,$0000,$0002
  LoadCamera=          89366,-258,48077,88372,-1300,45701,0
  Level=                        DATA\KARNAK,110


If the cursor is on the required #INCLUDE directive, then hit F5, so that subscript will be loaded into the script window of NG Center.
Now you can edit this subscript here, or you can use Save/Build buttons to save/build the whole script.
Hit F6 to restore the main script in the script window.

Notes:
- The directive can be placed only in the main script. So you can’t type it in a subscript to refer a sub-subscript.
- If you want, you can use CTRL+F5 to create the TXT and to inset its #INCLUDE directive in the Script. (Be careful, if that TXT already exists, then it will be overwritten now!)

#FIRST_ID directive

Several Script commands have ID numbers to identify them: TriggerGroups, GlobalTriggers etc. Mostly it is the very first field of the command. If the cursor is just in that field, and you just want to type that ID, but you don’t know what the first (smallest) free ID in that level, then you don’t need to search for that. Just hit F1, and then the first ID will be typed there automatically.

The problem is this method is useless in subscripts made by #INCLUDE directives. You can fix that with #FIRST_ID directive.
For example, your main script is finished for that level, and you used fourteen TriggerGroups (from ID#1 to ID#14) in the setup. The further TriggerGroups of that level will be used in a particular subscript TXT file, that is why you start that subscript with typing this:

#FIRST_ID TriggerGroup=15

Which means if you hit F1 for a free TriggerGroup ID, when you edit this subscript in NG Center Script window, then 15 will be the first free ID at the first hit, then 16 for the next TriggerGroup etc.
Naturally you can type more than one #FIRST_ID directive in each subscript, if you want to define the first free ID’s of more than one command for that subscript. For example:

#FIRST_ID TriggerGroup=15
#FIRST_ID GlobalTrigger=22

#DEFINE directive

This directive is useful if you want to substitute some numbers or texts for some reason.

For example, you have a setup for something that ends with GlobalTrigger#9 and TriggerGroup#24, so you start your next setup for another thing with GlobalTrigger#10 and TriggerGroup#25 – like this:

Code:
  GlobalTrigger= 10, -1, GT_CONDITION_GROUP, -1, 25, 26, -1
  GlobalTrigger= 11, -1, GT_LARA_HOLDS_ITEM, HOLD_SHOTGUN, -1, 27,-1
  TriggerGroup= 25, $8000, 1, $23
  TriggerGroup= 26, $2000, 355, $1400
  TriggerGroup= 27, $2000, 355, $A04; $2000, 118, $11C ; 1C is the hexadecimal version of “28”, it refers to TriggerGroup#28
  TriggerGroup= 28, $2000+TGROUP_SINGLE_SHOT, 91, $40A


Then you realize you need further GlobalTriggers and TriggerGroups in the first setup. You can do that with the free GlobalTrigger#12 and TriggerGroup#29 ID’s, but you don’t want to break the line, so you want GlobalTrigger#10 and 11 ID and TriggerGroup#25, 26, 27 and 28 ID for the first setup.
That is why you need to modify this in the second setup (colored by red above):

- GlobalTrigger ID’s in the GlobalTrigger commands, and
- TriggerGroup ID’s in the TriggerGroup and GlobalTrigger commands, including the hexadecimal value in one of the trigger.

It is tiresome, and it would be a really serious source of errors if the second setup is bigger, and you mistype the new ID’s.

That is why you type the second setup this way, if you expect the first setup has not been finished yet, so you maybe needs further GlobalTriggers and TriggerGroups for that:

Code:
  #DEFINE TG 25
  #DEFINE GT 10
  GlobalTrigger= GT, -1, GT_CONDITION_GROUP, -1, TG, TG+1, -1
  GlobalTrigger= GT+1, -1, GT_LARA_HOLDS_ITEM, HOLD_SHOTGUN, -1, TG+2, -1
  TriggerGroup= TG, $8000, 1, $23
  TriggerGroup= TG+1, $2000, 355, $1400
  TriggerGroup= TG+2, $2000, 355, $A04, $2000, 118, $101+TG+2
  TriggerGroup= TG+3, $2000+TGROUP_SINGLE_SHOT, 91, $40A


Explanation – see only the red parts, they are peculiar:

#DEFINE TG 25 says when you type “TG” then that means 25. (TG refers to the word of TriggerGroup, but is not necessary, you can type anything else. X, for example.)

So in the first GlobalTrigger, TG refers to TriggerGroup#25, and TG+1 refers to TriggerGroup#26.
In the second GlobalTrigger, TG+2 refers to TriggerGroup#27.
In the first TriggerGroup, TG refers to TriggerGroup#25.
In the second TriggerGroup, TG+1 refers to TriggerGroup#26.
In the third TriggerGroup, TG+2 refers to TriggerGroup#27.
In the fourth TriggerGroup, TG+3 refers to TriggerGroup#28.

See the exported value of F118 trigger with the smallest TriggerGroup ID (1). It is $2000, 118, $101. As I said above, the last number of this trigger refers to the ID number, so this is $101 now. TG+2 means 27, so $101+TG+2 must refer to TriggerGroup28 (1+27).

#DEFINE GT 10 works in a similar way for the GlobalTrigger ID’s.

As you see, if you need to change the ID’s for the setup then all you need to do is to change the number in the directive.
So, if you use TriggerGroup ID 25, 26, 27 and 28 and GlobalTrigger ID 10 and 11 for the first setup, as I said above, then all you need to do is modify that 25 and 10 in the directive, for the next free (29 and 12) ID’s:

Code:
  #DEFINE TG 29
  #DEFINE GT 12
  GlobalTrigger= GT, -1, GT_CONDITION_GROUP, -1, TG, TG+1, -1
  GlobalTrigger= GT+1, -1, GT_LARA_HOLDS_ITEM, HOLD_SHOTGUN, -1, TG+2, -1
  TriggerGroup= TG, $8000, 1, $23
  TriggerGroup= TG+1, $2000, 355, $1400
  TriggerGroup= TG+2, $2000, 355, $A04, $2000, 118, $101+TG+2
  TriggerGroup= TG+3, $2000+TGROUP_SINGLE_SHOT, 91, $40A


So TG will refer to TriggerGroup#29, TG+1 will refer to TriggerGroup#30 etc.

Note:
Sometimes you get an error message if you remove/overwrite a #DEFINE directive in a subscript TXT file.
In that case probably you should restore the original directive, even if you don’t use it.
(For example, when you modify #DEFINE TG 25 to 29 then you got the error message. Restore #DEFINE TG 25, and choose another constant, for example X, for TriggerGroup ID’s: #DEFINE X 29, also typing this directive. Then naturally swap TG for X in all the TriggerGroup and GlobalTrigger commands.)

Further examples to use the directive:

Example#1:

I suspect you can’t substitute everything in the Script with #DEFINE. It is successfully tested for command ID’s (see above) and for the Script constants.
For example, you have several WindowsFont commands, and you want to type this in all of them:

WFF_LEFT_ALIGN+WFF_FORCE_FIXED_PITCH

It is boring to tpye this in all the commands, but if you type their ID instead of them (128+1024, see NG Center/Reference), then it is hard to easily identify them.
That is why you type this directive:

#DEFINE FONT1 WFF_LEFT_ALIGN+WFF_FORCE_FIXED_PITCH

So where you type FONT1 in a WindowsFont command, that will always mean WFF_LEFT_ALIGN+WFF_FORCE_FIXED_PITCH. For example:

Code:
  #DEFINE FONT1 WFF_LEFT_ALIGN+WFF_FORCE_FIXED_PITCH
  ColorRGB= 1, 0, 255, 0
  WindowsFont= 1, Arial, FONT1+WFF_BOLD, 30, 1, -1


Example#2:

#DEFINE directives can compose a chain. For example:

#DEFINE GT 12
#DEFINE TG GT+15

So GT must be 12, and TG is always GT+15, which is 27 now.

The order is important now, the number defined at first (GT now) must be above!

Example#3:

You can combine #DEFINE and #FIRST_ID. For example:

#DEFINE X 30
#FIRST_ID TriggerGroup=X+10

X is 30, so the first free ID in the subscript is 40 now, if you hit F1. It will be 41 if you modify X to 31 etc.

Note for TRNG 1.3.0.0 users (or above):
See how it works for plugins (NG Center Plugin Script command). It could be crucial!

Last edited by AkyV; 05-12-16 at 14:06.
AkyV is offline  
Closed Thread

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 14:39.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2017, vBulletin Solutions, Inc.