‼️Scripting
Implementing a new feature
In order to get a nice result for our CrystalCoat implementation we need to use some scripting. This script will also allow us to go deeper into the customization later.
Download this template, rename it with your mod name, and place it into your project at this location.
Then edit the script using VSCode. You need to perform some replacements into the file to make it work for your mod. To replace text use CTRL + H.
Perform case-sensitive replacements to avoid mistakes.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252Fcudf6YXacxon6kPskgQS%252Fspaces_4gzcGtLrr90pVjAWVdTc_uploads_0GCmaBXX3e3gwex8daEz_image.webp%3Falt%3Dmedia%26token%3Dccf77805-e2f7-4e9d-b9c7-eaca8fc6982f&width=768&dpr=4&quality=100&sign=c6200a1f&sv=1)
Script setup
Module name
First you need to define the name of your module at the top of the file. The module name acts as a namespace for your types definition so they won't collide with another mod. It also allows other mods to check if your mod is installed.
You must use a unique combination of words to define your module name. I recommend you to use your nickname followed by your mod name.
In order to change this perform a global replacement using CTRL + H. Replace My_Nickname.My_Mod_Name
using the case-sensitive option.
You should have replaced 3 occurrences.
Vehicle record name
Next you need to use your vehicle record name. In this tutorial I am using the Mahir Supron with this record name Vehicle.v_standard25_mahir_supron_player
.
If you are working with another vehicle then perform a global replacement of this sequence with yours. You should have replaced 1 occurrence.
Entity appearance name
Do you remember what I told you about how does the game use appearances when it loads a vehicle ?
The script needs to monitor entity loading and it must hook only if this is the vehicle entity that your mod is working with. This is why you need to tell the script what is the entity ENT file and what is the entity appearance name to look for.
You need to replace mahir_supron__basic_player_01
by the base appearance name of the vehicle you can find in the vehicle record using the Tweak Browser at the field named appearanceName
. You should have replaced 1 occurrence.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FmOgAVAF6RzVHKTlauMDe%252Fspaces_4gzcGtLrr90pVjAWVdTc_uploads_mBELJ0qcN9JS0BRGZBI8_image.webp%3Falt%3Dmedia%26token%3Ddcb053ff-4b40-4b37-8362-39d40329c126&width=768&dpr=4&quality=100&sign=a35eb945&sv=1)
Entity file relative path
You need to replace the entity file path by the one from the base game, that is to say by the one that is actually loaded by the game during runtime (not your own file !). Remember that our own ENT file only serves the purpose of having its content appended to the base game file.
You should have replaced 1 occurrence.
You must use double-backslashes (\\
) for file paths in the script file.
Supported vehicle name
This script can be extended to support multiple vehicles so you will find an enumerated type.
If you are not creating a mod for the Mahir Supron you should replace the model name in this type definition and also into the code. Replace the type definition manually, then replace usage occurrences by looking for .Supron
You should have replaced 2 usage occurrences.
Last updated