forked from Tencent/UnLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorialObject.cpp
More file actions
42 lines (35 loc) · 1008 Bytes
/
TutorialObject.cpp
File metadata and controls
42 lines (35 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "TutorialObject.h"
#include "LuaCore.h"
#include "UnLua.h"
#include "UnLuaEx.h"
FTutorialObject::FTutorialObject()
{
}
static int32 FTutorialObject_New(lua_State* L)
{
const auto NumParams = lua_gettop(L);
if (NumParams != 2)
{
UNLUA_LOGERROR(L, LogUnLua, Log, TEXT("%s: Invalid parameters!"), ANSI_TO_TCHAR(__FUNCTION__));
return 0;
}
const char* NameChars = lua_tostring(L, 2);
if (!NameChars)
{
UE_LOG(LogUnLua, Log, TEXT("%s: Invalid tutorial name!"), ANSI_TO_TCHAR(__FUNCTION__));
return 0;
}
const auto UserData = NewUserdataWithPadding(L, sizeof(FTutorialObject), "FTutorialObject");
new(UserData) FTutorialObject(UTF8_TO_TCHAR(NameChars));
return 1;
}
static const luaL_Reg FTutorialObjectLib[] =
{
{ "__call", FTutorialObject_New },
{ nullptr, nullptr }
};
BEGIN_EXPORT_CLASS(FTutorialObject)
ADD_FUNCTION(GetTitle)
ADD_LIB(FTutorialObjectLib)
END_EXPORT_CLASS()
IMPLEMENT_EXPORTED_CLASS(FTutorialObject)