Updating Lua plugins
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
-
Topic authorSevenSpheres
- Moderator
- Posts: 826
- Joined: 08.10.2019
- With us: 5 years 1 month
Updating Lua plugins
Sometime after version 1.7 Celestia will drop support for Lua 5.1, so all Lua plugins need to be updated to the latest version (5.3 or maybe 5.4). I've tried to update the Lua Edu Tools by replacing "table.getn(foo)" with "#foo". When I did this in Celestia 1.6.2-beta1 (which doesn't support Lua 5.1) I saw this:
Obviously some other code needs to change, but I don't know what that is. Can someone who knows more about Lua help with this?
Obviously some other code needs to change, but I don't know what that is. Can someone who knows more about Lua help with this?
My Addons: viewtopic.php?f=23&t=19978 • Discord server admin
Celestia versions: 1.5.1, 1.6.1, 1.6.2, 1.7.0, and some unofficial versions like Celestia-ED
Celestia versions: 1.5.1, 1.6.1, 1.6.2, 1.7.0, and some unofficial versions like Celestia-ED
- Lafuente_Astronomy
- Moderator
- Posts: 726
- Joined: 04.08.2018
- Age: 26
- With us: 6 years 3 months
- Location: Cebu City, Cebu Province, Philippines
- Contact:
I have been working on restoring getn since the # symbol annoys me.
However, in my research I came across an actual reason to restore it.
getn works with lua tables, # does not.
Which means that as long as you use generic arrays, everything is fine.
If you use tables however, it does not.
I can not say anyone ever will or will not use tables, but a difference is a difference.
The code for # walks the array to count, where getn retrieves the size from the structure itself.
getn works the same regardless of the type, # does not.
Plenty of reason for me to keep the former, while leaving but ignoring the latter.
Janus.
EDIT: added for quick reference.
https://stackoverflow.com/questions/31452871/tabl ... n-i-get-the-length-of-an-array
However, in my research I came across an actual reason to restore it.
getn works with lua tables, # does not.
Which means that as long as you use generic arrays, everything is fine.
If you use tables however, it does not.
I can not say anyone ever will or will not use tables, but a difference is a difference.
The code for # walks the array to count, where getn retrieves the size from the structure itself.
getn works the same regardless of the type, # does not.
Plenty of reason for me to keep the former, while leaving but ignoring the latter.
Janus.
EDIT: added for quick reference.
https://stackoverflow.com/questions/31452871/tabl ... n-i-get-the-length-of-an-array
- gironde
- Posts: 851
- Joined: 16.12.2016
- Age: 72
- With us: 7 years 11 months
- Location: Montigny-Les-Metz, France
LUT5 has been tested with celestia 1.6.1 and celestia EP V3 (1.7.0 5229 from the Russian Celestia website). The executables (32 bits) are mounted with LUA 5.1.
The lua modules of LUT5 use the table statement: getn (your_table).
Celestia 1.6.2 installer (32 / 64bit) is mounted in its beta version 1 with lua 5.2 / lua 5.3.
First observation: the installer does not leave the choice between 32 or 64 bits; if you have a 64-bit PC, it will install the 64-bit version. I found that it did not suit me because to test my achievements in lua, I use DECODA debugger that works only 32 bits.
Then: once celestia 1.6.2 64 bit installed, it seems to work very well. When I copied my extras and lua_applications, I got an error message about table: getn (). I searched all the getn and replaced them with # to comply with lua5.1, 5.2, 5.3.
Once done, I restarted clestia 1.6.2 64 bits and now loading files stops after a while without message.
The change of getn by #, I did it also in my old versions celestia 1.6.1 and celestia EP V3. In its versions, everything works correctly with #.
Why celestia 1.6.2 (64 bits) crashes at loading, I do not know either because.
For the problem of Janus:
Maybe Janus uses other types of lua tables for which change by # is not appropriate. I do not know.
The image of Janus shows a disturbance in celestia's display at the top left but not in his menu lua_applications. Is there not a font problem? Does this problem occur only with the change by #?
The lua modules of LUT5 use the table statement: getn (your_table).
Celestia 1.6.2 installer (32 / 64bit) is mounted in its beta version 1 with lua 5.2 / lua 5.3.
First observation: the installer does not leave the choice between 32 or 64 bits; if you have a 64-bit PC, it will install the 64-bit version. I found that it did not suit me because to test my achievements in lua, I use DECODA debugger that works only 32 bits.
Then: once celestia 1.6.2 64 bit installed, it seems to work very well. When I copied my extras and lua_applications, I got an error message about table: getn (). I searched all the getn and replaced them with # to comply with lua5.1, 5.2, 5.3.
Once done, I restarted clestia 1.6.2 64 bits and now loading files stops after a while without message.
The change of getn by #, I did it also in my old versions celestia 1.6.1 and celestia EP V3. In its versions, everything works correctly with #.
Why celestia 1.6.2 (64 bits) crashes at loading, I do not know either because.
For the problem of Janus:
Maybe Janus uses other types of lua tables for which change by # is not appropriate. I do not know.
The image of Janus shows a disturbance in celestia's display at the top left but not in his menu lua_applications. Is there not a font problem? Does this problem occur only with the change by #?
-
- Site Admin
- Posts: 706
- Joined: 22.09.2018
- With us: 6 years 2 months
Both getn and # are crap:
With luajit I have:
# works with continuous "arrays" only. getn was deprecated in 5.1, so it's barely legal in 5.1 syntax.
To answer the question "why we want to use lua5.3 or later":
LuaJIT provides support for 5.1 syntax but it's not actively maintained, the latest update was 9 months ago.
Code: Select all
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
local array = {5, "text", {"more text", 463, "even more text"}, "more text"}
array[10] = 1;
print(#array)
print(table.getn(array))
print(tablelength(array))
With luajit I have:
Code: Select all
4
4
5
# works with continuous "arrays" only. getn was deprecated in 5.1, so it's barely legal in 5.1 syntax.
To answer the question "why we want to use lua5.3 or later":
The last release was Lua 5.1.5, released on 17 Feb 2012. There will be no further releases of Lua 5.1.
LuaJIT provides support for 5.1 syntax but it's not actively maintained, the latest update was 9 months ago.
Speaking strictly for myself and no one else.
I am patching getn back in to the lua 5.3 library I use.
Then I will have a personal lua fork to go with my personal celestia fork.
Actually, I will use this fork in all my stuff where I have lua as my script.
I had no intention of forking more than celestia since I dislike QT, but it looks like that has changed.
I know I am the minority, but I prefer clarity and readability over shorthand.
Visual flow during analyses is important to understanding logic.
getn makes sense visually, # is just noise, to me at least.
I will put my code when I have it done, and made a place to put it.
Janus.
I am patching getn back in to the lua 5.3 library I use.
Then I will have a personal lua fork to go with my personal celestia fork.
Actually, I will use this fork in all my stuff where I have lua as my script.
I had no intention of forking more than celestia since I dislike QT, but it looks like that has changed.
I know I am the minority, but I prefer clarity and readability over shorthand.
Visual flow during analyses is important to understanding logic.
getn makes sense visually, # is just noise, to me at least.
I will put my code when I have it done, and made a place to put it.
Janus.
-
Topic authorSevenSpheres
- Moderator
- Posts: 826
- Joined: 08.10.2019
- With us: 5 years 1 month
@SevenSpheres
The best place to learn about LUA, is https://www.lua.org, which has good guides and documentation.
You can find lists of additions and deprecations there by looking through release notes.
I am not a good guide to lua, or large project programming in general really, I tend to make my own tools.
Just like in my own fork I use local to the project copies of support libraries because I like to know the exact state when I compile.
I also sometimes struggle since cmake is incompatible with my setup.
The LUA function I am adding back is because I dislike what replaces it, which does not visually or mentally flow for me.
There is zero requirement for anyone else to use it even if they use my fork.
Janus.
The best place to learn about LUA, is https://www.lua.org, which has good guides and documentation.
You can find lists of additions and deprecations there by looking through release notes.
I am not a good guide to lua, or large project programming in general really, I tend to make my own tools.
Just like in my own fork I use local to the project copies of support libraries because I like to know the exact state when I compile.
I also sometimes struggle since cmake is incompatible with my setup.
The LUA function I am adding back is because I dislike what replaces it, which does not visually or mentally flow for me.
There is zero requirement for anyone else to use it even if they use my fork.
Janus.
-
Topic authorSevenSpheres
- Moderator
- Posts: 826
- Joined: 08.10.2019
- With us: 5 years 1 month
Janus:
On lua.org I don't see any changelogs or guides for updating old scripts. (That doesn't mean there aren't any, I may have just missed them.) Do you know where I can find either of these?
On lua.org I don't see any changelogs or guides for updating old scripts. (That doesn't mean there aren't any, I may have just missed them.) Do you know where I can find either of these?
My Addons: viewtopic.php?f=23&t=19978 • Discord server admin
Celestia versions: 1.5.1, 1.6.1, 1.6.2, 1.7.0, and some unofficial versions like Celestia-ED
Celestia versions: 1.5.1, 1.6.1, 1.6.2, 1.7.0, and some unofficial versions like Celestia-ED
-
- Site Admin
- Posts: 706
- Joined: 22.09.2018
- With us: 6 years 2 months
SevenSpheres wrote:On lua.org I don't see any changelogs or guides for updating old scripts.
Check a document called Lua X.Y Reference Manual, section Incompatibilities with the Previous Version,
https://www.lua.org/manual/5.1/manual.html#7
https://www.lua.org/manual/5.2/manual.html#8
https://www.lua.org/manual/5.3/manual.html#8
- gironde
- Posts: 851
- Joined: 16.12.2016
- Age: 72
- With us: 7 years 11 months
- Location: Montigny-Les-Metz, France
For my part, I dropped the site https://www.lua.org/manual/5.1 because it is very difficult to learn a programming language in a foreign language. I found this:
https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/
It's in French.
The replacement of table.getn () with # is noted in this tutorial.
I agree with janus, table.getn () was much more talk than #
https://wxlua.developpez.com/tutoriels/lua/general/cours-complet/
It's in French.
The replacement of table.getn () with # is noted in this tutorial.
I agree with janus, table.getn () was much more talk than #
I think I have chased down all the bits of getn.
I should have Lua 5.3 with getn restored today.
Once I have finished getting my existing VS project files to work with the latest commit, I will post exes for people to test.
This may take a few days as I juggle work.
A current customer asked if I could over clock their equipment by upping the mains frequency.
I treated it as him asking humorously.
Janus.
I should have Lua 5.3 with getn restored today.
Once I have finished getting my existing VS project files to work with the latest commit, I will post exes for people to test.
This may take a few days as I juggle work.
A current customer asked if I could over clock their equipment by upping the mains frequency.
I treated it as him asking humorously.
Janus.
Okay, question for the crowd.
Restoring getn is involved.
Its function is dependent on internal structures which have changed.
getn treats tables and arrays the same, # only works on arrays.
My question is this.
Do I restore just the name, which is mostly straightforward, but will leave getn working just like #.
Or do I continue and fully restore the getn functionality.
I ask because the only real difference is that getn returns the size of tables reliably, which # does not.
Is that difference worth the effort, or possible impact on lua speed if there is any.
Janus.
Restoring getn is involved.
Its function is dependent on internal structures which have changed.
getn treats tables and arrays the same, # only works on arrays.
My question is this.
Do I restore just the name, which is mostly straightforward, but will leave getn working just like #.
Or do I continue and fully restore the getn functionality.
I ask because the only real difference is that getn returns the size of tables reliably, which # does not.
Is that difference worth the effort, or possible impact on lua speed if there is any.
Janus.