I will put here what I find contrary to programming in LUA.
- first :
-----------------------------------------------------------------------
FNeb003Box.Action = (function()
return
function()
local obj = celestia:find("Frosty Leo Nebula")
celestia:select(obj)
local sel = celestia:getselection()
if not(empty(sel)) then
obs:follow(sel)
obs:goto(sel)
end
end
end) ()
-----------------------------------------------------------------------
the code should simply be:
Code: Select all
FNeb003Box.Action = function()
local obj = celestia:find("Frosty Leo Nebula")
celestia:select(obj)
local sel = celestia:getselection()
if not(empty(sel)) then
obs:follow(sel)
obs:goto(sel)
end
end
all the LUT5 lua scripts were written this way (note that they still work)
- second :
:text(_("Frosty Leo"))
can be written like this :
Code: Select all
:text("Frosty Leo")
simpler !
Added after 29 minutes 55 seconds:
a table in Lua is a list of data which are used by a program responsible for retrieving them for use in a part of the program.
generally they are written this way:
name_of_table = {n,n+1,n+2,n+3}
or
name_of_table =
{
n,
n+1,
n+2,
n+3
}
the comma after each element is required. (it is often a mistake that we look for a long time)
note that your language file is a Lua table.
a comma error will block the entire program.
-------------------------------------------------------------------
the semicolon (;) at the end of the instruction line is not necessary and does not replace the comma (,) in a table.
Added after 4 minutes 34 seconds:
Caution: when you modify a code in a Lua module, always make a backup copy of your file and test your modifications.
Added after 29 minutes 31 seconds:
This is what we find throughout the code in LUT5
name_of_box.Customdraw = function
name_of_button.Action = function
???
An Box, an frame, an button is the same for Lua. This is an object.
They all look like this :
FNeb001Box = CXBox:new()
:init(0, 0, 0, 0)
:bordercolor(cbubordoff)
:textfont(smallfont)
:textcolor({0,0.69,0.94,1})
:textpos("center")
:movetext(-3, 10)
:text("Name")
:movable(false)
:active(false)
:attach(FNebFrame, 2, 2+14*(gg-1), 190, 5+14*1)
CXBox:new() is the subroutine that creates the box.
all the lines that follow and starting with (:) are properties of the box (dimensions, color, displayed text, visibility, activity, ...)
When an box must be active, you must put your property: Active (true).
A click on the box will activate the corresponding code. Active = function (the function must have the same name as the box)
the .Customdraw functions are in fact the body of your LUT5 program and their instructions are executed constantly without intervention.
It is important to remember that the code begins to be executed as soon as a module (.lua file) is loaded.
So you have to pay careful attention to the loading order.
A module, in its Customdraw, must not refer to an object which is not yet loaded.
Added after 1 hour 38 minutes:
to be continued