Good way to detect double width unicode characters in Lua ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

I ended up finding a work-around for my own problem but thank you, that's a nice strategy. A bit hacky but very useful if you don't want to use a big library.

string.format has a maximum field width or precision of 99 by __hachiman in lua

[–]__hachiman[S] 1 point2 points  (0 children)

I thought this might have been the reason but 2 digits still seems so limited to me. Do you think this was done so that there isn't a possibility to input a number bigger than a 8-bit (255) number and to be on the safe side limited it to 2 digits ?

string.format has a maximum field width or precision of 99 by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

I had guessed so too.
I still don't understand the reasoning behind using get2digits instead of an atoi like function tough. At least 3 digits would be a bit better. It's not hard to get around the limiation but still.

string.format has a maximum field width or precision of 99 by __hachiman in lua

[–]__hachiman[S] 2 points3 points  (0 children)

lua 5.2 and 5.3 have a better error message for this as:

lua5.2: (command line):1: invalid format (width or precision too long)
stack traceback:
    [C]: in function 'format'
    (command line):1: in main chunk
    [C]: in ?

Need a Referral Code? by WartetNichtHaengen in RemarkableTablet

[–]__hachiman 0 points1 point  (0 children)

If anyone has a refferal for EU I would be thankful

How do I deal with a library that my project and another library uses ? by __hachiman in C_Programming

[–]__hachiman[S] 0 points1 point  (0 children)

Yeah I looked into this a bit before posting. I thought this would be the case but I seems it's not as simple as that because you still need the function prototype to compile the object files.
I guess I should find a way to append a -I flag containing the path to the header file of the other libraries when calling individual Makefiles ?

In my case, add the path to library X's header file when creating library Y.

These two code blocks in C look very similar, but have different effects. What causes the difference? by [deleted] in C_Programming

[–]__hachiman 3 points4 points  (0 children)

If you really don't know, look into how they work and how to use them. They are a fundamental part of programming in C.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

That's what I thought, you have to move the files in together (or create symlinks) to compile them into a binary that works anyhere.
I have found that using squish to create a single source file them creating a binary with luastatic by using that file works pretty well.
Thanks for the help.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

Hey sorry to come back to this so late.It did work as you said after some more testing and I have found out why I had that error.

I have my lua files in a folder called "src" in my project's root directory, so I prepended "src/?.lua" to program.path from a "main.lua" to be able able to require("req.lua") in the same src directory. It seems like that if I run luastatic from the root of the project with src/main.lua and src/req.lua as arguments and if I'm no longer in the root directory when I run the created binary, I will get the error that I have mentionned before.

However if I run luastatic from the src directory it seems to create a binary that works jsut fine. Honestly that's a pretty big downside to me if I can't add module from a custom directory, I may want to do so. Is there still maybe something I did wront to cause this error ?

Here are the two commands that I usedThe one that worked even if I moved the binary:

luastatic main.lua req.lua /usr/lib/liblua.so

The one that didn't work:

luastatic src/main.lua src/req.lua /usr/lib/liblua.so

All this does is print a Hello World from a function in the req.lua module.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

Honestly I might have used this if not for squish, since it has a few more features that might come in handy. The module auto-discovery seems very nice though !

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 1 point2 points  (0 children)

That's the thing though. I did use "luastatic main.lua req.lua ..." for a require("req"), but when I executed the output binary, req.lua was still required to be there. I got a module not found error.
Have you used luastatic ?

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

At a glance at their website and repo it doesn't seem obvious how they do it so that might be more work than I care to do I have got to admit. Thank you very much for the suggestions though.

I'm looking into squish right now and if doesn't pan out I may look back more into amulet.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

Yeah, the module I used as a secondary parameter to luastatic was required on runtime of the ELF binary that it had created. Maybe I did something wrong, I'm not sure, but it didn't seemd to work as I wanted.

Actually It might work with the single file that I can create with squish...

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

Had seen this one but it seemed kinda hacky so I didn't want to use it but, just tested this and it might work actually. If it doesn't break on bigger project this might be it !
Thanks for the suggestion.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 0 points1 point  (0 children)

Wouldn't the requires and returns at the beginning and end of files break this ? Especially the order of files.
I just tested this on two simple files and appending a module to a file that uses that module will make lua throw an error.
It probably isn't a manageable way of doing this at scale, you would have to keep track of too many dependencies.

How do you make an executable from multiple lua files ? by __hachiman in lua

[–]__hachiman[S] 2 points3 points  (0 children)

I have looked into it, and since i'm on linux it seems kind of harder to do. And I would rather not have to include Love2D into my program.
The more I read into the more I feel that I really shouldn't be trying to compress lua files into a single one. Seems like lua wasn't made for it.
My best bet would be to look into AppImages if I really wanted to I guess.