Files
BusyRabbit/Content/Lua/Utils/DataTableUtils.lua

39 lines
1.1 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local DataTableUtils = {}
local BusyGamePlayLibrary = import("BusyGamePlayLibrary")
function DataTableUtils.GetDataTable(table_name)
return BusyGamePlayLibrary.GetGameDataTable(table_name)
end
function DataTableUtils.GetDataTableRow(table_name, row_name)
local data_table = DataTableUtils.GetDataTable(table_name)
if not data_table then
return nil
end
return data_table:FindRow(row_name)
end
--[[
LuaExtensionMethod.cpp:22-28
// 封装函数示例
static int FindRowWrapper(lua_State* L) {
UDataTable* dataTable = LuaObject::checkUD<UDataTable>(L, 1);
FName rowName = LuaObject::checkValue<FName>(L, 2);
UScriptStruct* rowStruct = LuaObject::checkUD<UScriptStruct>(L, 3);
// 使用反射调用 FindRow
uint8* rowData = dataTable->FindRowUnchecked(rowName);
if (rowData && rowStruct) {
// 将结果推送到 Lua
return LuaObject::pushStruct(L, rowStruct, rowData);
}
return LuaObject::pushNil(L);
}
这段代码中pushStruct只接受两个参数如何改
]]
return DataTableUtils