Login Register


[C++] [Release] Lua C API - Printing a string filter_list
Author
Message
[C++] [Release] Lua C API - Printing a string #1
Download
VirusTotal

Spoiler: Lua Interpreter.cpp
Code:
#pragma comment(lib, "lua5.1.lib") #include <stdio.h> #include <string.h> #include <iostream> #include <Windows.h> extern "C" {    #include "lua.h"    #include "lauxlib.h"    #include "lualib.h" } using namespace std; int main(void) {    SetConsoleTitleA("Lua C API - Printing a string (Made by Confidential)");    lua_State *L = luaL_newstate(); // Creates our environment    luaL_openlibs(L); // Loads the libraries    luaL_dofile(L, "Test.lua"); // Runs the Lua file    lua_close(L); // Exits our environment    system("pause");    return 0; }


Spoiler: Test.lua
Code:
function infiniteLoop(time) local second = tonumber(os.clock() + time) while (os.clock() < second) do print("This text was printed to the console using the Lua C API!") end end infiniteLoop(5)
(This post was last modified: 02-04-2019, 02:22 AM by Confidential.)

Reply

RE: [C++] [Release] Lua C API - Printing a string #2
Why did you make this in C++ if you're writing C code? That's just bad practice. @"Ender"

Reply

RE: [C++] [Release] Lua C API - Printing a string #3
(04-29-2018, 05:26 AM)phyrrus9 Wrote: Why did you make this in C++ if you're writing C code? That's just bad practice. @"Ender"

That's just straight up illogical. C++ was designed to be compatible with C. People mix the two languages all the time because of libraries.
(This post was last modified: 04-29-2018, 05:36 AM by Confidential.)

Reply

RE: [C++] [Release] Lua C API - Printing a string #4
There's no point in using C++ for this, just use C.

Lua's neat in that it embeds really nicely into C programs, and it's really fast in comparison to other scripting languages (cough Python cough). You should make a tutorial on something more than just "hello world":
Here's a link to the C API documentation: https://www.lua.org/pil/24.html
And here's a link to a tutorial on calling C functions from Lua: http://www.troubleshooters.com/codecorn/...alls_c.htm
(This post was last modified: 04-29-2018, 06:44 AM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

Reply

RE: [C++] [Release] Lua C API - Printing a string #5
(04-29-2018, 05:32 AM)Confidential Wrote:
(04-29-2018, 05:26 AM)phyrrus9 Wrote: Why did you make this in C++ if you're writing C code? That's just bad practice. @"Ender"

That's just straight up illogical. C++ was designed to be compatible with C. People mix the two languages all the time because of libraries.

Common advice: Just because it works doesn't mean it's good


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

[+] 2 users Like Blink's post
Reply

RE: [C++] [Release] Lua C API - Printing a string #6
(04-29-2018, 06:45 AM)Ender Wrote:
(04-29-2018, 05:32 AM)Confidential Wrote:
(04-29-2018, 05:26 AM)phyrrus9 Wrote: Why did you make this in C++ if you're writing C code? That's just bad practice. @"Ender"

That's just straight up illogical. C++ was designed to be compatible with C. People mix the two languages all the time because of libraries.

Common advice: Just because it works doesn't mean it's good

Agree.

A simple example (on a different note) Is selecting the best pen testing tool. There's no purpose If the tool Is very user-friendly and pen tester has all the knowledge & skill set In how to use It, however the tool does not serve It's purpose In an efficient and effective manner.

Reversing the role, there's no purpose If the tool scans the network & system accordingly, Identifies vulnerabilities, prioritizes them from the most critical to the least and generates a detailed report at the end of all findings, but It's so complex to use that the pen tester has very little knowledge of how to operate It.
In this case, It "must" work both ways.

Perhaps off-topic to some extent, but the analogy gives an Indication of what to look for when approaching a task at hand.
[Image: AD83g1A.png]

Reply







Users browsing this thread: