Page 1 of 1

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

Posted: 25.08.2016, 20:22
by Croc
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.

Posted: 26.08.2016, 19:21
by John Van Vliet
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

Posted: 26.08.2016, 21:45
by Croc
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.

Posted: 26.08.2016, 22:59
by jogad
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.

Posted: 27.08.2016, 15:24
by Croc
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.

Posted: 28.08.2016, 01:16
by jogad
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

Posted: 28.08.2016, 02:35
by Croc
Jogad, thank you for a master class.

I do not see the image:
Image

Posted: 28.08.2016, 09:11
by jogad
Croc wrote:I do not see the image

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

Posted: 28.08.2016, 10:02
by Croc
I can see the image. Ok!

Posted: 28.08.2016, 20:05
by Croc
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

Posted: 31.08.2016, 13:05
by Croc
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

Posted: 31.08.2016, 21:12
by jogad
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.

.

Posted: 31.08.2016, 22:13
by Croc
It is a pity that Vincent Giangiolio does not come on reconstructed forum ... :sad: