How to create a file-clone "addBox.lua" for ViDiBa?

Discuss Celestia's features, adaptations and Addons for use in educational environments
Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

How to create a file-clone "addBox.lua" for ViDiBa?

Post #1by Croc » 25.08.2016, 20:22

For a collection of asteroids 3100, I created a virtual discrete base (ViDiBa), which is controlled by 26 addons, placed in a folder adds.
One addon enables / disables the 200 asteroids.
Here are kind of the first 200 Main Belt asteroids:

Image

I created a file-clone "addsBox.lua" for addons ViDiVa.
Name clone "ViDiBaBox.lua". The cloned file replaced all references, for example:

Original "addsBox.lua":

Code: Select all

-- Set the height of the Adds window.
local nadds = table.getn(adds);
nAddsLinesMax = math.max(4, math.min(addon_list_nlines, nadds));
addsFrameWidth, addsFrameHeight = 250, 110 + (20 * nAddsLinesMax);
addsScrollbarFrameW, addsScrollbarFrameH = 9, addsFrameHeight  - 110 - 20;


File-clone "ViDiBaBox.lua":

Code: Select all

-- Set the height of the ViDiBa window.
local nViDiBa = table.getn(ViDiBa);
nViDiBaLinesMax = math.max(4, math.min(addon_list_nlines, nViDiBa));
ViDiBaFrameWidth,  ViDiBaFrameHeigh = 250, 110 + (20 * nViDiBaLinesMax);
ViDiBaScrollbarFrameW,  ViDiBaScrollbarFrameH = 9,  ViDiBaFrameHeight  - 110 - 20;


Added 25.08.2016, 06:56:
Separately works correctly the original file "addsBox.lua" and file clone "ViDiVaBox.lua".
Together working the original file is only "addsBox.lua".
The conflict over the "adds" folder. If you create a "ViDiBa" folder, then ViDiVaBoks.lua it does not see.
Experts Lua language, help to understand the problem.
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

Post #2by John Van Vliet » 26.08.2016, 19:21

that dose not look to be a "? clone?" ????? of a file
a "clone" is a copy

Code: Select all

cp fileName.txt /new/location



the above looks more like a "search and replace "


for that look as using the sed or awk commands with grep

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #3by Croc » 26.08.2016, 21:45

John Van Vliet, thank you for trying to help solve my problem. Sorry, but I do not know English. I use Google translator. I'm not sure what is right I explained the problem. I will try in the next message to state the problem more clearly.
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 1 month
Location: Paris France

Post #4by jogad » 26.08.2016, 22:59

I think I understand your problem but I don't really have a solution for you.
You try to make another program from a previous one with the same structure.

There are many reasons why two program can conflict together.

Your bug description is not precise enough to figure out where does the problem come from.
The context and the circumstances of the bug are missing and the few lines of code that you show don't help very much.

However, the main reason is that one or several variables are unexpectedly shared between the two programs.
By default variables are global and shared between all the lua modules.
Unless you have a strong reason to do otherwise, a variable which is intended to be used in only one module should be declared as local.

Another reason is the use of an uninitialized variable.
Think of declaring all your variables before using them.

The problem of language is a real one.
I did exactly like you when I was on the Russian forum.
As I don't even know a word in Russian, I translated my text from French to Russian and then I checked the translation from Russian to French.
Usually it was barely understandable. So I modified the French text until the reverse translation from Russian to French give a correct result.
The tip is to make sentences as simple and short as possible.

For English native speakers : Please think that English is not the mother tongue of everyone.
If I try to translate 'dose' instead of 'does' the result is not as expected. Google has trouble with misspelled words.

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #5by Croc » 27.08.2016, 15:24

Jogad wrote:I think I understand your problem but I don't really have a solution for you. You try to make another program from a previous one with the same structure.

This is the correct interpretation of problem.

Your bug description is not precise enough to figure out where does the problem come from. The context and the circumstances of the bug are missing and the few lines of code that you show don't help very much.

A detailed description of task: Create a new tool - analogue addsBox.lua.

Changes in the structure of files:

Image

Changes in Lua Edu Tools Configuration File:

Image

Image

Creating ViDiBaBox.lua file
  • Creating a copy of the file addsBox.lua. Renaming copy to ViDiBaBox.lua
  • Change the text "adds" to "ViDiBa"
  • Change the text of "add" to "VDB" - it was a mistake !!!

Result:

Image

Image

