LFS Movie Maker Script Help
Scripts give you direct control of the ingame camera, meaning you can set the position, heading, angle and other
parameters. Aswell as control of the ingame camera, scripts allow you to take control of the 'time' in LFS, this means
you can control the playback speed and even stop time completly.
Scripts are written in Delphi Pascal and are fully compatible with mathematic equations and complex syntax. You
don't need to know any programming to be able to write a script, simply take a look at some examples and you will
pick it up pretty quickly.
The scripter comes complete with source code completion, this means when you begin to type, if the scripter
recognises an identifier within its library it will display a list of the commands and variables you can add. A complete
list and explanation of the identifiers is listed below.
Getting Started:
The script editor is similar to notepad, it is a simple text editor with the added benefit of coloured code and code completion. At
the top the editor is the tool menu where you will find the usual New, Load and Save options aswell as the edit options. One option
in the File menu, Save Locked, allows you to save your script for distributing to other users of LFS Movie Maker without them
being able to edit it.
There are 3 important things to remember when making a script. 1) It must have a unit name, this is the first line of the script, it
will say 'unit Untitled' to begin with. You can change the name to anything you like BUT it can't have and spaces or special
characters. 2) There must be a KillScript procedure, this is added by default and shouldn't be removed or edited unless you
need LFS Movie Maker to break a loop or set any values that need setting to end the script. 3) There must be a main procedure,
this is where all of the code goes for the script.
The code completion will start to work as soon as you start to type, if you type COM_ or _ then it will appear, you can select a
word to use by double clicking it from the list. Next to each word in the list will be a hist about the type of variable it is or what to
pass to make the command work. For a full list of reserved words see the Identifier List below.
Script Format:
To get a script to work properly you must action the commands in the correct order. If you want to edit the camera then you
must call the COM_get_camera function, this will tell LFS Movie Maker to get the current camera position and settings. You can
then access the camera properties and change them by using the _camera_??? variables. It is recommended that you call
COM_pause with a value of about 100 to allow LFS Movie Maker enough time to get the camera.
If you want to edit the 'in car' camera then you must pass and extra 8192 in the _camera_flags variable. You can use the constant
value VIEW_OVERRIDE in the script.
To set a camera position you must pass COM_set_camera. This will tell LFS Movie Maker to change the camera settings to the
settings stored.
If you want to control the time in LFS Movie Maker then you must call COM_stop_internal_time first, this will stop LFS Movie Maker
from controlling the time and will pass control over to the script. You can move time by using the COM_step_time command. When
you have finished with the time you MUST pass COM_stop_internal_time(false) to pass control back to LFS Movie Maker other
wise LFS will hang in suspended time.
You can use COM_start_outsim and COM_stop_outsim to start and stop receiving the current car's position in the LFS world. You
cannot change these values, they are read only and can be used as reference values for plotting cameras and tracking cameras etc.
If is actually recommended that you write scripts in the Script SDK Tool, it will help you create scripts faster and easier. You can
get the Script SDK from the LFS Movie Maker website.
Extra Information:
There are some basic things you should know before getting started. Most lines of code must end with a ; semi
colon. There are exceptions and they are after reserved words such as 'begin', 'end', 'do', 'repeat' and more.
A reserved word will generally turn to bold in the script so you will know.
The double slash // means a comment, any text after // will change colour, this means the scripter will ignore the line
and treat it is a comment. You can also block out a lot of code using { and } you can see an example at the top of the
default script.
The code in the script is not case sensitive, this means ABC and abc are treated as the same. This also applies
to identifiers and reserved words.
All script code must be entered between the 'begin' and 'end' inside the 'Main' procedure. You can write custom
procedures and functions outside of the main procedure if you want.
Identifier List:
COM_stop_internal_time() - Use this to start and stop the time inside LFS and in LFSMM2. Pass True or False inside
     the brackets. True stops time, false starts time.
COM_get_camera; - Use this to make LFSMM2 get the current camera position.
COM_set_camera; - Use this to make LFSMM2 pass the current camera position to LFS.
COM_pause(); - Use this to stop the script from continuing to the next line. Pass the pause duration in the brackets. The
     value is in milliseconds, 1000 = 1sec.
COM_get_fps; - Use this to get the current fps used in LFSMM2.
COM_step_time(); - Use this to move time in LFS and LFSMM2 by a set duration. Pass the time in the brackets in hundredths.
COM_start_outsim; - Makes LFS send position of the current car
COM_stop_outsim; - Make LFS stop sending positions
NOTE: these next variables require you to make the COM_get_camera; call atleast once prior to getting or setting the
value.
_camera_pos_x - Get or set the camera x position. Value is an integer 65536 = 1m
_camera_pos_y - Get or set the camera y position.
_camera_pos_z - Get or set the camera z position.
_camera_heading - Get or set the camera heading. Value is in radians 0 - 65536. You can also use + and - values from the center heading.
_camera_pitch - Get or set the camera pitch. Value is the same as heading.
_camera_roll - Get or set the camera roll. CURRENTLY NOT SUPPORTED BY INSIM
_camera_viewplayer - Get or set which player to view. Value is an integer, 0 = poll, 1 = second etc
_camera_ingamecam - Get or set the ingame camera. Value is an integer. 0 = Arcade View, 1 = Helicopter View,
     2 = TV Camera View, 3 = Driver View, 4 = Custom View.
_camera_fov - Get or set the camera FOV (field of view). Value is an integer.
_camera_time - Get or set the camera smoothing time. Value is an integer. Use time to set the smoothness of the
     camera movement. Pass the smoothing in hundredths.
_camera_flags - Get or set the camera packet flags. Flags are switches which tell LFS what to do. You can see a
     full list in the LFS InSim readme, I have added some to the default script.
_current_step_time - This is a read-only value and returns the current step amount in LFSMM2. The step amount is
     how many hundredths of a second LFSMM2 is advancing the time in LFS.
NOTE: these next variables require you to make the COM_start_outsim call prior to getting the values.
_outsim_time - Get the current time to the next check order. (not really needed)
_outsim_angularvelocity_x - Get the current cars x angular velocity. Value is a single
_outsim_angularvelocity_y - Get the current cars y angular velocity.
_outsim_angularvelocity_z - Get the current cars z angular velocity.
_outsim_heading - Get the current cars heading. Value is in radians 0 - 65536.
_outsim_pitch - Get the current cars pitch. Value is in radians 0 - 65536.
_outsim_roll - Get the current cars roll. Value is in radians 0 - 65536.
_outsim_acceleration_x - Get the current cars x acceleration. Value is a single
_outsim_acceleration_y - Get the current cars x acceleration.
_outsim_acceleration_z - Get the current cars x acceleration.
_outsim_velocity_x - Get the current cars x velocity. Value is a single
_outsim_velocity_y - Get the current cars y velocity.
_outsim_velocity_z - Get the current cars z velocity.
_outsim_position_x - Get the current cars x position. Value is an integer 65536 = 1m
_outsim_position_y - Get the current cars y position.
_outsim_position_z - Get the current cars z position.
Other Information:
Just as a small pointer it might be worth looking at some Delphi and Pascal examples to see some more code
samples. The syntax is slightly different to other languages but still works the same.