Lua obfuscator, how to - lua

I understand this question will appear silly but I'm clueless what to do, which makes it even more silly. I have written a lua script for a game - which works, but I've never actually run any lua with the lua programs(from the site download). I would like to obfuscate my lua code with this tool: https://github.com/mlnlover11/XFuscator but I'm unsure how to do it, I tried running the lua program and browsing there, dropping the xfuscator file on top of the program etc but nothing has given any result.How should I do it?

Open a command line (e.g. under windows, that's cmd). Go into the directory where you have your local copy of XFuscator. Make sure lua is on your PATH. Type
lua XFuscator.lua -h
This should show the help message, which will describe the next steps.

Related

Lua unexpected identifier issue in VSC

i was transfering code from my tablet's ide to VSC to tweak it and continue it on PC but i've ran into an issue. I'm trying to define a variable by using local xyz = 0 but it keeps returning SyntaxError: Unexpected identifier when i try to run it but it worked perfectly fine on my mobile IDE. (on pc i'm using Visual Studio Code with the Lua extension by sumneko and on pc i was using an app called TouchLua+)debug console output
i've tried looking it up on google but there were no posts describing any similar issue
It's hard to say without more code or context(not familiar with the touchapp) but this as a standalone piece of lua is valid.
However notice your debug screenshot, you are executing a piece of lua with nodejs, Look at the cli
C:\ProgramFiles\nodejs\node.exe RPSbot.lua
^ ^
| |
Path to node |
your lua file given to the node.exe
Unsure if there is some other js process that you used on your tablet that ran lua via nodejs or you are trying this from js yourself. But nodejs is intended for javascript files.
Using node on this piece of code produces the same error. You should run this using the lua runtime. If you haven't already, you can download lua here, be sure to add it to your path if needed.
Then you can run it from cli as following:
lua RPSbot.lua
Or create a batch script to call it by name without lua before it, i.e. create a file called RPSbot.cmd or RPSbot.bat and place calling code in it lua RPSbot.lua. The calling code might need to use the full path to lua and your script. Then you can just run that batch script each time.
If it is intended to run trough node you might need to provide more code and/or context.
Use Zerobranestudio or jdoodle. I give up to compile Lua with vsc.

How to install Lua GUI in ZBS IDE

I am completely new to programming in Lua outside a sandbox.
I have found a library called Lua GUI that I'd like to use (https://github.com/williamwilling/luagui/). I have still not understood how to quite install the library, and how I even go about using it.
That's part 1 of my question; How can I install Lua GUI(or an library for that matter), and then how do I go about actually using it? By that I mean, is it as simple as writing a program that starts with "require "gui"" and then running it, or is there more to it?
Part 2 of my question is then how do I go about installing it as a package for ZeroBrane Studio IDE, I have no idea at all what the readme file is instructing me to do so I would be grateful if someone could clarify.
If you copy the contents of the src folder in the luagui project to your project directory you should be able to call:
local gui = require("gui")
in your main Lua file and use it that way.

Can love2d programs be run as normal Lua programs?

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.

Running a lua program from a text file

I've just started learning Lua, and I'm trying to get the native Lua interpreter to run a program that has been saved to a .txt file. I'm running Windows Vista with Lua 5.1.4.
Perhaps I'm missing something, but the only thing my book (Programming in Lua) says is that all you have to do to run your program is to call the interpreter with the name of the text file that contains your program. Then it gives this supposedly handy piece of code:
% lua filename.lua
Which I can't get to work in cmd or in the Lua interpreter. Further research I've done indicates that I might need to use a
dofile("filename.lua")
command, but I'm not sure how to do this. Specifically, what information do I need to put in the argument? Any help you can give is greatly appreciated.
You need to download a Win32 binary (see lua-5.2.1_Win32_bin.zip or lua-5.2.1_Win64_bin.zip here). Unzip this somewhere. How to run your script, in order of easiness and inverse order or common procedure:
Drag your script onto the Lua.exe using the Windows file Explorer.
a. Move your script to the same folder as Lua.exe
b. Shift right-click on that folder and select Open Command Window Here.
c. Type lua filename.lua and press Enter.
Add the directory containing Lua.exe to your system PATH, then do steps 2a and 2b on the folder containing your script.
Integrate Lua.exe with your editor in some way (how you do this depends on your editor).

