Can love2d programs be run as normal Lua programs? - lua

Sorry, this is a total Lua-noob question, but from what I have learned about LÖVE so far, it seems that in order to use it, you must run the love executable on a folder/.love file with a main.lua file in the root.
Is it possible, as an alternative, to write an arbitrarily-named Lua script and just require("love") instead, or do you have to start your app with the love executable? (And if so, how?)

You really need to run it with love.exe
It is possible to build love as a shared library so you could, in principle, write an openlib wrapper over it. However, to get it to work in a reasonable fashion as a lua module would need a fair amount of work.
I wouldn't want to put you off doing this if that's of interest to you but it's not really intended to work that way.

Related

Is it possible to embed perl6 in a C (or C++) program?

In perl5 it was easy to link in libperl.so, set some variables and run some code, with callbacks. Is there a story for doing this in perl6?
I think you can find the state of the art in that respect at https://metacpan.org/pod/Inline::Perl6 , which embeds Rakudo in Perl 5.
Besides what #elizabeth-mattijsen has commented, no, there's no such thing. While the perl interpreter was a monolithic thing which might be relatively easily turned into a .so library and then linked with some API endpoints, Perl 6 is two big things: a virtual machine, either Java or MoarVM, plus the interpreter, Rakudo. There could be an scenario in which you wouldn't need to embed Java or MoarVM, because both languages would be running in the same VM. Think Perl 6 embedded in Clojure, for instance. Or Perl6 embedded in 007, both running in MoarVM. That would be kind of easy, and you would be targeting a VM with the same capabilities. But C++, C and Perl6 have a very different abstract virtual machine as a target; think about the Unicode handling, or the concurrent interface. Embedding Perl6 in C would be basically running Perl6 programs from C, instead of running them from the command line.
It is possible that, in the same way Perl regexes ended all over the place, some Perl 6 capabilities, like Unicode handling or grammars, could end up ported or embedded in other languages. But I don't see a clear use case for embedding Perl in C or C++, right now, and devoting some effort for that kind of thing would be, thus, better employed in something completely different.
This isn't an answer, but suppose I've got an already existing C program which is designed to use plugins which are .dlls or .sos, and they get loaded via dlopen or LoadLibrary, an API entry point is found using dlsym or GetProcAddress, then that entry point is called with some sort of handle for the plugin to make calls back into the main process.
Now, suppose I want my plugin (inside of this .dll or .so) to load moarvm, and then run some perl6 script, which in turn uses NativeCall to call back into the main process. How would I go about doing this?
Alternatively, suppose I want my plugin (inside of this .dll or .so) to load the jvm, then run some perl6 script, etc. How would I go about doing this?
Loading perl5 just to load perl6 seems like a silly solution. It might work, but...

How can I distribute my program if it has dependencies?

So I recently wrote a chat bot which relies on lua and luasocket to respond to a twitch stream's chat. It's very basic and has various files it reads/writes to. It runs from the local computer. I finally got it working perfectly and now I'm interested in potentially distributing it to streamers who would get the most practical usage out of it.
But I can't just give them the files and lua script; they wouldn't be able to run it. They would need an interpreter and they would need to set up luasocket. With very little experience this is a very daunting task. Even I struggled to properly get luasocket working to make this bot.
So my question: Is there a way to package the lua interpreter and luasocket library such that I can give my bot to other people in an easy to use and practical manner? Preferably a .exe file, but really anything that doesn't require them to go out and set up the entire language and script dependencies on their own.

Evaluating Rascal's Performance?

I want to evaluate the performance of Rascal for a given rewrite system that I've written. I'm wondering if there's a good way of doing it?
Ideally, I'd generate some compiled Java classes from the system and then run them manually against my inputs. Is there an easy or recommended way to do it?
Cheers,
One way to do this is to use the functions in the library util::Benchmark. Typically, you could write something like
cpuType( (){ call_the_function_I_want_to_observe(); } ). This will execute your function and print the cpu time used.
Note that Rascal can be executed in two ways: interpreted and compiled which makes a big difference when measuring performance. We are working hard at the moment to fully integrate the compiler in the Eclipse IDE, but a stand alone version is available as well. This can be called as java -Xss8m -jar rascal-0.8.4-SNAPSHOT.jar --compiledREPL followed by at least values for directories for sources (--src), and binaries (--bin). Here rascal-0.8.4-SNAPSHOT.jar (but most likely named differently) is downloaded from the https://update.rascal-mpl.org/console/rascal-shell-unstable.jar.
If you need more information, don't hesitate to ask for more details: this part of our tool chain is unfortunately still undocumented.

Erlang Shell Working Directory

I am configuring Ideaj to open an Erlang REPL by setting it up as and external tool, however the working directory param is ignored. Is there a way once the REPL is open to switch the working directory?
Within the shell use the command cd("some/path") and it will work pretty much the same way you would expect from an ordinary shell.
This means you can move around your project directories and run c(module_name) and be in the local loading path as well -- which can be pretty convenient when hand-tweaking/testing things.
As an aside... most folks don't use an IDE with Erlang, because the shell has so much stuff already built into it, and your OS itself already has whatever other tools you usually want. I've yet to see someone start with an IDE and stick with it in Erlang (usually wind up becoming either Emacs users or go the vim + coreutils route).
Also, pwd() and ls() work as you'd expect.
Regarding IDEs- I find the Erlang Intellij plugin (http://ignatov.github.io/intellij-erlang/) very usable, and when doing more than relatively short one-offs in vim (with Erlang plugin) the code completion and Find Usages kinds of IDE functionality to be useful.
Give it a shot - YMMV.

Lua Bytecode to Lua human "readable"

I just got an script that I want to make some changes and I'm looking for someone to develop me a freelance job to make the loadstring that I will give readable for editing.
The Lua code is like this:
------------------------- ENGINE -----------------------------
code='\27\76\117\97\81\0\1\4\4\4\8\0\56\0\0\0\64\67\58\92\85\115\101\114\115\92\74\101\
I want it to be turned into a human code. I already searched about the subject and found that there are some tools like Chuckspy, Luadec51 and Unluac that can do this job. Anyway, I never programmed before in lua and got no compiler knowledge to perform that.
I'm looking for someone to help me, I have no idea how I'll do it.
Thanks anyway
The link of two archive:
http://www.4shared.com/file/uQguRL4D/Avani_Dice_Script_1.html
http://www.4shared.com/file/FSLbD9tA/Avani_Dice_Script_2.html
luac -l will print out the Lua bytecode in human-readable form. With a basic understanding of Lua's instruction format, this is fairly easy to manually turn into source code.
As with other languages, automatic decompilers will rarely produce source code which is useful for understanding or editing the code.

Resources