Jogad, thank you! I will consider Your advice is in the future.
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 1 month
Location: Paris France

Post #6by jogad » 28.08.2016, 01:16

As I had guessed, the problem was primarily a conflict between program variables.
Lua edu Tools and more LUT handle a considerable number of variables and it is impossible to retain all.
Except for variables that require communication between modules, all other variables should always be declared as local.
Use of undeclared variables can also cause problems.

I modified the code addsBox.lua considering all that and now it works.


Image


Here are the modified addsBox.lua and VidibaBox.lua files
Attachments
boxes.zip
(5.59 KiB) Downloaded 383 times
Last edited by jogad on 28.08.2016, 09:07, edited 1 time in total.

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #7by Croc » 28.08.2016, 02:35

Jogad, thank you for a master class.

I do not see the image:
Image
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 1 month
Location: Paris France

Post #8by jogad » 28.08.2016, 09:11

Croc wrote:I do not see the image

I have edited the post. Do you see it now ?
:cyclop:

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #9by Croc » 28.08.2016, 10:02

I can see the image. Ok!
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #10by Croc » 28.08.2016, 20:05

Translation of "Panel ViDiBa" in French - fr.lua file

Spoiler

Code: Select all

-- ViDiBaBox
    -- ceinture d'ast?ro?des demi-grand axe = ~Ast?ro?des d.-g. axe
   ["ViDiBa asteroids:"] = "ViDiBa ast?ro?des:";
        ["Asteroids00"] = "Ast?ro?des Ma Liste";
        ["Asteroids01"] = "Ast?ro?des d.-g. axe 1,8-2,3531 u.a.";
        ["Asteroids02"] = "Ast?ro?des d.-g. axe < 2,4628 u.a.";
        ["Asteroids03"] = "Ast?ro?des d.-g. axe < 2,6083 u.a.";
        ["Asteroids04"] = "Ast?ro?des d.-g. axe < 2,67908 u.a.";
        ["Asteroids05"] = "Ast?ro?des d.-g. axe < 2,76531 u.a.";
        ["Asteroids06"] = "Ast?ro?des d.-g. axe < 2,8691 u.a.";
        ["Asteroids07"] = "Ast?ro?des d.-g. axe < 3,01028 u.a.";
        ["Asteroids08"] = "Ast?ro?des d.-g. axe < 3,0853 u.a.";
        ["Asteroids09"] = "Ast?ro?des d.-g. axe < 3,1415 u.a.";
        ["Asteroids10"] = "Ast?ro?des d.-g. axe < 3,16796 u.a.";
        ["Asteroids11"] = "Ast?ro?des d.-g. axe < 3,21186 u.a.";
        ["Asteroids12"] = "Ast?ro?des d.-g. axe < 4,3058 u.a.";
        ["Asteroids13"] = "Atira";
        ["Asteroids14"] = "Aton";
        ["Asteroids15"] = "Apollon";
        ["Asteroids16"] = "Amours";
        ["Asteroids17"] = "Mars-crosser";
        ["Asteroids18"] = "Centaures";
        ["Asteroids19"] = "Ceinture de Kuiper";
        ["Asteroids20"] = "Disque dispers?";
        ["Asteroids21"] = "Trojans";
        ["Asteroids22"] = "Damoclo?de";
        ["Asteroids23"] = "Dehors de la classe";
        ["Asteroids24"] = "Syst?me";

Image
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #11by Croc » 31.08.2016, 13:05

Buttons scrollUpButton and scrollDownButton not work.
This decorative buttons ? How to their step up - one click and the slider moves the list one line down / up?

Image
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 1 month
Location: Paris France

Post #12by jogad » 31.08.2016, 21:12

Croc wrote:This decorative buttons ?

Yes! :twisted:

Though, with a little extra work, you can improve it!

Exerpt from the original "Lua Edu Tools" readme.txt by Vincent Giangiulio :
The Lua Edu Tools can be freely used/copied/modified/distributed for non-commercial activities.

.

Avatar
Topic author
Croc M
Forum Admin
Posts: 437
Joined: 10.08.2016
With us: 8 years 2 months
Location: Udomlya, Tver region, Russia

Post #13by Croc » 31.08.2016, 22:13

It is a pity that Vincent Giangiolio does not come on reconstructed forum ... :sad:
Creator of the GUI "Lua Universal Tools"
25/V/1947 - 30/III/2019


Return to “Celestia in Education”