lua write error

This commit is contained in:
milek7
2018-03-21 20:06:26 +01:00
parent 479498cedc
commit 9b602686a2
4 changed files with 13 additions and 5 deletions

View File

@@ -70,7 +70,7 @@ std::string filename_scenery() {
void WriteLog( const char *str, logtype const Type ) {
if( str == nullptr ) { return; }
if( true == TestFlag( Global.DisabledLogTypes, Type ) ) { return; }
if( true == TestFlag( Global.DisabledLogTypes, (int)Type ) ) { return; }
if (Global.iWriteLogEnabled & 1) {
if( !output.is_open() ) {
@@ -106,7 +106,7 @@ void WriteLog( const char *str, logtype const Type ) {
void ErrorLog( const char *str, logtype const Type ) {
if( str == nullptr ) { return; }
if( true == TestFlag( Global.DisabledLogTypes, Type ) ) { return; }
if( true == TestFlag( Global.DisabledLogTypes, (int)Type ) ) { return; }
if (!errors.is_open()) {

5
Logs.h
View File

@@ -11,12 +11,13 @@ http://mozilla.org/MPL/2.0/.
#include "uilayer.h"
enum logtype : unsigned int {
enum class logtype : unsigned int {
generic = ( 1 << 0 ),
file = ( 1 << 1 ),
model = ( 1 << 2 ),
texture = ( 1 << 3 )
texture = ( 1 << 3 ),
lua = ( 1 << 4 )
};
void WriteLog( const char *str, logtype const Type = logtype::generic );

View File

@@ -158,7 +158,12 @@ extern "C"
EXPORT void scriptapi_writelog(const char* txt)
{
WriteLog("lua: log: " + std::string(txt));
WriteLog("lua: log: " + std::string(txt), logtype::lua);
}
EXPORT void scriptapi_writeerrorlog(const char* txt)
{
ErrorLog("lua: log: " + std::string(txt), logtype::lua);
}
struct memcell_values { const char *str; double num1; double num2; };

View File

@@ -29,6 +29,7 @@ const char lua_ffi[] = "local ffi = require(\"ffi\")\n"
"\n"
"double scriptapi_random(double a, double b);\n"
"void scriptapi_writelog(const char* txt);\n"
"void scriptapi_writeerrorlog(const char* txt);\n"
"]]\n"
"\n"
"local ns = ffi.C\n"
@@ -88,4 +89,5 @@ const char lua_ffi[] = "local ffi = require(\"ffi\")\n"
"\n"
"module.random = ns.scriptapi_random\n"
"module.writelog = ns.scriptapi_writelog\n"
"module.writeerrorlog = ns.scriptapi_writeerrorlog\n"
"\nreturn module\n";