准备制作食材预处理流程,为lua直接读data table做基建
...
This commit is contained in:
		
							
								
								
									
										39
									
								
								Content/Lua/Utils/DataTableUtils.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Content/Lua/Utils/DataTableUtils.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| 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 | ||||
		Reference in New Issue
	
	Block a user