Lua Debugger that can Attach to Process

My company has a program that uses Lua embedded in its runtime, loading up .lua files from disk and executing functions defined in them repeatedly.
Is there a way to attach to the running process and set breakpoints in my .lua files? (I'd accept either gdb-style command-line debugging as part of the Lua distribution, or perhaps a third-party IDE that provides Visual-Studio-like GUI breakpoints.)
Or is what I'm asking for entirely nonsensical and impossible given the nature of the runtime loading up random files from disk?
Edit: Looks like it's not nonsensical, given that Lua's own debug.getinfo() function can determine the source file for a given function, and debug.sethook() allows a callback for each new line of code entered. So, it's reasonable to load source code from disk and be able to tell when the interpreter is executing a particular line of code from that file. The question remains: how do I latch onto an existing process that has a Lua interpreter and inject my own trace function (which can then watch for file/line number pairs and pause execution)?
If you can modify the .lua files, you can insert the following call just before anything you need to debug:
require 'remdebug.engine'.start()
It starts the RemDebug Lua debugger engine and tries to connect to a controller. If it cannot connect, it will just continue running as normal. I did some fixes to the debugger engine, such as dealing with temporary variables, and my student is working on a debugger GUI (due next year).
In the meantime, you can try if Lua Development Tools works for you. It features a debugger similar to RemDebug, which should be possible to set up as follows:
require("debugger")(host, port, idekey)
Alternatively, you can use SciTE-debug, which is an extension to the SciTE editor, and can serve as a controller to RemDebug. Just make sure you insert the call to remdebug.engine.start somewhere in your Lua code and insert this into the SciTE output window:
:debug.target=remote.lua
When you start your program, SciTE should show the source and current line.
I've been using Decoda editor for that. It allows you to attach to a running C++ application, after that it detects that you're running a Lua Interpreter within your C++ code and show your Lua source code, where you can add beakpoints and inspect variables as usual.
This is an alternative I use after much searching. If you have an external executable that loads lua, I got this working in a few minutes. The op is very responsive, it has an interactive debugger which loads your code you can place debug points interactively. It doesn't have an editor, but I use scite or crimson editor and start the executable, one line in your main lua module enables the debugger.
http://www.cushy-code.com/grld/ - this link seems dead now
I've moved to eclipse.org/ldt it has an ide and integrated debugger, recommended
hth
The Lua plugin for IntelliJ has a working debugger with no special setup required other than pointing to your Lua interpreter.
Here's a screencast of it:
http://www.screencast.com/t/CBWIkoZPg
Similar to what Michal Kottman described, I have implemented a debugger based on RemDebug, but with additional fixes and features (on github: https://github.com/pkulchenko/MobDebug).
You can update your .lua file with require("mobdebug").start("localhost", 8171) at the point where you want the debugging to start. You can then use the command line debugger to execute commands, set breakpoints, evaluate/execute expressions and so on.
As an alternative, you can use ZeroBrane Studio IDE, which integrates with the debugger and gives you a front-end to load your code and execute same debugger commands in a nice GUI. If you want to see the IDE in action, I have a simple demo here: http://notebook.kulchenko.com/zerobrane/live-coding-in-lua-bret-victor-style.
You should probably use Decoda.
Go to Debug -> Processes -> Attach to attach your process. This should work fine.
Well the easiest way is this, thanks to the genius author
https://github.com/slembcke/debugger.lua
you don't need to setup a remote debug server ,just require one file,and simplely call dbg() and it will pause,just like gdb
an tutorial is also shipped with it, check it out.

Resources