require instruction LET and LUT5

All about writing scripts for Celestia in Lua and the .cel system
Topic author
gironde M
Posts: 406
Joined: 16.12.2016
Age: 67
With us: 2 years 10 months
Location: Montigny-Les-Metz, Grand Est, Lorraine, Moselle, France

require instruction LET and LUT5

Post #1by gironde » 16.07.2018, 10:14

In the LET and LUT modules, the "require" statement is often found at the beginning of the script.

This instruction tells the program to load the corresponding Lua module.

for example: require "pCXBox" load module pCXBox.lua

since we find the same load in many LET and LUT modules, the program spends a lot of time trying to load it when it is already loaded. In this case, this instruction becomes useless because it is a repetition.

Generally, the modules called by require are already loaded by lua_universal_tools.lua, config.lua or the modules coming from lua_application. The only 'require' instructions that should remain are those that use new modules.

the first module loaded with Celestia and luahookinit.lua is "lua_universal_tools" in a LUT5 configuration and "lua_edu_tools" in a LET configuration.

Some LET modules are reused with LUT5.

You have to be very careful if you decide to purge the scripts and check which script loads the module first (in case you have to keep the call). Once loaded, the following calls with require are no longer needed.
The biggest difficulty lies in the LET modules used in LUT5. If in doubt keep 'require' calls.

Before making any changes, make a backup copy in your pc.

The speed of the LUA language comes from the fact that it does not control error. Any error in the script prevents the module concerned from loading and thus will create subsequent operating errors.

Rather than dropping the 'require' statements, put them in commentary behind "-"

Given the latest addon creations on the forum, the guides for 'spacecraft' are in overhaul so you do not want to have some files listed in the table attached.

(12.35 KiB) Downloaded 41 times

Return to “Scripting”

Who is online

Users browsing this forum: 7 guests