ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 3054

[C++] [Release] Lua C API - Printing a string

by IcyJake - 04-29-2018 - 05:44 AM
#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 IcyJake)");
    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]

[spoiler=Test.lua]
Code:
function printMessage()
    print("This text was printed to the console using the Lua C API!")
end
printMessage()
[/spoiler]
Reply

Users browsing: 4 Guest(s)