├── .gitignore ├── Config ├── DefaultEditor.ini ├── DefaultEditorPerProjectUserSettings.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content ├── Game.zip ├── Geometry │ └── Meshes │ │ ├── 1M_Cube.uasset │ │ ├── 1M_Cube_Chamfer.uasset │ │ ├── CubeMaterial.uasset │ │ └── TemplateFloor.uasset ├── LuaVM.uasset ├── MyGameInstance.uasset ├── SUE4Lua.zip ├── Vehicle │ ├── Meshes │ │ ├── BaseMaterial.uasset │ │ ├── GrayMaterial.uasset │ │ ├── OrangeMaterial.uasset │ │ ├── RoughTerrain_StaticMesh.uasset │ │ └── WhiteMaterial.uasset │ ├── Sedan │ │ ├── Materials │ │ │ ├── M_Vehicle_Sedan.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_Glass.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_Headlights.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_Paint.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_Plastic.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_TailLights.uasset │ │ │ ├── M_Vehicle_Sedan_Inst_Tires.uasset │ │ │ └── M_Vehicle_Sedan_Inst_Wheels.uasset │ │ ├── SedanVirtualJoysticks.uasset │ │ ├── Sedan_AnimBP.uasset │ │ ├── Sedan_PhysMat.uasset │ │ ├── Sedan_PhysicsAsset.uasset │ │ ├── Sedan_SkelMesh.uasset │ │ └── Sedan_Skeleton.uasset │ └── Textures │ │ ├── VehicleJoystick_BackgroundL.uasset │ │ └── VehicleJoystick_BackgroundR.uasset └── VehicleBP │ ├── Blueprints │ ├── VehicleGameMode.uasset │ └── VehicleHUD.uasset │ ├── Maps │ ├── VehicleExampleMap.umap │ └── VehicleExampleMap_BuiltData.uasset │ ├── Sedan │ ├── Sedan.uasset │ ├── Sedan_BackWheel.uasset │ └── Sedan_FrontWheel.uasset │ ├── Tutorial │ └── VehicleBlueprintDetail.uasset │ └── VehicleOverview.uasset ├── LICENSE ├── Plugins └── SilvervineUE4Lua │ ├── Config │ └── DefaultSilvervineUE4Lua.ini │ ├── Documents │ ├── HowToCreateVMAsset.md │ ├── HowToCreateVMAsset_ko.md │ ├── HowToCreateVMInstance.md │ ├── HowToCreateVMInstance_ko.md │ ├── HowToRegisterGameInstance.md │ ├── HowToRegisterGameInstance_ko.md │ ├── HowToSetupDispatchHandlerFactory.md │ ├── HowToSetupDispatchHandlerFactory_ko.md │ ├── HowToSetupFileLoader.md │ ├── HowToSetupFileLoader_ko.md │ ├── HowToSetupGameModule.md │ ├── HowToSetupGameModule_ko.md │ ├── Images │ │ ├── AddLuaVMToGameInstance.png │ │ ├── BundleFileLoader.png │ │ ├── Dispatch01.png │ │ ├── Dispatch02.png │ │ ├── Dispatch03.png │ │ ├── Dispatch04.png │ │ ├── EditingVM.png │ │ ├── EnableSUE4Lua.png │ │ ├── InitializeLuaBridge.png │ │ ├── LocalFileLoader.png │ │ ├── LuaBridge.png │ │ ├── LuaBridgeHelper.png │ │ ├── LuaValue.png │ │ ├── RegisterGameInstance.png │ │ ├── Sedan_UpdateHUDStrings_BP.png │ │ ├── SettingVM.png │ │ ├── UnitTest_AutomationLog.png │ │ ├── UnitTest_AutomationTab.png │ │ ├── VMAsset.png │ │ ├── VSCode_Debug.png │ │ ├── VSCode_Search.png │ │ ├── VSCode_Workspace.png │ │ ├── VehicleHUD_BP.png │ │ └── VehicleScreenShot.png │ ├── Library.md │ ├── Library_ko.md │ ├── LuaHotReloading.md │ ├── LuaHotReloading_ko.md │ ├── ProgrammingGuide.md │ ├── ProgrammingGuide_ko.md │ ├── README.md │ ├── README_ko.md │ ├── SUE4LuaSample.md │ ├── SUE4LuaSample_ko.md │ ├── SUE4Lua_ko.md │ ├── UE4.Color_ko.md │ ├── UE4.DateTime_ko.md │ ├── UE4.LinearColor_ko.md │ ├── UE4.Math_ko.md │ ├── UE4.PlatformTime_ko.md │ ├── UE4.PointerEvent_ko.md │ ├── UE4.QualifiedFrameTime_ko.md │ ├── UE4.Quat_ko.md │ ├── UE4.Rotator_ko.md │ ├── UE4.TextFormatter_ko.md │ ├── UE4.Timespan_ko.md │ ├── UE4.Transform_ko.md │ ├── UE4.Vector2D_ko.md │ ├── UE4.Vector_ko.md │ ├── UE4_ko.md │ ├── UnitTest.md │ ├── UnitTest_ko.md │ ├── WorkWithBlueprintDispatch.md │ ├── WorkWithBlueprintDispatch_ko.md │ ├── WorkWithDebugPrint.md │ ├── WorkWithDebugPrint_ko.md │ ├── WorkWithDirectCall.md │ ├── WorkWithDirectCall_ko.md │ ├── WorkWithLuaValue.md │ ├── WorkWithLuaValue_ko.md │ ├── WorkWithNativeDispatch.md │ ├── WorkWithNativeDispatch_ko.md │ ├── WorkWithTimer.md │ ├── WorkWithTimer_ko.md │ ├── WorkWithUEnum.md │ ├── WorkWithUEnum_ko.md │ ├── WorkWithUObject.md │ ├── WorkWithUObject_ko.md │ ├── WorkWithUStruct.md │ ├── WorkWithUStruct_ko.md │ ├── WorkWithVSCode.md │ └── WorkWithVSCode_ko.md │ ├── Resources │ └── icon128.png │ ├── SilvervineUE4Lua.uplugin │ └── Source │ ├── SilvervineUE4Lua │ ├── Private │ │ ├── Bindings │ │ │ ├── LuaActorBinding.cpp │ │ │ ├── LuaActorComponentBinding.cpp │ │ │ ├── LuaClassBinding.cpp │ │ │ ├── LuaObjectBinding.cpp │ │ │ ├── LuaSceneComponentBinding.cpp │ │ │ ├── LuaStructBinding.cpp │ │ │ └── LuaUserWidgetBinding.cpp │ │ ├── LuaAPI.h │ │ ├── LuaBindingRegistry.cpp │ │ ├── LuaBundleArchive.cpp │ │ ├── LuaBundleArchive.h │ │ ├── LuaBundleFileLoader.cpp │ │ ├── LuaCall.cpp │ │ ├── LuaCall.h │ │ ├── LuaFileLoader.cpp │ │ ├── LuaFunction.cpp │ │ ├── LuaLibrary.cpp │ │ ├── LuaLibrary.h │ │ ├── LuaLocalFileLoader.cpp │ │ ├── LuaLog.cpp │ │ ├── LuaLog.h │ │ ├── LuaNativeValue.cpp │ │ ├── LuaNativeValue.h │ │ ├── LuaStack.cpp │ │ ├── LuaStaticBinding.cpp │ │ ├── LuaThread.cpp │ │ ├── LuaUFunction.cpp │ │ ├── LuaUFunction.h │ │ ├── LuaUObject.cpp │ │ ├── LuaUObject.h │ │ ├── LuaUProperty.cpp │ │ ├── LuaUProperty.h │ │ ├── LuaUStruct.cpp │ │ ├── LuaUStruct.h │ │ ├── LuaUserData.cpp │ │ ├── LuaUserData.h │ │ ├── LuaValueReferencer.cpp │ │ ├── LuaVirtualMachine.cpp │ │ ├── Scripts │ │ │ ├── Debug │ │ │ │ ├── dkjson.lua │ │ │ │ └── vscode-debuggee.lua │ │ │ ├── Framework │ │ │ │ ├── CodeGen │ │ │ │ │ └── DefaultParameters.g.lua │ │ │ │ ├── DefaultParameters.lua │ │ │ │ ├── Prerequisite.lua │ │ │ │ ├── SUE4Lua.lua │ │ │ │ ├── SUE4LuaBinding.lua │ │ │ │ └── UE4.lua │ │ │ ├── Libraries │ │ │ │ ├── AllLIbraries.lua │ │ │ │ └── CaseInsensitiveTable.lua │ │ │ └── Tests │ │ │ │ ├── AllTests.lua │ │ │ │ ├── CoroutineTest.lua │ │ │ │ ├── PCallTest.lua │ │ │ │ ├── PerformanceTest.lua │ │ │ │ ├── TimerTest.lua │ │ │ │ ├── UEnumTest.lua │ │ │ │ └── UObjectTest.lua │ │ ├── SilvervineUE4Lua.cpp │ │ ├── SilvervineUE4LuaBridge.cpp │ │ ├── SilvervineUE4LuaSettings.cpp │ │ ├── SilvervineUE4LuaValue.cpp │ │ ├── SilvervineUE4LuaVirtualMachine.cpp │ │ └── Tests │ │ │ ├── LuaUnitTestArray.cpp │ │ │ ├── LuaUnitTestBinding.cpp │ │ │ ├── LuaUnitTestCaseInsensitiveTable.cpp │ │ │ ├── LuaUnitTestCoroutine.cpp │ │ │ ├── LuaUnitTestDelegates.cpp │ │ │ ├── LuaUnitTestFileLoader.cpp │ │ │ ├── LuaUnitTestFunction.cpp │ │ │ ├── LuaUnitTestMap.cpp │ │ │ ├── LuaUnitTestMath.cpp │ │ │ ├── LuaUnitTestPointerEvent.cpp │ │ │ ├── LuaUnitTestPrimitiveTypes.cpp │ │ │ ├── LuaUnitTestSUE4Lua.cpp │ │ │ ├── LuaUnitTestSet.cpp │ │ │ ├── LuaUnitTestTextFormatter.cpp │ │ │ ├── LuaUnitTestUE4.cpp │ │ │ ├── LuaUnitTestUEnum.cpp │ │ │ ├── LuaUnitTestUFunction.cpp │ │ │ ├── LuaUnitTestULuaBridge.cpp │ │ │ ├── LuaUnitTestULuaValue.cpp │ │ │ ├── LuaUnitTestUObject.cpp │ │ │ ├── LuaUnitTestUStruct.cpp │ │ │ ├── LuaUnitTestUnknownUObjectType.cpp │ │ │ ├── LuaUnitTestUnknownUObjectType.h │ │ │ ├── LuaUnitTestVM.cpp │ │ │ ├── LuaUnitTests.cpp │ │ │ └── LuaUnitTests.h │ ├── Public │ │ ├── Bindings │ │ │ ├── LuaActorBinding.h │ │ │ ├── LuaActorComponentBinding.h │ │ │ ├── LuaClassBinding.h │ │ │ ├── LuaObjectBinding.h │ │ │ ├── LuaSceneComponentBinding.h │ │ │ ├── LuaStructBinding.h │ │ │ └── LuaUserWidgetBinding.h │ │ ├── LuaBindingRegistry.h │ │ ├── LuaBundleFileLoader.h │ │ ├── LuaFileLoader.h │ │ ├── LuaFunction.h │ │ ├── LuaLocalFileLoader.h │ │ ├── LuaStack.h │ │ ├── LuaStaticBinding.h │ │ ├── LuaThread.h │ │ ├── LuaValueReferencer.h │ │ ├── LuaVirtualMachine.h │ │ ├── SilvervineUE4Lua.h │ │ ├── SilvervineUE4LuaBridge.h │ │ ├── SilvervineUE4LuaSettings.h │ │ ├── SilvervineUE4LuaValue.h │ │ └── SilvervineUE4LuaVirtualMachine.h │ ├── SilvervineUE4Lua.Build.cs │ ├── SilvervineUE4LuaPCH.h │ └── ThirdParty │ │ └── Lua │ │ ├── 5.3.4 │ │ └── src │ │ │ ├── lapi.c │ │ │ ├── lapi.h │ │ │ ├── lauxlib.c │ │ │ ├── lauxlib.h │ │ │ ├── lbaselib.c │ │ │ ├── lbitlib.c │ │ │ ├── lcode.c │ │ │ ├── lcode.h │ │ │ ├── lcorolib.c │ │ │ ├── lctype.c │ │ │ ├── lctype.h │ │ │ ├── ldblib.c │ │ │ ├── ldebug.c │ │ │ ├── ldebug.h │ │ │ ├── ldo.c │ │ │ ├── ldo.h │ │ │ ├── ldump.c │ │ │ ├── lfunc.c │ │ │ ├── lfunc.h │ │ │ ├── lgc.c │ │ │ ├── lgc.h │ │ │ ├── linit.c │ │ │ ├── liolib.c │ │ │ ├── llex.c │ │ │ ├── llex.h │ │ │ ├── llimits.h │ │ │ ├── lmathlib.c │ │ │ ├── lmem.c │ │ │ ├── lmem.h │ │ │ ├── loadlib.c │ │ │ ├── lobject.c │ │ │ ├── lobject.h │ │ │ ├── lopcodes.c │ │ │ ├── lopcodes.h │ │ │ ├── loslib.c │ │ │ ├── lparser.c │ │ │ ├── lparser.h │ │ │ ├── lprefix.h │ │ │ ├── lstate.c │ │ │ ├── lstate.h │ │ │ ├── lstring.c │ │ │ ├── lstring.h │ │ │ ├── lstrlib.c │ │ │ ├── ltable.c │ │ │ ├── ltable.h │ │ │ ├── ltablib.c │ │ │ ├── ltm.c │ │ │ ├── ltm.h │ │ │ ├── lua.c │ │ │ ├── lua.h │ │ │ ├── lua.hpp │ │ │ ├── luaconf.h │ │ │ ├── lualib.h │ │ │ ├── lundump.c │ │ │ ├── lundump.h │ │ │ ├── lutf8lib.c │ │ │ ├── lvm.c │ │ │ ├── lvm.h │ │ │ ├── lzio.c │ │ │ └── lzio.h │ │ └── extension │ │ └── luasocket │ │ ├── auxiliar.c │ │ ├── auxiliar.h │ │ ├── buffer.c │ │ ├── buffer.h │ │ ├── except.c │ │ ├── except.h │ │ ├── inet.c │ │ ├── inet.h │ │ ├── io.c │ │ ├── io.h │ │ ├── luasocket.c │ │ ├── luasocket.h │ │ ├── mime.c │ │ ├── mime.h │ │ ├── options.c │ │ ├── options.h │ │ ├── select.c │ │ ├── select.h │ │ ├── socket.h │ │ ├── tcp.c │ │ ├── tcp.h │ │ ├── timeout.c │ │ ├── timeout.h │ │ ├── udp.c │ │ ├── udp.h │ │ ├── wsocket.c │ │ └── wsocket.h │ ├── SilvervineUE4LuaCodeGen │ ├── Private │ │ ├── LuaCodeGeneratorBase.cpp │ │ ├── LuaCodeGeneratorBase.h │ │ ├── LuaDefaultParameterCodeGen.cpp │ │ ├── LuaDefaultParameterCodeGen.h │ │ ├── LuaStaticBindingCodeGen.cpp │ │ ├── LuaStaticBindingCodeGen.h │ │ ├── SilvervineUE4LuaCodeGen.cpp │ │ └── SilvervineUE4LuaCodeGen.h │ └── SilvervineUE4LuaCodeGen.Build.cs │ └── SilvervineUE4LuaEditor │ ├── Private │ ├── LuaVirtualMachineFactory.cpp │ ├── LuaVirtualMachineFactory.h │ └── SilvervineUE4LuaEditor.cpp │ ├── SilvervineUE4LuaEditor.Build.cs │ └── SilvervineUE4LuaEditorPCH.h ├── README.md ├── SUE4LuaSample_21.uproject ├── SUE4LuaSample_22.uproject ├── SUE4LuaSample_23.uproject ├── SUE4LuaSample_24.uproject ├── SilvervineUE4Lua.code-workspace └── Source ├── SUE4LuaSample.Target.cs ├── SUE4LuaSample ├── SUE4LuaSample.Build.cs ├── SUE4LuaSample.cpp ├── SUE4LuaSample.h └── Scripts │ ├── Main.lua │ ├── Sedan.lua │ └── VehicleHUD.lua └── SUE4LuaSampleEditor.Target.cs /.gitignore: -------------------------------------------------------------------------------- 1 | #### project folders 2 | 3 | /Binaries/ 4 | /Intermediate/ 5 | /Saved/ 6 | /Plugins/*/Binaries/ 7 | /Plugins/*/Intermediate/ 8 | 9 | #### SUE4LuaCodeGen 10 | 11 | # Commented for debugging purpose(easy to see the difference) 12 | #/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Framework/CodeGen/*.g.lua 13 | 14 | 15 | #### vs 16 | 17 | *.sln 18 | *.sdf 19 | *.VC.db 20 | *.VC.opendb 21 | **/.vs/ 22 | 23 | #### etc 24 | 25 | -------------------------------------------------------------------------------- /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | [UnrealEd.SimpleMap] 2 | SimpleMapName=/Game/SUE4LuaSample/Maps/VehicleExampleMap 3 | 4 | [EditoronlyBP] 5 | bAllowClassAndBlueprintPinMatching=true 6 | bReplaceBlueprintWithClass= true 7 | bDontLoadBlueprintOutsideEditor= true 8 | bBlueprintIsNotBlueprintType= true -------------------------------------------------------------------------------- /Config/DefaultEditorPerProjectUserSettings.ini: -------------------------------------------------------------------------------- 1 | [ContentBrowser] 2 | ContentBrowserTab1.SelectedPaths=/Game/VehicleBP -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | [ProjectSettings] 2 | GameID=9D7B98C94D18E92A0B99D4B246527BDF 3 | ProjectName=Vehicle BP Game Template 4 | 5 | 6 | [/Script/EngineSettings.GeneralProjectSettings] 7 | ProjectID=16F4079E43A8763267C9E7872E73F2A9 8 | -------------------------------------------------------------------------------- /Content/Game.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Game.zip -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Geometry/Meshes/1M_Cube.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube_Chamfer.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Geometry/Meshes/1M_Cube_Chamfer.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Geometry/Meshes/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/TemplateFloor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Geometry/Meshes/TemplateFloor.uasset -------------------------------------------------------------------------------- /Content/LuaVM.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/LuaVM.uasset -------------------------------------------------------------------------------- /Content/MyGameInstance.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/MyGameInstance.uasset -------------------------------------------------------------------------------- /Content/SUE4Lua.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/SUE4Lua.zip -------------------------------------------------------------------------------- /Content/Vehicle/Meshes/BaseMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Meshes/BaseMaterial.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Meshes/GrayMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Meshes/GrayMaterial.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Meshes/OrangeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Meshes/OrangeMaterial.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Meshes/RoughTerrain_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Meshes/RoughTerrain_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Meshes/WhiteMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Meshes/WhiteMaterial.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Glass.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Glass.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Headlights.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Headlights.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Paint.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Paint.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Plastic.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Plastic.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_TailLights.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_TailLights.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Tires.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Tires.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Wheels.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Materials/M_Vehicle_Sedan_Inst_Wheels.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/SedanVirtualJoysticks.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/SedanVirtualJoysticks.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Sedan_AnimBP.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Sedan_AnimBP.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Sedan_PhysMat.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Sedan_PhysMat.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Sedan_PhysicsAsset.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Sedan_PhysicsAsset.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Sedan_SkelMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Sedan_SkelMesh.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Sedan/Sedan_Skeleton.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Sedan/Sedan_Skeleton.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Textures/VehicleJoystick_BackgroundL.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Textures/VehicleJoystick_BackgroundL.uasset -------------------------------------------------------------------------------- /Content/Vehicle/Textures/VehicleJoystick_BackgroundR.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/Vehicle/Textures/VehicleJoystick_BackgroundR.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Blueprints/VehicleGameMode.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Blueprints/VehicleGameMode.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Blueprints/VehicleHUD.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Blueprints/VehicleHUD.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Maps/VehicleExampleMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Maps/VehicleExampleMap.umap -------------------------------------------------------------------------------- /Content/VehicleBP/Maps/VehicleExampleMap_BuiltData.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Maps/VehicleExampleMap_BuiltData.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Sedan/Sedan.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Sedan/Sedan.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Sedan/Sedan_BackWheel.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Sedan/Sedan_BackWheel.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Sedan/Sedan_FrontWheel.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Sedan/Sedan_FrontWheel.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/Tutorial/VehicleBlueprintDetail.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/Tutorial/VehicleBlueprintDetail.uasset -------------------------------------------------------------------------------- /Content/VehicleBP/VehicleOverview.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Content/VehicleBP/VehicleOverview.uasset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 devCAT studio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Config/DefaultSilvervineUE4Lua.ini: -------------------------------------------------------------------------------- 1 | [/Script/SilvervineUE4Lua.SUE4LuaSettings] 2 | BundleFileLoadMap=(("SUE4Lua", "Content\\SUE4Lua.zip"),("Game", "Content\\Game.zip")) 3 | LocalFileLoadMap=(("SUE4Lua", "Plugins\\SilvervineUE4Lua\\Source\\SilvervineUE4Lua\\Private\\Scripts"),("Game", "Source\\SUE4LuaSample\Scripts")) 4 | 5 | ;Add engine module names to be excluded 6 | +ExcludedEngineModules=AIModule 7 | +ExcludedEngineModules=AndroidRuntimeSettings 8 | +ExcludedEngineModules=AnimGraphRuntime 9 | +ExcludedEngineModules=AudioMixer 10 | +ExcludedEngineModules=AugmentedReality 11 | +ExcludedEngineModules=BlueprintRuntime 12 | +ExcludedEngineModules=CinematicCamera 13 | +ExcludedEngineModules=ClothingSystemRuntime 14 | +ExcludedEngineModules=ClothingSystemRuntimeCommon 15 | +ExcludedEngineModules=ClothingSystemRuntimeInterface 16 | +ExcludedEngineModules=ClothingSystemRuntimeNv 17 | +ExcludedEngineModules=EngineSettings 18 | +ExcludedEngineModules=EyeTracker 19 | +ExcludedEngineModules=Foliage 20 | +ExcludedEngineModules=GameplayTasks 21 | +ExcludedEngineModules=HeadMountedDisplay 22 | +ExcludedEngineModules=IOSRuntimeSettings 23 | +ExcludedEngineModules=Landscape 24 | +ExcludedEngineModules=LevelSequence 25 | +ExcludedEngineModules=LiveLinkInterface 26 | +ExcludedEngineModules=LuminRuntimeSettings 27 | +ExcludedEngineModules=MaterialShaderQualitySettings 28 | +ExcludedEngineModules=MediaAssets 29 | +ExcludedEngineModules=MeshDescription 30 | +ExcludedEngineModules=MoviePlayer 31 | +ExcludedEngineModules=MovieScene 32 | +ExcludedEngineModules=MovieSceneCapture 33 | +ExcludedEngineModules=MovieSceneTracks 34 | +ExcludedEngineModules=MRMesh 35 | +ExcludedEngineModules=NavigationSystem 36 | +ExcludedEngineModules=Overlay 37 | +ExcludedEngineModules=TimeManagement 38 | 39 | ;Add engine plugin module names to be included 40 | +IncludedEnginePlugins= 41 | 42 | ;Add game plugin module names to be included 43 | +IncludedGamePlugins= -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToCreateVMAsset.md: -------------------------------------------------------------------------------- 1 | 2 | How To Create VM Assets 3 | ======================= 4 | 5 | To run a lua code, you must first create a Lua VM(Virtual Machine). 6 | You can simply create a VM using C++, but it is convenient to create a VM as an uasset. 7 | 8 | For more information, please see [this](HowToCreateVMInstance.md). 9 | 10 | Note: 11 | * You can create multiple VM assets without any problems. But, you can't pass lua values to other VMs. 12 | 13 | Creating VM Assets 14 | ------------------ 15 | 16 | ![](Images/VMAsset.png) 17 | 18 | 1. Right-Click in the Content Browser to open the context menu. 19 | 2. Miscellaneous -> choose 'SUE4Lua Virtual Machine'. 20 | 3. When the window for selecting the parent class opens, select 'SUE4LuaVirtualMachine'. 21 | 22 | Editing VM Properties 23 | --------------------- 24 | 25 | ![](Images/EditingVM.png) 26 | 27 | Double-Click the VM asset in the Content Browser to edit it. 28 | 29 | * Startup File Path 30 | 31 | When the VM is started, the specified file will be executed. 32 | 33 | ------------------------------------------------ 34 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToCreateVMAsset_ko.md: -------------------------------------------------------------------------------- 1 | 2 | VM 어셋 생성하기 3 | =============== 4 | 5 | lua 코드를 실행하기 위해서는 먼저 Lua VM(Virtual Machine)을 만들어야 합니다. 6 | C++ 코드로 VM을 간단하게 생성할 수도 있으나 UE4 어셋(*.uasset)으로 VM을 생성하는 것이 여러 가지로 편리합니다. 7 | 8 | C++로 직접 VM 인스턴스를 생성하는 방법은 [여기](HowToCreateVMInstance_ko.md)를 참고하세요. 9 | 10 | 참고: 11 | * VM 어셋을 여러 개 만들어도 전혀 문제 없습니다. 하지만 다른 VM으로 Lua 값을 전달할 수 없으니 주의하시기 바랍니다. 12 | 13 | VM 어셋 생성하기 14 | --------------- 15 | 16 | ![](Images/VMAsset.png) 17 | 18 | 1. 컨텐츠 브라우저에서 우클릭하여 컨텍스트 메뉴를 엽니다. 19 | 2. Miscellaneous -> SUE4Lua Virtual Machine 을 선택합니다. 20 | 3. 부모 클래스를 선택하는 창이 열리면 SUE4LuaVirtualMachine을 선택합니다. 21 | 22 | VM 속성 편집하기 23 | --------------- 24 | 25 | ![](Images/EditingVM.png) 26 | 27 | 컨텐츠 브라우저에서 VM 어셋을 더블클릭하면 VM 어셋 편집 창이 열립니다. 28 | 29 | * Startup File Path 30 | 31 | VM이 시작되면 지정된 파일을 실행합니다. 32 | 33 | ---------------------------------------------------- 34 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToCreateVMInstance.md: -------------------------------------------------------------------------------- 1 | 2 | How to Create VM Assets in C++ 3 | ============================== 4 | 5 | This guide describes how to create a VM in C++. 6 | 7 | 1. Include "LuaVirtualMachine.h". 8 | 9 | If you get a compile error, check [this](HowToSetupGameModule.md) out. 10 | 11 | 2. Write the following code. 12 | 13 | ```cpp 14 | auto VM = FSUE4LuaVirtualMachine::Create(); 15 | if (VM.IsValid()) 16 | { 17 | // ok 18 | } 19 | ``` 20 | 21 | The return type is `TSharedPtr`. 22 | 23 | To create a VM with debugging enabled, pass `true` as an argument. 24 | 25 | ```cpp 26 | auto VM = FSUE4LuaVirtualMachine::Create(true); 27 | if (VM.IsValid()) 28 | { 29 | // ok 30 | } 31 | ``` 32 | 33 | Note: 34 | * The VM instance created by uasset has debugging enabled. 35 | 36 | ------------------------------------------------ 37 | [Back to Programming Guide](ProgrammingGuide.md) 38 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToCreateVMInstance_ko.md: -------------------------------------------------------------------------------- 1 | 2 | C++에서 VM 인스턴스를 생성하기 3 | ============================ 4 | 5 | 이 문서에서는 C++에서 VM을 만드는 방법에 대해서 설명합니다. 6 | 7 | 1. "LuaVirtualMachine.h"을 인클루드 합니다. 8 | 9 | 이 단계에서 컴파일 오류가 발생할 경우 [게임 모듈 설정하기](HowToSetupGameModule.md)를 하지 않았는지 확인해보세요. 10 | 11 | 2. 다음과 같은 코드를 작성합니다. 12 | 13 | ```cpp 14 | auto VM = FSUE4LuaVirtualMachine::Create(); 15 | if (VM.IsValid()) 16 | { 17 | // ok 18 | } 19 | ``` 20 | 21 | 반환 타입은 `TSharedPtr` 입니다. 22 | 23 | 디버깅이 활성화된 VM을 생성하려면 인자로 `true`를 전달합니다. 24 | 25 | ```cpp 26 | auto VM = FSUE4LuaVirtualMachine::Create(true); 27 | if (VM.IsValid()) 28 | { 29 | // ok 30 | } 31 | ``` 32 | 33 | 참고: 34 | * VM 어셋이 생성한 VM 인스턴스는 디버깅이 활성화되어 있습니다. 35 | 36 | ---------------------------------------------------- 37 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 38 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToRegisterGameInstance.md: -------------------------------------------------------------------------------- 1 | How to Register a Game Instance with VM Asset 2 | ============================================= 3 | 4 | To use VM assets in a game, you must register the game instance with the VM asset after the game starts. 5 | If this step is missing, all calls through the VM assets will not work. 6 | 7 | If you created the VM directly in C++, you can skip the following steps. 8 | 9 | For convenience, we have implemented it with blueprint, but with C++ you can implement in much the same way. 10 | 11 | 1. Open the GameInstance blueprint in the editor and add LuaVM variable. 12 | 13 | ![](Images/AddLuaVMToGameInstance.png) 14 | 15 | * The variable type is _SUE4Lua Virtual Machine_. 16 | * Set the default value to the VM asset you created. 17 | 18 | 2. Add the following code to the Init and Shutdown events. 19 | 20 | ![](Images/RegisterGameInstance.png) 21 | 22 | ------------------------------------------------ 23 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToRegisterGameInstance_ko.md: -------------------------------------------------------------------------------- 1 | 2 | VM 어셋에 게임 인스턴스 등록하기 3 | ============================== 4 | 5 | 게임에서 VM 어셋을 사용하려면 게임 시작 후에 VM 어셋에 게임 인스턴스를 등록해야 합니다. 6 | 이 과정이 누락되면 VM 어셋을 통한 모든 함수 호출이 동작하지 않습니다. 7 | 8 | C++에서 직접 VM을 생성했다면 아래 과정을 생략해도 상관 없습니다. 9 | 10 | 편의상 Blueprint로 구현했습니다만 C++도 거의 유사한 방법으로 구현할 수 있습니다. 11 | 12 | 1. 에디터에서 게임 인스턴스 Blueprint를 열고 LuaVM 변수를 추가합니다. 13 | 14 | ![](Images/AddLuaVMToGameInstance.png) 15 | 16 | * 변수 형식은 SUE4Lua Virtual Machine 입니다. 17 | * 기본값은 만들어두신 VM 어셋으로 설정하시면 됩니다. 18 | 19 | 2. Init, Shutdown 이벤트에 다음과 같은 코드를 추가합니다. 20 | 21 | ![](Images/RegisterGameInstance.png) 22 | 23 | ---------------------------------------------------- 24 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupDispatchHandlerFactory.md: -------------------------------------------------------------------------------- 1 | 2 | How to Setup a Dispatch Handler Factory 3 | ======================================= 4 | 5 | The _Dispatch Handler Factory_ is a lua function that returns the name of the lua file used by the class to be dispatched. 6 | 7 | Implement the dispatch handler factory as follows and connect it to the VM. It is recommended that you write to the first running lua file, such as Game/Main.lua. 8 | 9 | ```lua 10 | SUE4Lua.SetDispatchHandlerFactory(function (CallerClass) 11 | local ClassName = CallerClass:GetName() 12 | 13 | SUE4Lua.Log("DispatchHandlerFactory: ", ClassName) 14 | 15 | local Filenames = { 16 | Sedan_C = "Game/Sedan.lua", 17 | VehicleHUD_C = "Game/VehicleHUD.lua", 18 | } 19 | 20 | return Filenames[ClassName] or "" 21 | end) 22 | ``` 23 | 24 | Note: 25 | * The loaded dispatch handlers are cached inside the VM. The dispatch handler factory is called whenever a class not in the cache is found. 26 | 27 | ------------------------------------------------ 28 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupDispatchHandlerFactory_ko.md: -------------------------------------------------------------------------------- 1 | 2 | 디스패치 핸들러 팩토리 설정하기 3 | ============================ 4 | 5 | 디스패치할 클래스가 사용하는 Lua 파일 이름을 반환해주는 Lua 함수를 _디스패치 핸들러 팩토리_ 라고 부릅니다. 6 | 7 | 디스패치 핸들러 팩토리를 다음과 같이 구현한 후에 VM에 연결해주세요. Game/Main.lua와 같은 가장 먼저 실행되는 Lua파일에 작성하시는 것이 좋습니다. 8 | ```lua 9 | SUE4Lua.SetDispatchHandlerFactory(function (CallerClass) 10 | local ClassName = CallerClass:GetName() 11 | 12 | SUE4Lua.Log("DispatchHandlerFactory: ", ClassName) 13 | 14 | local Filenames = { 15 | Sedan_C = "Game/Sedan.lua", 16 | VehicleHUD_C = "Game/VehicleHUD.lua", 17 | } 18 | 19 | return Filenames[ClassName] or "" 20 | end) 21 | ``` 22 | 23 | 참고: 24 | * 로딩한 디스패치 핸들러는 VM 내부에서 캐싱됩니다. 디스패치 핸들러 팩토리는 캐시에 없는 클래스를 발견했을 때에 호출됩니다. 25 | 26 | ---------------------------------------------------- 27 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupFileLoader.md: -------------------------------------------------------------------------------- 1 | 2 | How to Setup a File Loader 3 | ========================== 4 | 5 | SUE4Lua reads all lua files through the [File Loader Class](../Source/SilvervineUE4Lua/Public/LuaFileLoader.h). 6 | This guide explains how to select the appropriate lua file loader for each type of environment and build. 7 | 8 | Lua Local FileLoader 9 | -------------------- 10 | 11 | Developers who edit lua files must use a local file loader. 12 | This is mainly used by engineers and designers. 13 | 14 | How to Setup: 15 | 16 | 1. Open the project settings and go to Plugins -> SilvervineUE4Lua. 17 | 18 | 2. Uncheck 'Use Bundle File Loader'. 19 | 20 | 3. Set 'Local File Load Map' to the paths that contains lua files. 21 | 22 | ![](Images/LocalFileLoader.png) 23 | 24 | * Set __virtual path__ as the key for the map. SUE4Lua uses a virtual path instead of an actual path when specifying a lua file path. 25 | * Set the path containing the lua files as the value for the map. 26 | 27 | It is recommended to use only the following two virtual paths. 28 | 29 | * `SUE4Lua` : Used to read lua files in the SUE4Lua plugin. 30 | 31 | Ex: SUE4Lua/Framework/SUE4Lua.lua 32 | 33 | * `Game` : Used to read lua files in game modules. 34 | 35 | Ex: Game/Main.lua 36 | 37 | Note: 38 | * [SUE4LuaSample](SUE4LuaSample.md) project is set up to use a local file loader. 39 | 40 | Lua Bundle FileLoader 41 | --------------------- 42 | 43 | A Bundle file is a file that combines several files togheter. Zip format is mainly used. 44 | 45 | Usually, those who do not edit lua files do not use source code repositories, the build machine will automatically create and distribute the bundle file. 46 | 47 | You must use the bundle file loader when distributing games. 48 | 49 | How to Setup: 50 | 51 | 1. Open the project settings and go to Plugins -> SilvervineUE4Lua. 52 | 53 | 2. Check 'Use Bundle File Loader'. 54 | 55 | 3. Set 'Bundle File Load Map' to the paths that contains bundle files. 56 | 57 | ![](Images/BundleFileLoader.png) 58 | 59 | * Set the same virtual path as the local file loader as the key for the map. 60 | * Set the path containing the bundle file as the value for the map. 61 | 62 | Note: 63 | * Currently, only ZIP format is supported. 64 | * It is good to automate bundle creation and deployment by CI tools. 65 | 66 | ------------------------------------------------ 67 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupFileLoader_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua 파일 로더 설정하기 3 | ===================== 4 | 5 | SUE4Lua는 모든 Lua 파일을 [파일 로더 클래스](../Source/SilvervineUE4Lua/Public/LuaFileLoader.h)를 통해 읽어옵니다. 6 | 이 문서에서는 작업자의 실행 환경 및 빌드 종류 마다 적절한 Lua 파일 로더를 선택하는 방법에 대해 설명합니다. 7 | 8 | Lua Local FileLoader 9 | -------------------- 10 | 11 | 직접 Lua 파일을 편집하는 작업자는 로컬 파일로더를 사용해야 합니다. 12 | 주로 엔지니어, 디자이너(기획자)가 이렇게 사용합니다. 13 | 14 | 설정 방법: 15 | 16 | 1. 프로젝트 설정 창을 열고 Plugins -> SilvervineUE4Lua로 이동합니다. 17 | 18 | 2. Use Bundle File Loader 체크를 해제합니다. 19 | 20 | 3. Local File Load Map에 Lua 파일이 들어있는 경로들을 등록합니다. 21 | 22 | ![](Images/LocalFileLoader.png) 23 | 24 | * 맵의 Key 값으로 _가상 경로_ 를 설정합니다. SUE4Lua는 Lua 파일 경로를 지정할 때 실제 경로를 사용하지 않고 가상 경로를 사용합니다. 25 | * 맵의 Value 값으로 원하는 Lua 파일들이 들어있는 디렉토리 이름을 설정합니다. 26 | 27 | 파일 관리의 편의성을 위해서 다음의 두 개의 가상 경로만 사용할 것을 추천합니다. 28 | 29 | * `SUE4Lua` : SUE4Lua 플러그인에 들어있는 필수 Lua 파일들을 읽을 때 사용합니다. 30 | 31 | 예: SUE4Lua/Framework/SUE4Lua.lua 32 | 33 | * `Game` : 게임 모듈이 사용할 Lua 파일들을 읽을 때 사용합니다. 34 | 35 | 예: Game/Main.lua 36 | 37 | 참고: 38 | * [SUE4LuaSample](SUE4LuaSample_ko.md) 프로젝트는 로컬 파일 로더를 사용하도록 설정되어 있습니다. 39 | 40 | Lua Bundle FileLoader 41 | --------------------- 42 | 43 | 번들 파일이란 여러 개의 파일을 하나로 합친 파일을 뜻합니다. 주로 사용하는 번들 형식은 zip 입니다. 44 | 45 | 보통, Lua 소스 코드를 수정하지 않는 작업자들은 소스코드 저장소를 설치하기 않기 때문에, 46 | 빌드 머신이 자동으로 생성해서 배포하는 번들 파일을 사용합니다. 47 | 48 | 게임을 배포할 때에는 반드시 번들 파일로더를 사용해야 합니다. 게임을 배포할 때 소스코드를 제공하는 일은 거의 없기 때문입니다. 49 | 50 | 설정 방법: 51 | 52 | 1. 프로젝트 설정 창을 열고 Plugins -> SilvervineUE4Lua로 이동합니다. 53 | 54 | 2. Use Bundle File Loader를 체크합니다. 55 | 56 | 3. Bundle File Load Map에 번들 파일이 들어있는 경로들을 등록합니다. 57 | 58 | ![](Images/BundleFileLoader.png) 59 | 60 | * 맵의 Key 값으로 로컬 파일 로더와 동일한 가상 경로로 설정합니다. 61 | * 맵의 Value 값으로 번들 파일의 경로를 설정합니다. 가상 경로 하나당 번들 파일 하나를 지정합니다. 62 | 63 | 참고: 64 | * 현재 zip 형식만 지원합니다. 65 | * 빌드 자동화 등의 CI(Continuous Integration)를 구축하여 번들 생성 및 배포를 자동화하면 매우 편리합니다. 66 | 67 | ---------------------------------------------------- 68 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupGameModule.md: -------------------------------------------------------------------------------- 1 | 2 | How to Setup a Game Module 3 | ========================== 4 | 5 | To use SUE4Lua in the C++ code of the game module, you must write some setup codes. 6 | 7 | If you are using lua only with a blueprint, you can skip the steps below. 8 | 9 | 1. Add the following code in your game module's Build.cs. 10 | 11 | ```cpp 12 | PrivateDependencyModuleNames.Add("SilvervineUE4Lua"); 13 | ``` 14 | 15 | For example, 16 | 17 | ```cpp 18 | // Fill out your copyright notice in the Description page of Project Settings. 19 | 20 | using UnrealBuildTool; 21 | 22 | public class SUE4LuaSample : ModuleRules 23 | { 24 | public SUE4LuaSample(ReadOnlyTargetRules Target) : base(Target) 25 | { 26 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 27 | 28 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 29 | 30 | PrivateDependencyModuleNames.AddRange(new string[] { }); 31 | 32 | // Uncomment if you are using Slate UI 33 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 34 | 35 | // Uncomment if you are using online features 36 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 37 | 38 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 39 | 40 | PrivateDependencyModuleNames.Add("SilvervineUE4Lua"); 41 | } 42 | } 43 | ``` 44 | 45 | 2. Add `#include "SilvervineUE4LuaCodeGen_Game.g.inl"` to the appropriate location of your game module's cpp. 46 | 47 | 3. Add the following code in StartupModule(). 48 | 49 | ```cpp 50 | SUE4LUA_REGISTER_BINDINGS(); 51 | ``` 52 | 53 | For example, 54 | 55 | ```cpp 56 | // Fill out your copyright notice in the Description page of Project Settings. 57 | 58 | #include "SUE4LuaSample.h" 59 | #include "Modules/ModuleManager.h" 60 | 61 | #include "SilvervineUE4LuaCodeGen_Game.g.inl" 62 | 63 | class FSUE4LuaSampleGameModuleImpl : public FDefaultGameModuleImpl 64 | { 65 | public: 66 | // Begin IModuleInterface 67 | virtual void StartupModule() override 68 | { 69 | SUE4LUA_REGISTER_BINDINGS(); 70 | } 71 | 72 | virtual void ShutdownModule() override 73 | { 74 | } 75 | // End IModuleInterface 76 | }; 77 | 78 | IMPLEMENT_PRIMARY_GAME_MODULE(FSUE4LuaSampleGameModuleImpl, SUE4LuaSample, "SUE4LuaSample"); 79 | ``` 80 | 81 | ------------------------------------------------ 82 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/HowToSetupGameModule_ko.md: -------------------------------------------------------------------------------- 1 | 2 | 게임 모듈 설정하기 3 | ================ 4 | 5 | 게임 모듈의 C++ 코드에서 SUE4Lua를 사용하려면 몇 가지 설정이 필요합니다. 6 | 7 | Blueprint에서만 Lua를 사용하고 있다면 아래 과정은 생략해도 상관 없습니다. 8 | 9 | 1. 게임 모듈의 Build.cs 파일을 열고 아래 코드를 추가합니다. 10 | 11 | ```cpp 12 | PrivateDependencyModuleNames.Add("SilvervineUE4Lua"); 13 | ``` 14 | 15 | 예를 들면, 16 | 17 | ```cpp 18 | // Fill out your copyright notice in the Description page of Project Settings. 19 | 20 | using UnrealBuildTool; 21 | 22 | public class SUE4LuaSample : ModuleRules 23 | { 24 | public SUE4LuaSample(ReadOnlyTargetRules Target) : base(Target) 25 | { 26 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 27 | 28 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 29 | 30 | PrivateDependencyModuleNames.AddRange(new string[] { }); 31 | 32 | // Uncomment if you are using Slate UI 33 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 34 | 35 | // Uncomment if you are using online features 36 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 37 | 38 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 39 | 40 | PrivateDependencyModuleNames.Add("SilvervineUE4Lua"); 41 | } 42 | } 43 | ``` 44 | 45 | 2. 게임 모듈을 정의하는 cpp 파일을 열고 적당한 위치에 `#include "SilvervineUE4LuaCodeGen_Game.g.inl"` 인클루드 코드를 추가합니다. 46 | 47 | 3. StartupModule() 함수에 아래 코드를 추가합니다. 48 | 49 | ```cpp 50 | SUE4LUA_REGISTER_BINDINGS(); 51 | ``` 52 | 53 | 예를 들면, 54 | 55 | ```cpp 56 | // Fill out your copyright notice in the Description page of Project Settings. 57 | 58 | #include "SUE4LuaSample.h" 59 | #include "Modules/ModuleManager.h" 60 | 61 | #include "SilvervineUE4LuaCodeGen_Game.g.inl" 62 | 63 | class FSUE4LuaSampleGameModuleImpl : public FDefaultGameModuleImpl 64 | { 65 | public: 66 | // Begin IModuleInterface 67 | virtual void StartupModule() override 68 | { 69 | SUE4LUA_REGISTER_BINDINGS(); 70 | } 71 | 72 | virtual void ShutdownModule() override 73 | { 74 | } 75 | // End IModuleInterface 76 | }; 77 | 78 | IMPLEMENT_PRIMARY_GAME_MODULE(FSUE4LuaSampleGameModuleImpl, SUE4LuaSample, "SUE4LuaSample"); 79 | ``` 80 | 81 | ---------------------------------------------------- 82 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/AddLuaVMToGameInstance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/AddLuaVMToGameInstance.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/BundleFileLoader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/BundleFileLoader.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/Dispatch01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/Dispatch01.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/Dispatch02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/Dispatch02.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/Dispatch03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/Dispatch03.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/Dispatch04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/Dispatch04.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/EditingVM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/EditingVM.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/EnableSUE4Lua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/EnableSUE4Lua.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/InitializeLuaBridge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/InitializeLuaBridge.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/LocalFileLoader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/LocalFileLoader.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/LuaBridge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/LuaBridge.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/LuaBridgeHelper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/LuaBridgeHelper.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/LuaValue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/LuaValue.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/RegisterGameInstance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/RegisterGameInstance.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/Sedan_UpdateHUDStrings_BP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/Sedan_UpdateHUDStrings_BP.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/SettingVM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/SettingVM.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/UnitTest_AutomationLog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/UnitTest_AutomationLog.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/UnitTest_AutomationTab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/UnitTest_AutomationTab.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VMAsset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VMAsset.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Debug.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Search.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Workspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VSCode_Workspace.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VehicleHUD_BP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VehicleHUD_BP.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Images/VehicleScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Documents/Images/VehicleScreenShot.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Library.md: -------------------------------------------------------------------------------- 1 | 2 | Libraris 3 | ======== 4 | 5 | The following libraries are included in the plugin. 6 | All of these functions are implemented without UE4 reflection system. 7 | 8 | Base 9 | ---- 10 | 11 | * [SUE4Lua(Korean)](SUE4Lua_ko.md) 12 | 13 | UE4 14 | --- 15 | 16 | * [UE4(Korean)](UE4_ko.md) 17 | * [UE4.Color(Korean)](UE4.Color_ko.md) 18 | * [UE4.DateTime(Korean)](UE4.DateTime_ko.md) 19 | * [UE4.LinearColor(Korean)](UE4.LinearColor_ko.md) 20 | * [UE4.Math(Korean)](UE4.Math_ko.md) 21 | * [UE4.PlatformTime(Korean)](UE4.PlatformTime_ko.md) 22 | * [UE4.PointerEvent(Korean)](UE4.PointerEvent_ko.md) 23 | * [UE4.QualifiedFrameTime(Korean)](UE4.QualifiedFrameTime_ko.md) 24 | * [UE4.Quat(Korean)](UE4.Quat_ko.md) 25 | * [UE4.Rotator(Korean)](UE4.Rotator_ko.md) 26 | * [UE4.TextFormatter(Korean)](UE4.TextFormatter_ko.md) 27 | * [UE4.Timespan(Korean)](UE4.Timespan_ko.md) 28 | * [UE4.Transform(Korean)](UE4.Transform_ko.md) 29 | * [UE4.Vector(Korean)](UE4.Vector_ko.md) 30 | * [UE4.Vector2D(Korean)](UE4.Vector2D_ko.md) 31 | 32 | ------------------------------------------------ 33 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/Library_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | ======= 4 | 5 | 아래와 같은 라이브러리가 플러그인에 포함되어 있습니다. 6 | 이 함수들은 모두 리플렉션을 사용하지 않고 직접 구현한 C++ 코드 입니다. 7 | 8 | 기본 9 | ---- 10 | 11 | * [SUE4Lua](SUE4Lua_ko.md) 12 | 13 | UE4 14 | --- 15 | 16 | * [UE4](UE4_ko.md) 17 | * [UE4.Color](UE4.Color_ko.md) 18 | * [UE4.DateTime](UE4.DateTime_ko.md) 19 | * [UE4.LinearColor](UE4.LinearColor_ko.md) 20 | * [UE4.Math](UE4.Math_ko.md) 21 | * [UE4.PlatformTime](UE4.PlatformTime_ko.md) 22 | * [UE4.PointerEvent](UE4.PointerEvent_ko.md) 23 | * [UE4.QualifiedFrameTime](UE4.QualifiedFrameTime_ko.md) 24 | * [UE4.Quat](UE4.Quat_ko.md) 25 | * [UE4.Rotator](UE4.Rotator_ko.md) 26 | * [UE4.TextFormatter](UE4.TextFormatter_ko.md) 27 | * [UE4.Timespan](UE4.Timespan_ko.md) 28 | * [UE4.Transform](UE4.Transform_ko.md) 29 | * [UE4.Vector](UE4.Vector_ko.md) 30 | * [UE4.Vector2D](UE4.Vector2D_ko.md) 31 | 32 | ---------------------------------------------------- 33 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/LuaHotReloading.md: -------------------------------------------------------------------------------- 1 | 2 | Lua File Hot Reloading 3 | ====================== 4 | 5 | For development builds only, the local file loader monitors file changes in the associated path. 6 | When a file change is detected, the `SUE4Lua.OnFileModifiled()` function is called. So, you can easily implement a simple hot reloading in it. 7 | 8 | ```lua 9 | local AdditionalExecuteFilenames = { 10 | "Game/Utility.lua", 11 | "Game/UI.lua", 12 | "Game/DispatchHandlerFactory.lua", 13 | } 14 | 15 | SUE4Lua.OnFileModifiled = function (Filename) 16 | SUE4Lua.Log("OnFileModifiled:", Filename) 17 | 18 | for _, ExecutedFilename in pairs(AdditionalExecuteFilenames) do 19 | if Filename:lower() == ExecutedFilename:lower() then 20 | SUE4Lua.Log("Re-Execute", Filename) 21 | SUE4Lua.ExecuteFile(Filename) 22 | break 23 | end 24 | end 25 | end 26 | ``` 27 | 28 | Note: 29 | * You must create a VM instance to start monitoring. That is, if you haven't started the game, changes will not be detected. 30 | * Dispatch handlers are automatically reloaded by SUE4Lua. 31 | ``` 32 | LogSUE4L: [LuaVM] [SUE4Lua/Framework/SUE4LuaBinding.lua:151] Dispatch Handler was Hot-Reloaded: Sedan_C game/Sedan.lua 33 | LogSUE4L: [LuaVM] [Game/Main.lua:59] OnFileModified: game/Sedan.lua 34 | ``` 35 | 36 | ------------------------------------------------ 37 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/LuaHotReloading_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua File Hot Reloading 3 | ====================== 4 | 5 | 개발 빌드 한정으로 로컬 파일로더는 연결된 경로의 파일 변경점을 모니터링 합니다. 6 | 파일 변경이 감지되면 `SUE4Lua.OnFileModifiled()` 함수가 호출되는데 이 함수를 구현해서 간단한 핫 리로딩 기능을 만들 수 있습니다. 7 | 8 | ```lua 9 | local AdditionalExecuteFilenames = { 10 | "Game/Utility.lua", 11 | "Game/UI.lua", 12 | "Game/DispatchHandlerFactory.lua", 13 | } 14 | 15 | SUE4Lua.OnFileModifiled = function (Filename) 16 | SUE4Lua.Log("OnFileModifiled:", Filename) 17 | 18 | for _, ExecutedFilename in pairs(AdditionalExecuteFilenames) do 19 | if Filename:lower() == ExecutedFilename:lower() then 20 | SUE4Lua.Log("Re-Execute", Filename) 21 | SUE4Lua.ExecuteFile(Filename) 22 | break 23 | end 24 | end 25 | end 26 | ``` 27 | 28 | 참고: 29 | * VM 인스턴스를 생성해야 모니터링을 시작합니다. 즉, 게임을 시작하지 않았다면 변경점을 감지하지 않습니다. 30 | * 디스패치 핸들러는 SUE4Lua가 자동으로 리로딩해줍니다. 31 | ``` 32 | LogSUE4L: [LuaVM] [SUE4Lua/Framework/SUE4LuaBinding.lua:151] Dispatch Handler was Hot-Reloaded: Sedan_C game/Sedan.lua 33 | LogSUE4L: [LuaVM] [Game/Main.lua:59] OnFileModified: game/Sedan.lua 34 | ``` 35 | 36 | ---------------------------------------------------- 37 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/ProgrammingGuide.md: -------------------------------------------------------------------------------- 1 | 2 | Programming Guide 3 | ================= 4 | 5 | This guide is about how to setup a environment for SUE4Lua, how to communicate with lua and call native functions in it. 6 | 7 | Please see [README](README.md) about the installation. 8 | 9 | Coding Convention 10 | ----------------- 11 | We use [UE4 Coding Standard](https://docs.unrealengine.com/en-us/Programming/Development/CodingStandard) for C++ and Lua. 12 | 13 | Getting Started 14 | --------------- 15 | 16 | * [How to Setup a Game Module](HowToSetupGameModule.md) 17 | * [How to Create VM Assets](HowToCreateVMAsset.md) 18 | * [How to Register a Game Instance with VM Asset](HowToRegisterGameInstance.md) 19 | * [How to Create VM Assets in C++](HowToCreateVMInstance.md) 20 | 21 | How to Setup an Environment 22 | --------------------------- 23 | 24 | * [How to Setup a File Loader](HowToSetupFileLoader.md) 25 | * [Working with Visual Studio Code](WorkWithVSCode.md) 26 | * [Unit Test](UnitTest.md) 27 | 28 | Lua Programming Guide 29 | --------------------- 30 | 31 | * [Libraries](Library.md) 32 | * [How to Print a Debug Text](WorkWithDebugPrint.md) 33 | * [Working with UObject in Lua](WorkWithUObject.md) 34 | * [Working with UStruct in Lua](WorkWithUStruct.md) 35 | * [Working with UEnum in Lua](WorkWithUEnum.md) 36 | * [Working with Timers in Lua](WorkWithTimer.md) 37 | * [How to Implement a Blueprint Function with Lua](WorkWithBlueprintDispatch.md) 38 | * [How to Implement a C++ Function with Lua](WorkWithNativeDispatch.md) 39 | * [How to Setup a Dispatch Handler Factory](HowToSetupDispatchHandlerFactory.md) 40 | * [How to Call Functions of a Dispatch Handler](WorkWithDirectCall.md) 41 | * [Working with LuaValue](WorkWithLuaValue.md) 42 | * [Lua File Hot Reloading](LuaHotReloading.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/ProgrammingGuide_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Programming Guide 3 | ================= 4 | 5 | 이 문서에서는 SUE4Lua 플러그인의 초기화 및 작업 환경 설정, Lua와의 데이터 교환, 함수 호출 방법 등을 설명합니다. 6 | 7 | 플러그인 설치 방법에 대해서는 [README](README_ko.md) 문서를 참고하세요. 8 | 9 | 코딩 컨벤션 10 | ---------- 11 | C++, Lua 모두 [UE4 코딩 표준](https://docs.unrealengine.com/en-us/Programming/Development/CodingStandard)을 사용합니다. 12 | 13 | 시작하기 14 | -------- 15 | 16 | * [게임 모듈 설정하기](HowToSetupGameModule_ko.md) 17 | * [VM 어셋 생성하기](HowToCreateVMAsset_ko.md) 18 | * [VM 어셋에 게임 인스턴스 등록하기](HowToRegisterGameInstance_ko.md) 19 | * [C++에서 VM 인스턴스를 생성하기](HowToCreateVMInstance_ko.md) 20 | 21 | 작업 환경 설정 22 | ------------- 23 | 24 | * [Lua 파일 로더 설정하기](HowToSetupFileLoader_ko.md) 25 | * [Visual Studio Code로 작업하기](WorkWithVSCode_ko.md) 26 | * [유닛 테스트](UnitTest_ko.md) 27 | 28 | Lua 프로그래밍 가이드 29 | -------------------- 30 | 31 | * [라이브러리](Library_ko.md) 32 | * [디버그 텍스트 출력하기](WorkWithDebugPrint_ko.md) 33 | * [Lua에서 UObject 사용하기](WorkWithUObject_ko.md) 34 | * [Lua에서 UStruct 사용하기](WorkWithUStruct_ko.md) 35 | * [Lua에서 UEnum 사용하기](WorkWithUEnum_ko.md) 36 | * [Lua에서 Timer 사용하기](WorkWithTimer_ko.md) 37 | * [Blueprint 함수를 Lua로 구현하기](WorkWithBlueprintDispatch_ko.md) 38 | * [C++ 함수를 Lua로 구현하기](WorkWithNativeDispatch_ko.md) 39 | * [디스패치 핸들러 팩토리 설정하기](HowToSetupDispatchHandlerFactory_ko.md) 40 | * [Lua에서 디스패치 핸들러의 함수를 호출하기](WorkWithDirectCall_ko.md) 41 | * [LuaValue 사용하기](WorkWithLuaValue_ko.md) 42 | * [Lua 파일 핫 리로딩](LuaHotReloading_ko.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/SUE4Lua_ko.md: -------------------------------------------------------------------------------- 1 | 2 | # SUE4Lua Library 3 | 4 | SUE4Lua에서 제공하는 필수 라이브러리입니다. 5 | 6 | ## SUE4Lua.ExecuteString(LuaString) 7 | 8 | 입력 텍스트의 소스를 불러와 실행합니다. 실행 성공 여부를 반환합니다. 9 | 10 | ```lua 11 | local bSuccess = SUE4Lua.ExecuteString("local Value = 123") 12 | ``` 13 | 14 | ## SUE4Lua.ExecuteFile(LuaFilename) 15 | 16 | 입력 파일 이름의 소스를 불러와 실행합니다. 실행 성공 여부를 반환합니다. 17 | 18 | ```lua 19 | local bSuccess = SUE4Lua.ExecuteFile("FilePath/FileName") 20 | ``` 21 | 22 | ## SUE4Lua.LoadString(LuaString) 23 | 24 | 입력 텍스트의 소스를 불러옵니다. 반환값은 함수입니다. 25 | 26 | ```lua 27 | local Function = SUE4Lua.LoadString("local Value = 123") 28 | ``` 29 | 30 | ## SUE4Lua.LoadFile(LuaFilename) 31 | 32 | 입력 텍스트의 소스를 불러옵니다. 반환값은 함수입니다. 33 | 34 | ```lua 35 | local Function = SUE4Lua.LoadFile("FilePath/FileName") 36 | ``` 37 | 38 | ## SUE4Lua.GetEnumTable(EnumName) 39 | 40 | 입력 이름의 Enum을 Table로 반환합니다. 41 | 42 | ```lua 43 | local ESlateVisibility = SUE4Lua.GetEnumTable("ESlateVisibility") 44 | 45 | local Enum1 = ESlateVisibility.Visible -- 0 46 | local Enum2 = ESlateVisibility.Collapsed -- 1 47 | local Enum3 = ESlateVisibility.Hidden -- 2 48 | local Enum4 = ESlateVisibility.HitTestInvisible -- 3 49 | local Enum5 = ESlateVisibility.SelfHitTestInvisible -- 4 50 | ``` 51 | 52 | ## SUE4Lua.SetDispatchHandlerFactory(Function) 53 | 54 | UE4의 클래스에 대응하는 루아 파일을 디스패치하는 핸들러를 등록합니다. 55 | 56 | ```lua 57 | SUE4Lua.SetDispatchHandlerFactory(function (CallerClass) 58 | local ClassName = CallerClass:GetName() 59 | local Filename = ("Game/SomePath/%s.lua"):format(ClassName) 60 | return Filename 61 | end) 62 | ``` 63 | 64 | ## SUE4Lua.IsFixedArray(Userdata) 65 | 66 | 입력 Userdata가 고정 크기 배열(예 : int32[]) 인지 확인합니다. 67 | 68 | ## SUE4Lua.IsArray(Userdata) 69 | 70 | 입력 Userdata가 UE4의 TArray인지 확인합니다. 71 | 72 | ## SUE4Lua.IsMap(Userdata) 73 | 74 | 입력 Userdata가 UE4의 TMap인지 확인합니다. 75 | 76 | ## SUE4Lua.IsSet(Userdata) 77 | 78 | 입력 Userdata가 UE4의 TSet인지 확인합니다. 79 | 80 | ## SUE4Lua.IsDebuggable() 81 | 82 | 디버깅이 가능한 환경인 지 확인합니다. 83 | 84 | ------------------------------------ 85 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4.Color_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 Color Library 2 | 3 | SilvervineUE4Lua에서 제공하는 Color 함수 라이브러리입니다. 4 | 5 | ## operator + (C1, C2) 6 | 7 | 두 색상 C1, C2를 덧셈한 결과를 가져옵니다. 8 | 9 | ```lua 10 | local Color1 = UE4.Color.new(1, 2, 3, 4) 11 | local Color2 = UE4.Color.new(5, 6, 7, 8) 12 | 13 | local Return = Color1 + Color2 -- Color(6, 8, 10, 12) 14 | ``` 15 | 16 | ## operator == (C1, C2) 17 | 18 | 두 색상 C1, C2가 동일한지 확인합니다. 19 | 20 | ```lua 21 | local Color1 = UE4.Color.new(1, 2, 3, 4) 22 | local Color2 = UE4.Color.new(1, 2, 3, 4) 23 | 24 | local Return = Color1 == Color2 -- true 25 | ``` 26 | 27 | ## UE4.Color.ToLinearColor(C) 28 | 29 | 색상을 선형색상으로 가져옵니다. 30 | 31 | ```lua 32 | local Color = UE4.Color.new(255, 0, 255, 0) 33 | 34 | local Return1 = UE4.Color.ToLinearColor(Color) -- LinearColor(1.0, 0.0, 1.0, 0.0) 35 | local Return2 = Color:ToLinearColor() -- LinearColor(1.0, 0.0, 1.0, 0.0) 36 | ``` 37 | 38 | ------------------------------------ 39 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4.PlatformTime_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 PlatformTime Library 2 | 3 | UE4의 플랫폼 별 시간과 관련된 기능을 지원하는 라이브러리입니다. 4 | 5 | ## UE4.PlatformTime.Seconds() 6 | 7 | 게임 시작으로부터 지난 시간을 초 단위로 반환합니다. 8 | 9 | ------------------------------------ 10 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4.PointerEvent_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 PointerEvent Library 2 | 3 | UE4의 PointerEvent 관련된 기능을 지원하는 라이브러리입니다. 4 | 5 | ## UE4.PointerEvent.GetScreenSpacePosition(PointEvent) 6 | 7 | 화면 공간에서 커서의 위치를 반환합니다. 8 | 9 | ## UE4.PointerEvent.GetLastScreenSpacePosition(PointEvent) 10 | 11 | 입력 이벤트를 마지막으로 처리 할 때 화면 공간에서 커서의 위치를 반환합니다. 12 | 13 | ## UE4.PointerEvent.GetCursorDelta(PointEvent) 14 | 15 | 마지막 이벤트가 처리 된 이후 마우스가 이동한 거리를 반환합니다. 16 | 17 | ## UE4.PointerEvent.IsLeftMouseButtonDown(PointEvent) 18 | 19 | 현재 눌려진 마우스 버튼이 왼쪽 버튼인지 확인합니다. 인자 PointEvent는 FPointerEvent 구조체입니다. 20 | 21 | ## UE4.PointerEvent.IsMouseRightButtonDown(PointEvent) 22 | 23 | 현재 눌려진 마우스 버튼이 오른쪽 버튼인지 확인합니다. 인자 PointEvent는 FPointerEvent 구조체입니다. 24 | 25 | ## UE4.PointerEvent.GetEffectingButton(PointEvent) 26 | 27 | 이 이벤트를 일으킨 마우스 버튼 정보를 반환합니다. (EB_None 일 가능성이 있음) 반환 타입은 FKey입니다. 28 | 29 | ## UE4.PointerEvent.GetWheelDelta(PointEvent) 30 | 31 | 마지막 마우스 이벤트 이후 마우스 휠이 돌았는지에 대한 값을 반환합니다. 32 | 33 | ## UE4.PointerEvent.GetUserIndex(PointEvent) 34 | 35 | 이벤트의 원인이 된 사용자의 인덱스를 반환합니다. 36 | 37 | ## UE4.PointerEvent.GetPointerIndex(PointEvent) 38 | 39 | 포인터의 고유 식별자를 반환합니다 (예 : finger index) 40 | 41 | ## UE4.PointerEvent.GetTouchpadIndex(PointEvent) 42 | 43 | 이벤트를 생성 한 터치 패드의 인덱스를 반환합니다 (사용자 당 여러 개의 터치 패드가 있는 플랫폼의 경우) 44 | 45 | ## UE4.PointerEvent.IsTouchEvent(PointEvent) 46 | 47 | 이 이벤트가 (마우스가 아닌) 터치로 인한 결과인지 확인합니다. 48 | 49 | ## UE4.PointerEvent.GetGestureType(PointEvent) 50 | 51 | 터치 동작 유형을 반환합니다. 52 | 53 | ## UE4.PointerEvent.GetGestureDelta(PointEvent) 54 | 55 | 동일한 유형의 마지막 동작 이벤트 이후의 동작 값의 변경을 반환합니다. 56 | 57 | ------------------------------------ 58 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4.QualifiedFrameTime_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 QualifiedFrameTime Library 2 | 3 | SilvervineUE4Lua에서 제공하는 QualifiedFrameTime 함수 라이브러리입니다. 4 | 5 | ## UE4.QualifiedFrameTime.AsSeconds(QFT) 6 | 7 | 프레임시간 QFT를 초 단위의 값으로 변환합니다. 8 | 9 | ```lua 10 | local FrameTime = UE4.FrameTime.new(UE4.FrameNumber.new(10), 0.1) 11 | local FrameRate = UE4.FrameRate.new(10, 20) 12 | local QualifiedFrameTime = UE4.QualifiedFrameTime.new(FrameTime, FrameRate) 13 | 14 | local Return1 = UE4.QualifiedFrameTime.AsSeconds(QualifiedFrameTime) -- 20.2 15 | local Return2 = QualifiedFrameTime:AsSeconds() -- 20.2 16 | ``` 17 | 18 | ## UE4.QualifiedFrameTime.ConvertTo(QFT, DesiredFrameRate) 19 | 20 | 프레임시간 QFT를 프레임속도 DesiredFrameRate를 이용하여 변환합니다. 21 | 22 | ```lua 23 | local FrameTime = UE4.FrameTime.new(UE4.FrameNumber.new(10), 0.1) 24 | local FrameRate = UE4.FrameRate.new(10, 20) 25 | local QualifiedFrameTime = UE4.QualifiedFrameTime.new(FrameTime, FrameRate) 26 | local DesiredFrameRate = UE4.FrameRate.new(30, 40) 27 | 28 | local Return1 = UE4.QualifiedFrameTime.ConvertTo(QualifiedFrameTime, DesiredFrameRate) -- FrameTime(FrameNumber(15), 0.15) 29 | local Return2 = QualifiedFrameTime:ConvertTo(DesiredFrameRate) -- FrameTime(FrameNumber(15), 0.15) 30 | ``` 31 | 32 | ------------------------------------ 33 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4.TextFormatter_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 TextFormatter Library 2 | 3 | UE4의 TextFormatter 관련된 기능을 지원하는 라이브러리입니다. 4 | 5 | ## UE4.TextFormatter.Format(Text, ...) 6 | 7 | FText::Format 혹은 블루프린트의 Format Text와 유사한 기능을 제공합니다. 8 | 9 | 2번째 인자로 테이블 혹은 가변인자를 입력할 수 있습니다. 10 | 11 | ```lua 12 | local Return1 = UE4.TextFormatter.Format("You currently have {CurrentHealth} health left.", { CurrentHealth = 100 }) 13 | -- "You currently have 100 health left." 14 | local Return2 = UE4.TextFormatter.Format("{0} / {1}", 100, 200) 15 | -- "100 / 200" 16 | ``` 17 | 18 | 포매팅에 대한 자세한 사항은 [UE4 문서](http://api.unrealengine.com/KOR/Gameplay/Localization/Formatting/)를 참고하세요 19 | 20 | ------------------------------------ 21 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UE4_ko.md: -------------------------------------------------------------------------------- 1 | # UE4 Library 2 | 3 | UE4의 기본적인 기능을 지원하는 라이브러리입니다. 4 | 5 | ## UE4.FindClass(ClassName) 6 | 7 | 입력 이름과 일치하는 UClass를 찾아서 반환합니다. 8 | 9 | ```lua 10 | local Class = UE4.FindClass("Actor") 11 | ``` 12 | 13 | ## UE4.LoadObject(Class, Outer, Name) 14 | 15 | 입력 정보와 일치하는 UObject를 불러옵니다. 16 | 17 | ```lua 18 | local Class = UE4.FindClass("LevelSequence") 19 | local ObjectName = "/Game/ObjectName.ObjectName_C" 20 | 21 | local Object = UE4.LoadObject(Class, nil, ObjectName) 22 | ``` 23 | 24 | ## UE4.NewObject(Class, Outer) 25 | 26 | 입력 정보와 일치하는 UObject를 생성하여 반환합니다. 27 | 28 | ```lua 29 | local Class = UE4.FindClass("LevelSequence") 30 | 31 | local Object = UE4.NewObject(Class, Outer) 32 | ``` 33 | 34 | ## UE4.NewStruct(StructName) 35 | 36 | 입력 정보와 일치하는 UStruct를 생성하여 반환합니다. 37 | 38 | ```lua 39 | local Struct = UE4.NewStruct("SlateColor") 40 | Struct.SpecifiedColor = UE4.LinearColor.new(0.66, 0.66, 0.66, 1.0) 41 | ``` 42 | 43 | ## UE4.CreateWidget(OwningObject, Class) 44 | 45 | 입력 정보와 일치하는 위젯을 생성하여 반환합니다. 46 | 47 | ```lua 48 | local UObject = UE4.FindClass("Object") 49 | local WidgetName = "/Game/WidgetName.WidgetName_C" 50 | local WidgetClass = UE4.LoadObject(UObject, nil, WidgetName) 51 | 52 | local Widget = UE4.CreateWidget(self:GetWorld(), WidgetClass) 53 | Widget:AddToViewport(0) 54 | ``` 55 | 56 | ## UE4.IsValid(UObject) 57 | 58 | 입력 UObject가 유효한 지(non null and not garbage collected) 확인합니다. 59 | 60 | ------------------------------------ 61 | [라이브러리](Library_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UnitTest.md: -------------------------------------------------------------------------------- 1 | 2 | Unit Test 3 | ========= 4 | 5 | SUE4Lua uses the [UE4 Automation System](https://docs.unrealengine.com/en-US/Programming/Automation/index.html) to run unit tests. 6 | 7 | When the editor starts, the registered unit tests are executed. If an error occurs, it is printed to the log. 8 | 9 | To run unit tests yourself: 10 | 1. Go to Window -> Developer Tools -> Session Frontend. 11 | 2. On the Automation tab, check 'Silvervine.UE4Lua' and press the Start button. 12 | 13 | ![](Images/UnitTest_AutomationTab.png) ![](Images/UnitTest_AutomationLog.png) 14 | 15 | Adding a unit test 16 | ------------------ 17 | 18 | Add your unit test [here](../Source/SilvervineUE4Lua/Private/Tests). 19 | 20 | For example, 21 | ```cpp 22 | //============================================================================================================================= 23 | // FSUE4LuaTestCaseVM 24 | //============================================================================================================================= 25 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseVM, "Silvervine.UE4Lua.VM", SUE4LUA_ATF_UNITTEST) 26 | bool FSUE4LuaTestCaseVM::RunTest(const FString& Parameters) 27 | { 28 | auto VM = FSUE4LuaVirtualMachine::Create(); 29 | 30 | TestTrue(TEXT("VM.Create()"), VM.IsValid()); 31 | 32 | return true; 33 | } 34 | ``` 35 | 36 | ------------------------------------------------ 37 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/UnitTest_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Unit Test 3 | ========= 4 | 5 | SUE4Lua는 [UE4 자동화 시스템](http://api.unrealengine.com/KOR/Programming/Automation/)을 사용해서 유닛 테스트를 처리합니다. 6 | 7 | 에디터가 시작되면 등록된 유닛 테스트가 자동으로 실행되며 오류가 발생하면 로그에 해당 내용이 출력됩니다. 8 | 9 | 유닛 테스트를 직접 실행하려면 다음과 같이 하세요: 10 | 1. Window -> Developer Tools -> Session Frontend로 이동합니다. 11 | 2. Automation 탭에서 Silvervine.UE4Lua를 체크하고 시작 버튼을 누릅니다. 12 | 13 | ![](Images/UnitTest_AutomationTab.png) ![](Images/UnitTest_AutomationLog.png) 14 | 15 | 유닛 테스트 추가하기 16 | ------------------ 17 | 18 | [여기](../Source/SilvervineUE4Lua/Private/Tests)에 유닛 테스트 코드를 추가하세요. 19 | 20 | 예를 들어 다음과 같이 테스트 코드를 작성하시면 됩니다. 21 | ```cpp 22 | //============================================================================================================================= 23 | // FSUE4LuaTestCaseVM 24 | //============================================================================================================================= 25 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseVM, "Silvervine.UE4Lua.VM", SUE4LUA_ATF_UNITTEST) 26 | bool FSUE4LuaTestCaseVM::RunTest(const FString& Parameters) 27 | { 28 | auto VM = FSUE4LuaVirtualMachine::Create(); 29 | 30 | TestTrue(TEXT("VM.Create()"), VM.IsValid()); 31 | 32 | return true; 33 | } 34 | ``` 35 | 36 | ---------------------------------------------------- 37 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithDebugPrint.md: -------------------------------------------------------------------------------- 1 | 2 | How to Print a Debug Text 3 | ========================= 4 | 5 | Printing a Debug Text in Lua 6 | ---------------------------- 7 | 8 | Use the function `SUE4Lua.Log()` to print log messages in lua. The parameter format is the same as `print()`. 9 | ```lua 10 | SUE4Lua.Log("This is a Log message:", 123) 11 | ``` 12 | 13 | Use the function `SUE4Lua.Warning()` to print warning messages. 14 | ```lua 15 | SUE4Lua.Warning("This is a Warning message:", 123) 16 | ``` 17 | 18 | Use the function `SUE4Lua.Error()` to print error messages. 19 | ```lua 20 | SUE4Lua.Error("This is an Error message:", 123) 21 | ``` 22 | 23 | Note: 24 | * print() is internally the same as SUE4Lua.Log(). However, we recommend that you use SUE4Lua.Log() instead of print() for consistency. 25 | 26 | Printing a Debug Text in C++ 27 | ---------------------------- 28 | 29 | SUE4Lua do not provide the functionality to print lua debug texts in the game module. 30 | 31 | Use the following macros to modify the plugin codes. The parameter format is similar to UE_LOG(). 32 | ```cpp 33 | SUE4LVM_LOG(L, TEXT("This is a Log message: %d"), 123); 34 | SUE4LVM_WARNING(L, TEXT("This is a Warning message: %d"), 123); 35 | SUE4LVM_ERROR(L, TEXT("This is an Error message: %d"), 123); 36 | ``` 37 | 38 | ------------------------------------------------ 39 | [Back to Programming Guide](ProgrammingGuide.md) 40 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithDebugPrint_ko.md: -------------------------------------------------------------------------------- 1 | 2 | 디버그 텍스트 출력하기 3 | ==================== 4 | 5 | Lua에서 디버그 텍스트 출력하기 6 | ---------------------------- 7 | 8 | Lua에서 일반 로그 메시지를 출력하려면 `SUE4Lua.Log()` 함수를 사용합니다. 인자는 `print()`와 동일합니다. 9 | ```lua 10 | SUE4Lua.Log("This is a Log message:", 123) 11 | ``` 12 | 13 | 경고 메시지는 `SUE4Lua.Warning()` 함수로 출력할 수 있습니다. 14 | ```lua 15 | SUE4Lua.Warning("This is a Warning message:", 123) 16 | ``` 17 | 18 | 에러 메시지는 `SUE4Lua.Error()` 함수로 출력할 수 있습니다. 19 | ```lua 20 | SUE4Lua.Error("This is an Error message:", 123) 21 | ``` 22 | 23 | 참고: 24 | * print()는 내부적으로 SUE4Lua.Log()와 동일하게 처리됩니다. 하지만 일관성 있게 print() 대신 SUE4Lua.Log()를 사용하시는 것이 좋습니다. 25 | 26 | C++에서 Lua 디버그 텍스트 출력하기 27 | ---------------------------- 28 | 29 | 게임 모듈에서 Lua 디버그 텍스트를 출력하는 기능은 제공하지 않습니다. 30 | 31 | 플러그인 코드를 직접 수정하실 때에는 다음의 매크로를 사용하세요. 형식은 UE_LOG()와 비슷합니다. 32 | ```cpp 33 | SUE4LVM_LOG(L, TEXT("This is a Log message: %d"), 123); 34 | SUE4LVM_WARNING(L, TEXT("This is a Warning message: %d"), 123); 35 | SUE4LVM_ERROR(L, TEXT("This is an Error message: %d"), 123); 36 | ``` 37 | 38 | ---------------------------------------------------- 39 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 40 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithDirectCall.md: -------------------------------------------------------------------------------- 1 | 2 | How to Call Functions of a Dispatch Handler 3 | =========================================== 4 | 5 | When you are writing the dispatch handler code, you may want to call the lua function of another dispatch handler. 6 | SUE4Lua allows you to call functions of the dispatch handler like a normal lua function. 7 | 8 | We call this feature a _Direct Call_. 9 | 10 | ```lua 11 | function ClassA:FuncA(...) 12 | -- DirectCall 13 | self.ObjB:FuncB(1, 2, 3) 14 | end 15 | ``` 16 | ```lua 17 | function ClassB:FuncB(P1, P2, P3) 18 | SUE4Lua.Log(P1, P2, P3) -- 1 2 3 19 | end 20 | ``` 21 | 22 | Note: 23 | * Direct Call is easy to use, but it can also make lua code less understandable because it is difficult to distinguish it from the dispatch handler function. 24 | * Please let us know if you have any ideas that can improve. 25 | 26 | ------------------------------------------------ 27 | [Back to Programming Guide](ProgrammingGuide.md) 28 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithDirectCall_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua에서 디스패치 핸들러의 함수를 호출하기 3 | ====================================== 4 | 5 | 디스패치 핸들러 Lua 코드를 작성하다 보면 다른 디스패치 핸들러의 Lua 함수를 호출하고 싶을 경우가 있습니다. 6 | SUE4Lua는 디스패치 핸들러의 함수들을 일반적인 lua 함수처럼 호출할 수 있게 해 줍니다. 7 | 8 | 저희는 이 기능을 _다이렉트 콜_ 이라고 부르고 있습니다. 9 | 10 | ```lua 11 | function ClassA:FuncA(...) 12 | -- DirectCall 13 | self.ObjB:FuncB(1, 2, 3) 14 | end 15 | ``` 16 | ```lua 17 | function ClassB:FuncB(P1, P2, P3) 18 | SUE4Lua.Log(P1, P2, P3) -- 1 2 3 19 | end 20 | ``` 21 | 22 | 참고: 23 | * 다이렉트 콜이 편리하긴 한데 디스패치 대상 함수와 구별하기가 어려워 Lua 코드를 이해하기 어렵게 만들기도 합니다. 24 | * 개선할 수 있는 아이디어가 있다면 저희에게 알려 주세요. 25 | 26 | ---------------------------------------------------- 27 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithLuaValue.md: -------------------------------------------------------------------------------- 1 | 2 | Working with LuaValue 3 | ===================== 4 | 5 | Use _LuaValue_(`USUE4LuaValue`) when you want to store lua values outside of lua like C++ or blueprint. 6 | 7 | For example, 8 | 9 | ![](Images/LuaValue.png) 10 | 11 | After you add LuaValue to the blueprint, you can set any lua value in it. 12 | ```lua 13 | self.LuaValue = true -- boolean 14 | self.LuaValue = 123 -- integer 15 | self.LuaValue = 123.456 -- number 16 | self.LuaValue = 'test' -- string 17 | self.LuaValue = function () end -- function 18 | self.LuaValue = {} -- table 19 | ``` 20 | 21 | In particular, if you set a function, you can bind the lua function to a delegate or call it directly in C++. 22 | ```lua 23 | self.LuaValue = function () end 24 | self.Delegate:Bind(self:getObjectProperty("LuaValue")) 25 | ``` 26 | 27 | The function `getObjectProperty()` is the SUE4Lua function that returns the property of a given name as UObject type. 28 | 29 | This example helps you understand it. 30 | ```lua 31 | self.LuaValue = function () end 32 | self.Delegate:Bind(self.LuaValue) 33 | -- LogSUE4L: Warning: [LuaVM] [...] function: expected UObject type. 34 | -- LogSUE4L: Error: [LuaVM] [...] Delegate.Bind(): Invalid arg1 35 | ``` 36 | 37 | Note: 38 | * Saved lua values are not garbage collected until the LuaValue is destroyed. 39 | * We haven't implemented (yet) the functionality to access LuaValue with a blueprint. 40 | * It is recommended that you name the LuaValue variable as _LuaContext_ and store all lua values only in it. This allows you to isolate lua state from others, which is very helpful for code management. 41 | ```lua 42 | self.LuaContext = { 43 | MargineLeft = 0.2, 44 | MargineTop = 0.2, 45 | MargineRight = 0.8, 46 | MargineBottom = 0.8 47 | } 48 | ``` 49 | 50 | ------------------------------------------------ 51 | [Back to Programming Guide](ProgrammingGuide.md) 52 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithLuaValue_ko.md: -------------------------------------------------------------------------------- 1 | 2 | LuaValue 사용하기 3 | ================ 4 | 5 | C++이나 Blueprint와 같은 Lua 바깥에 Lua 값을 저장하고 싶을 때 _LuaValue_(`USUE4LuaValue`)를 사용합니다. 6 | 7 | 예를 들어, 8 | 9 | ![](Images/LuaValue.png) 10 | 11 | 와 같이 Blueprint에 LuaValue를 추가한 후에 Lua 코드에서 아무 Lua값이나 저장할 수 있습니다. 12 | ```lua 13 | self.LuaValue = true -- boolean 14 | self.LuaValue = 123 -- integer 15 | self.LuaValue = 123.456 -- number 16 | self.LuaValue = 'test' -- string 17 | self.LuaValue = function () end -- function 18 | self.LuaValue = {} -- table 19 | ``` 20 | 21 | 특히 함수를 저장해 두면 딜리게이트에 Lua 함수를 바인딩하거나 C++에서 Lua 함수를 바로 호출할 수 있습니다. 22 | ```lua 23 | self.LuaValue = function () end 24 | self.Delegate:Bind(self:getObjectProperty("LuaValue")) 25 | ``` 26 | 27 | `getObjectProperty()` 함수는 주어진 이름의 속성을 UObject 타입으로 반환하는 SUE4Lua에 구현된 함수입니다. 28 | 29 | 이 함수는 Lua에서 LuaValue를 Lua 값이 아닌 UObject로 다루고 싶을 때 사용합니다. 30 | 31 | 이 예제를 보시면 쉽게 이해하실 수 있습니다. 32 | ```lua 33 | self.LuaValue = function () end 34 | self.Delegate:Bind(self.LuaValue) 35 | -- LogSUE4L: Warning: [LuaVM] [...] function: expected UObject type. 36 | -- LogSUE4L: Error: [LuaVM] [...] Delegate.Bind(): Invalid arg1 37 | ``` 38 | 39 | 참고: 40 | * 저장된 Lua 값은 LuaValue가 파괴되기 전까지 gc되지 않습니다. 41 | * Blueprint로 LuaValue에 접근하는 기능은 (아직) 구현하지 않았습니다. 42 | * LuaValue 변수 이름을 _LuaContext_ 과 같이 붙이고 해당 객체의 모든 Lua 값을 이 변수에만 저장하시기를 추천합니다. 43 | 이렇게 하면 Lua 상태를 격리시킬 수 있어서 코드 관리에 크게 도움됩니다. 44 | ```lua 45 | self.LuaContext = { 46 | MargineLeft = 0.2, 47 | MargineTop = 0.2, 48 | MargineRight = 0.8, 49 | MargineBottom = 0.8 50 | } 51 | ``` 52 | 53 | ---------------------------------------------------- 54 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithTimer.md: -------------------------------------------------------------------------------- 1 | 2 | Working with Timers in Lua 3 | ========================== 4 | 5 | SUE4Lua does not provide any functionality for UE4 timers. But, using the `UKismetSystemLibrary`, you can use the timer in a way similar to the blueprint. 6 | 7 | First, you need the `UKismetSystemLibrary` class. 8 | ```lua 9 | local UKismetSystemLibrary = UE4.FindClass("KismetSystemLibrary") 10 | ``` 11 | 12 | You can create timer using the function `SetTimer()`. 13 | ```lua 14 | UKismetSystemLibrary.SetTimer(Obj, TimerFuncName, 1, false) 15 | ``` 16 | 17 | When the above code is executed, the engine executes a function of Obj with the same name as TimerFuncName in 1 second. 18 | 19 | The function to be called by timer must be UFunction. You can also call a blueprint function. 20 | 21 | See the code below for how to use timer functions. 22 | ```lua 23 | if UKismetSystemLibrary.TimerExists(Obj, TimerFuncName) then 24 | SUE4Lua.Log("TimerExists() returns true.") 25 | 26 | if UKismetSystemLibrary.IsTimerActive(Obj, TimerFuncName) then 27 | SUE4Lua.Log("IsTimerActive() returns true.") 28 | 29 | UKismetSystemLibrary.PauseTimer(Obj, TimerFuncName) 30 | end 31 | 32 | if UKismetSystemLibrary.IsTimerPaused(Obj, TimerFuncName) then 33 | SUE4Lua.Log("IsTimerPaused() returns true.") 34 | 35 | UKismetSystemLibrary.UnPauseTimer(Obj, TimerFuncName) 36 | end 37 | 38 | SUE4Lua.Log("ElapsedTime", UKismetSystemLibrary.GetTimerElapsedTime(Obj, TimerFuncName)) 39 | SUE4Lua.Log("RemainingTime", UKismetSystemLibrary.GetTimerRemainingTime(Obj, TimerFuncName)) 40 | 41 | UKismetSystemLibrary.ClearTimer(Obj, TimerFuncName) 42 | end 43 | 44 | SUE4Lua.Log("TimerExists()", UKismetSystemLibrary.TimerExists(Obj, TimerFuncName)) 45 | 46 | -- TimerExists() returns true. 47 | -- IsTimerActive() returns true. 48 | -- IsTimerPaused() returns true. 49 | -- ElapsedTime 0.0 50 | -- RemainingTime 1.0 51 | -- TimerExists() false 52 | ``` 53 | 54 | The entire test code is [here](../Source/SilvervineUE4Lua/Private/Scripts/Tests/TimerTest.lua). 55 | 56 | ------------------------------------------------ 57 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithTimer_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua에서 Timer 사용하기 3 | ===================== 4 | 5 | SUE4Lua가 UE4의 타이머에 대한 추가 기능을 제공하지는 않습니다. 6 | 하지만 `UKismetSystemLibrary`를 사용해서 Blueprint와 비슷한 방식으로 타이머를 사용할 수 있습니다. 7 | 8 | 먼저 `UKismetSystemLibrary` 클래스를 얻습니다. 9 | ```lua 10 | local UKismetSystemLibrary = UE4.FindClass("KismetSystemLibrary") 11 | ``` 12 | 13 | 타이머 생성 함수는 `SetTimer()` 입니다. 14 | ```lua 15 | UKismetSystemLibrary.SetTimer(Obj, TimerFuncName, 1, false) 16 | ``` 17 | 18 | 위의 코드가 실행되면 엔진은 Obj의 TimerFuncName 값과 같은 이름의 함수를 1초 후에 실행합니다. 19 | 20 | 타이머로 호출할 함수는 반드시 UFunction이어야 합니다. 당연히 Blueprint 함수도 호출할 수 있습니다. 21 | 22 | 나머지 타이머 함수의 사용 방법은 아래 코드를 참고하세요. 23 | ```lua 24 | if UKismetSystemLibrary.TimerExists(Obj, TimerFuncName) then 25 | SUE4Lua.Log("TimerExists() returns true.") 26 | 27 | if UKismetSystemLibrary.IsTimerActive(Obj, TimerFuncName) then 28 | SUE4Lua.Log("IsTimerActive() returns true.") 29 | 30 | UKismetSystemLibrary.PauseTimer(Obj, TimerFuncName) 31 | end 32 | 33 | if UKismetSystemLibrary.IsTimerPaused(Obj, TimerFuncName) then 34 | SUE4Lua.Log("IsTimerPaused() returns true.") 35 | 36 | UKismetSystemLibrary.UnPauseTimer(Obj, TimerFuncName) 37 | end 38 | 39 | SUE4Lua.Log("ElapsedTime", UKismetSystemLibrary.GetTimerElapsedTime(Obj, TimerFuncName)) 40 | SUE4Lua.Log("RemainingTime", UKismetSystemLibrary.GetTimerRemainingTime(Obj, TimerFuncName)) 41 | 42 | UKismetSystemLibrary.ClearTimer(Obj, TimerFuncName) 43 | end 44 | 45 | SUE4Lua.Log("TimerExists()", UKismetSystemLibrary.TimerExists(Obj, TimerFuncName)) 46 | 47 | -- TimerExists() returns true. 48 | -- IsTimerActive() returns true. 49 | -- IsTimerPaused() returns true. 50 | -- ElapsedTime 0.0 51 | -- RemainingTime 1.0 52 | -- TimerExists() false 53 | ``` 54 | 55 | 테스트 코드 전체는 [여기](../Source/SilvervineUE4Lua/Private/Scripts/Tests/TimerTest.lua)에 있습니다. 56 | 57 | ---------------------------------------------------- 58 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithUEnum.md: -------------------------------------------------------------------------------- 1 | 2 | Working with UEnum in Lua 3 | ========================= 4 | 5 | Like C++, lua treats UEnum in integer type(_integer_). 6 | The `SUE4Lua.GetEnumTable()` function can be used to improve the readability of code that uses UEnum. 7 | 8 | ```lua 9 | local EHorizontalAlignment = SUE4Lua.GetEnumTable("EHorizontalAlignment") 10 | 11 | SUE4Lua.Log("EHorizontalAlignment.HAlign_Center", EHorizontalAlignment.HAlign_Center) 12 | -- EHorizontalAlignment.HAlign_Center 2 13 | ``` 14 | 15 | Use pairs() for enumerating a EnumTable. 16 | ```lua 17 | for k, v in pairs(EHorizontalAlignment) do 18 | SUE4Lua.Log(k, v) 19 | end 20 | -- HAlign_Right 3 21 | -- HAlign_Left 1 22 | -- HAlign_Fill 0 23 | -- HAlign_Center 2 24 | ``` 25 | 26 | You can also convert a UEnum value to a string. 27 | ```lua 28 | SUE4Lua.Log(EHorizontalAlignment.HAlign_Fill, EHorizontalAlignment:ToString(EHorizontalAlignment.HAlign_Fill)) 29 | -- 0 HAlign_Fill 30 | ``` 31 | 32 | Converting a string to a UEnum value is very simple. 33 | ```lua 34 | SUE4Lua.Log(EHorizontalAlignment.HAlign_Fill, EHorizontalAlignment["HAlign_Fill"]) 35 | -- 0 0 36 | ``` 37 | 38 | The entire code is [here](../Source/SilvervineUE4Lua/Private/Scripts/Tests/UEnumTest.lua). 39 | 40 | ------------------------------------------------ 41 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithUEnum_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua에서 UEnum 사용하기 3 | ===================== 4 | 5 | Lua는 C++과 마찬가지로 UEnum을 정수 형식(_integer_)으로 처리합니다. 6 | `SUE4Lua.GetEnumTable()` 함수를 사용하면 UEnum을 사용하는 코드의 가독성을 높일 수 있습니다. 7 | 8 | ```lua 9 | local EHorizontalAlignment = SUE4Lua.GetEnumTable("EHorizontalAlignment") 10 | 11 | SUE4Lua.Log("EHorizontalAlignment.HAlign_Center", EHorizontalAlignment.HAlign_Center) 12 | -- EHorizontalAlignment.HAlign_Center 2 13 | ``` 14 | 15 | pairs()로 EnumTable을 순회할 수 있습니다. 16 | ```lua 17 | for k, v in pairs(EHorizontalAlignment) do 18 | SUE4Lua.Log(k, v) 19 | end 20 | -- HAlign_Right 3 21 | -- HAlign_Left 1 22 | -- HAlign_Fill 0 23 | -- HAlign_Center 2 24 | ``` 25 | 26 | UEnum 값을 스트링으로 바꿀 수도 있습니다. 27 | ```lua 28 | SUE4Lua.Log(EHorizontalAlignment.HAlign_Fill, EHorizontalAlignment:ToString(EHorizontalAlignment.HAlign_Fill)) 29 | -- 0 HAlign_Fill 30 | ``` 31 | 32 | 스트링을 UEnum값으로 바꾸는 방법은 아주 간단합니다. 33 | ```lua 34 | SUE4Lua.Log(EHorizontalAlignment.HAlign_Fill, EHorizontalAlignment["HAlign_Fill"]) 35 | -- 0 0 36 | ``` 37 | 38 | 테스트 코드 전체는 [여기](../Source/SilvervineUE4Lua/Private/Scripts/Tests/UEnumTest.lua)에 있습니다. 39 | 40 | ---------------------------------------------------- 41 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithUStruct.md: -------------------------------------------------------------------------------- 1 | 2 | Working with UStruct in Lua 3 | =========================== 4 | 5 | How to use UStruct in lua is the same as for UObject. See [this](WorkWithUObject.md). 6 | 7 | Creating a UStruct Instance 8 | --------------------------- 9 | 10 | You can create a new UStruct instance using the `UE4.NewStruct()`. Unlike `UE4.NewObject()`, it takes a class name instead of a class object as an argument. 11 | ```lua 12 | local Struct = UE4.NewStruct("SlateColor") 13 | Struct.SpecifiedColor = UE4.LinearColor.new(0.66, 0.66, 0.66, 1.0) 14 | ``` 15 | 16 | ------------------------------------------------ 17 | [Back to Programming Guide](ProgrammingGuide.md) -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Documents/WorkWithUStruct_ko.md: -------------------------------------------------------------------------------- 1 | 2 | Lua에서 UStruct 사용하기 3 | ======================= 4 | 5 | Lua에서 UStruct를 사용하는 방법은 UObject와 같습니다. [여기](WorkWithUObject_ko.md)를 참고하세요. 6 | 7 | UStruct 생성하기 8 | --------------- 9 | 10 | `UE4.NewStruct()` 함수를 사용해서 새 UStruct 인스턴스를 생성할 수 있습니다. `UE4.NewObject()`와 달리 인자로 클래스 대신 이름을 사용합니다. 11 | ```lua 12 | local Struct = UE4.NewStruct("SlateColor") 13 | Struct.SpecifiedColor = UE4.LinearColor.new(0.66, 0.66, 0.66, 1.0) 14 | ``` 15 | 16 | ---------------------------------------------------- 17 | [프로그래밍 가이드](ProgrammingGuide_ko.md)로 돌아가기 -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Resources/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Resources/icon128.png -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/SilvervineUE4Lua.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "0.1.5", 5 | "FriendlyName": "Silvervine Lua Script Plugin for UE4", 6 | "Description": "", 7 | "Category": "Scripting", 8 | "CreatedBy": "ProjectDH, devCAT, NEXON", 9 | "CreatedByURL": "https://devcat.com", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "EnabledByDefault": false, 14 | "CanContainContent": false, 15 | "IsBetaVersion": false, 16 | "Installed": false, 17 | "CanBeUsedWithUnrealHeaderTool" : true, 18 | 19 | "Modules": [ 20 | { 21 | "Name": "SilvervineUE4Lua", 22 | "Type": "Runtime", 23 | "LoadingPhase": "PreDefault" 24 | }, 25 | { 26 | "Name": "SilvervineUE4LuaEditor", 27 | "Type": "Editor", 28 | "LoadingPhase": "Default" 29 | }, 30 | { 31 | "Name" : "SilvervineUE4LuaCodeGen", 32 | "Type" : "Program", 33 | "LoadingPhase" : "PostConfigInit" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaActorBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaActorBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaActorBinding::GetBindingClass() const 10 | { 11 | return AActor::StaticClass(); 12 | } 13 | 14 | FString USUE4LuaActorBinding::LuaStaticGetDebugName(const AActor* Actor) 15 | { 16 | return AActor::GetDebugName(Actor); 17 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaActorComponentBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaActorComponentBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaActorComponentBinding::GetBindingClass() const 10 | { 11 | return UActorComponent::StaticClass(); 12 | } 13 | 14 | void USUE4LuaActorComponentBinding::LuaRegisterComponent(UActorComponent* InSelf) 15 | { 16 | InSelf->RegisterComponent(); 17 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaClassBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaClassBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaClassBinding::GetBindingClass() const 10 | { 11 | return UClass::StaticClass(); 12 | } 13 | 14 | UObject* USUE4LuaClassBinding::LuaGetDefaultObject(UClass* InSelf) 15 | { 16 | return InSelf->GetDefaultObject(); 17 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaObjectBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaObjectBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaObjectBinding::GetBindingClass() const 10 | { 11 | return UObject::StaticClass(); 12 | } 13 | 14 | FString USUE4LuaObjectBinding::LuaGetName(UObject* InSelf) 15 | { 16 | return InSelf->GetName(); 17 | } 18 | 19 | UClass* USUE4LuaObjectBinding::LuaGetClass(UObject* InSelf) 20 | { 21 | return InSelf->GetClass(); 22 | } 23 | 24 | bool USUE4LuaObjectBinding::LuaIsA(UObject* InSelf, FName ClassName) 25 | { 26 | UClass* Class = FindObject(ANY_PACKAGE, *ClassName.ToString()); 27 | if (Class != nullptr) 28 | { 29 | return InSelf->IsA(Class); 30 | } 31 | else 32 | { 33 | return false; 34 | } 35 | } 36 | 37 | UWorld* USUE4LuaObjectBinding::LuaGetWorld(UObject* InSelf) 38 | { 39 | return InSelf->GetWorld(); 40 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaSceneComponentBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaSceneComponentBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaSceneComponentBinding::GetBindingClass() const 10 | { 11 | return USceneComponent::StaticClass(); 12 | } 13 | 14 | void USUE4LuaSceneComponentBinding::LuaSetupAttachment(USceneComponent* InSelf, USceneComponent* InParent, FName InSocketName) 15 | { 16 | InSelf->SetupAttachment(InParent, InSocketName); 17 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaStructBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaStructBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaStructBinding::GetBindingClass() const 10 | { 11 | return UStruct::StaticClass(); 12 | } 13 | 14 | UStruct* USUE4LuaStructBinding::LuaGetSuperStruct(UStruct* InSelf) 15 | { 16 | return InSelf->GetInheritanceSuper(); 17 | } 18 | 19 | TArray USUE4LuaStructBinding::LuaGetFieldNames(UStruct* InSelf) 20 | { 21 | TArray OutputNames; 22 | 23 | for (TFieldIterator FieldIt(InSelf, EFieldIteratorFlags::ExcludeSuper); FieldIt; ++FieldIt) 24 | { 25 | const UField* Field = *FieldIt; 26 | const UClass* FieldClass = Field->GetClass(); 27 | 28 | if (FieldClass->HasAnyCastFlag(CASTCLASS_UProperty | CASTCLASS_UFunction)) 29 | { 30 | OutputNames.Add(Field->GetName()); 31 | } 32 | } 33 | 34 | return OutputNames; 35 | } 36 | 37 | TArray USUE4LuaStructBinding::LuaGetPropertyNames(UStruct* InSelf) 38 | { 39 | TArray OutputNames; 40 | 41 | for (TFieldIterator PropIt(InSelf, EFieldIteratorFlags::ExcludeSuper); PropIt; ++PropIt) 42 | { 43 | OutputNames.Add(PropIt->GetName()); 44 | } 45 | 46 | return OutputNames; 47 | } 48 | 49 | TArray USUE4LuaStructBinding::LuaGetFunctionNames(UStruct* InSelf) 50 | { 51 | TArray OutputNames; 52 | 53 | for (TFieldIterator FuncIt(InSelf, EFieldIteratorFlags::ExcludeSuper); FuncIt; ++FuncIt) 54 | { 55 | OutputNames.Add(FuncIt->GetName()); 56 | } 57 | 58 | return OutputNames; 59 | } 60 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Bindings/LuaUserWidgetBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "Bindings/LuaUserWidgetBinding.h" 5 | 6 | #include "LuaLog.h" 7 | 8 | 9 | UClass* USUE4LuaUserWidgetBinding::GetBindingClass() const 10 | { 11 | return UUserWidget::StaticClass(); 12 | } 13 | 14 | UWidget* USUE4LuaUserWidgetBinding::LuaGetWidgetFromName(UUserWidget* InSelf, const FName& Name) 15 | { 16 | return InSelf->GetWidgetFromName(Name); 17 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaAPI.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaVirtualMachine.h" 5 | 6 | 7 | extern "C" 8 | { 9 | #define LUA_COMPAT_APIINTCASTS 1 10 | #include "lua.h" 11 | #include "lauxlib.h" 12 | #include "lualib.h" 13 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaBundleArchive.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Serialization/BufferArchive.h" 7 | #include "Serialization/MemoryReader.h" 8 | #include "Templates/SharedPointer.h" 9 | 10 | 11 | // 12 | // 압축한 zip 파일에 대한 FBufferArchive 구현. lua 번들 파일을 처리할 때 사용합니다. 13 | // 14 | // 참조 : https://en.wikipedia.org/wiki/Zip_(file_format) 15 | // 16 | class SILVERVINEUE4LUA_API FSUE4LuaBundleArchive : public FBufferArchive 17 | { 18 | public: 19 | static TSharedRef Create(const TCHAR* BundlePath); 20 | 21 | // 번들에서 파일을 읽습니다. 22 | bool ReadFile(FString& OutResult, const TCHAR* Filename); 23 | // 번들에 들어있는 파일 목록을 얻습니다. 24 | void GetFilenames(TArray& OutFilenames) { LocalFileHeaderOffsetMappings.GetKeys(OutFilenames); }; 25 | 26 | public: 27 | // Begin FBufferArchive Interface 28 | virtual FString GetArchiveName() const override { return *FString::Printf(TEXT("Lua Bundle(%s)"), *ArchiveName.ToString()); } 29 | // EndFBufferArchive Interface 30 | 31 | private: 32 | FSUE4LuaBundleArchive(bool bIsPersistent = false, const FName BundleName = NAME_None); 33 | 34 | bool ReadCentralDirectories(); 35 | 36 | private: 37 | TMap LocalFileHeaderOffsetMappings; 38 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaCall.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaCall.h" 5 | 6 | #include "LuaAPI.h" 7 | #include "LuaLog.h" 8 | #include "LuaStack.h" 9 | #include "LuaVirtualMachine.h" 10 | 11 | 12 | namespace SUE4LuaCall 13 | { 14 | bool PCall(lua_State* L, int32 ArgCount, int32 RetCount) 15 | { 16 | SUE4LuaLog::FFileLocationHintHelper FileLocationHintHelper(L, lua_gettop(L) - ArgCount); 17 | 18 | if (auto VM = FSUE4LuaVirtualMachine::PinVM(L)) 19 | { 20 | // Stack: Func, Arg1, ..., ArgN 21 | VM->PushErrorHandler(L); 22 | lua_insert(L, -2 - ArgCount); 23 | // Stack: ErrorHandler, Func, Arg1, ..., ArgN 24 | 25 | bool bSucceeded = true; 26 | int32 TopIndex = lua_gettop(L); 27 | 28 | if (lua_pcall(L, ArgCount, RetCount, -2 - ArgCount) == 0) 29 | { 30 | if (RetCount == LUA_MULTRET) 31 | { 32 | RetCount = lua_gettop(L) - (TopIndex - 1 - ArgCount); 33 | } 34 | 35 | // Stack: ErrorHandler, Ret1, ..., RetN 36 | lua_rotate(L, -1 - RetCount, -1); 37 | // Stack: Ret1, ..., RetN, ErrorHandler 38 | } 39 | else 40 | { 41 | bSucceeded = false; 42 | 43 | // 에러메시지는 이미 에러핸들러가 처리함 44 | // Stack: ErrorHandler, ErrorCode 45 | lua_pop(L, 1); 46 | // Stack: ErrorHandler 47 | } 48 | 49 | VM->PopErrorHandler(L); 50 | 51 | // Stack: Ret1, ..., RetN 52 | return bSucceeded; 53 | } 54 | 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaCall.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreUObject.h" 7 | 8 | 9 | struct lua_State; 10 | 11 | // 12 | // lua_pcall()을 간편하게 쓰기 위한 유틸리티 13 | // 14 | namespace SUE4LuaCall 15 | { 16 | // lua_pcall()을 사용해서 푸시된 lua 함수를 실행합니다. lua 스택에 함수와 인자를 푸시한 상태로 PCall()을 호출하세요. 17 | // 함수 호출이 성공하면 true, 실패하면 false를 반환합니다. 18 | bool PCall(lua_State* L, int32 ArgCount, int32 RetCount); 19 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaFileLoader.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaFileLoader.h" 5 | #include "SilvervineUE4Lua.h" 6 | 7 | 8 | FSUE4LuaFileLoader::FSUE4LuaFileLoader() 9 | { 10 | } 11 | 12 | FSUE4LuaFileLoader::~FSUE4LuaFileLoader() 13 | { 14 | } 15 | 16 | FString FSUE4LuaFileLoader::MakeCleanPath(const TCHAR* Path) 17 | { 18 | if (Path != nullptr) 19 | { 20 | // trim 21 | while (*Path != 0) 22 | { 23 | if (FChar::IsWhitespace(*Path)) 24 | { 25 | ++Path; 26 | } 27 | else 28 | { 29 | break; 30 | } 31 | } 32 | 33 | // 첫 글자 '/'는 무시 34 | Path = *Path == PathSeperator ? Path + 1 : Path; 35 | 36 | int32 Len = FCString::Strlen(Path); 37 | 38 | // trim trailing 39 | { 40 | int32 Pos = Len - 1; 41 | while (0 <= Pos) 42 | { 43 | if (FChar::IsWhitespace(Path[Pos])) 44 | { 45 | --Pos; 46 | } 47 | else 48 | { 49 | break; 50 | } 51 | } 52 | Len = Pos + 1; 53 | } 54 | 55 | // 마지막 '/'는 무시 56 | Len = (0 < Len && Path[Len - 1] == PathSeperator) ? Len - 1 : Len; 57 | 58 | return FString(Len, Path); 59 | } 60 | else 61 | { 62 | return FString(); 63 | } 64 | } 65 | 66 | bool FSUE4LuaFileLoaderHelper::LoadFileToString(FString& Result, const TCHAR* Filename) 67 | { 68 | return FSilvervineUE4LuaModule::Get().GetFileLoader().LoadFileToString(Result, Filename); 69 | } 70 | 71 | FString FSUE4LuaFileLoaderHelper::GetLocalFilePath(const TCHAR* Filename) 72 | { 73 | return FSilvervineUE4LuaModule::Get().GetFileLoader().GetLocalFilePath(Filename); 74 | } 75 | 76 | TArray FSUE4LuaFileLoaderHelper::GetFilenames(const TCHAR* Path) 77 | { 78 | return FSilvervineUE4LuaModule::Get().GetFileLoader().GetFilenames(Path); 79 | } 80 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaLibrary.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | 8 | struct lua_State; 9 | 10 | 11 | // 12 | // lua에서 사용할 c++ 라이브러리 구현 13 | // 14 | namespace SUE4LuaLibrary 15 | { 16 | void RegisterSUE4LuaLibrary(lua_State* L); 17 | void RegisterUE4Library(lua_State* L); 18 | void RegisterPlatformTimeLibrary(lua_State* L); 19 | void RegisterMathLibrary(lua_State* L); 20 | void RegisterVectorLibrary(lua_State* L); 21 | void RegisterVector2DLibrary(lua_State* L); 22 | void RegisterTransformLibrary(lua_State* L); 23 | void RegisterRotatorLibrary(lua_State* L); 24 | void RegisterQuatLibrary(lua_State* L); 25 | void RegisterColorLibrary(lua_State* L); 26 | void RegisterLinearColorLibrary(lua_State* L); 27 | void RegisterTextFormatterLibrary(lua_State* L); 28 | void RegisterDateTimeLibrary(lua_State* L); 29 | void RegisterTimespanLibrary(lua_State* L); 30 | void RegisterQualifiedFrameTimeLibrary(lua_State* L); 31 | void RegisterPointerEventLibrary(lua_State* L); 32 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaNativeValue.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaNativeValue.h" 5 | 6 | 7 | //============================================================================================================================= 8 | // FSUE4LuaNativeValue 9 | //============================================================================================================================= 10 | int32 FSUE4LuaNativeValue::InstanceCount = 0; 11 | 12 | FSUE4LuaNativeValue::FSUE4LuaNativeValue() 13 | { 14 | ++InstanceCount; 15 | } 16 | 17 | FSUE4LuaNativeValue::~FSUE4LuaNativeValue() 18 | { 19 | --InstanceCount; 20 | } 21 | 22 | FSUE4LuaUObjectValue::FSUE4LuaUObjectValue(UObject* InTargetUObject) 23 | { 24 | TargetUObject = InTargetUObject; 25 | } 26 | 27 | void* FSUE4LuaUObjectValue::GetValueAddress() 28 | { 29 | if (auto TargetUObjectPtr = TargetUObject.Get()) 30 | { 31 | return TargetUObjectPtr; 32 | } 33 | 34 | return nullptr; 35 | } 36 | 37 | //============================================================================================================================= 38 | // FSUE4LuaUStructValue 39 | //============================================================================================================================= 40 | FSUE4LuaUStructValue::FSUE4LuaUStructValue(const UStruct* InStruct) 41 | : StructInstance(InStruct) 42 | { 43 | } 44 | 45 | void* FSUE4LuaUStructValue::GetValueAddress() 46 | { 47 | if (StructInstance.IsValid()) 48 | { 49 | return StructInstance.GetStructMemory(); 50 | } 51 | 52 | return nullptr; 53 | } 54 | 55 | //============================================================================================================================= 56 | // FSUE4LuaUPropertyValue 57 | //============================================================================================================================= 58 | FSUE4LuaUPropertyValue::FSUE4LuaUPropertyValue(const UProperty* InProperty) 59 | : Property(InProperty) 60 | { 61 | Buffer = FMemory::Malloc(Property->GetSize(), Property->GetMinAlignment()); 62 | Property->InitializeValue(Buffer); 63 | } 64 | 65 | FSUE4LuaUPropertyValue::~FSUE4LuaUPropertyValue() 66 | { 67 | Property->DestroyValue(Buffer); 68 | FMemory::Free(Buffer); 69 | Buffer = nullptr; 70 | } 71 | 72 | void* FSUE4LuaUPropertyValue::GetValueAddress() 73 | { 74 | return Buffer; 75 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaNativeValue.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | #include "Templates/RefCounting.h" 8 | #include "UObject/StructOnScope.h" 9 | #include "UObject/WeakObjectPtr.h" 10 | 11 | 12 | // 13 | // lua에서 UObject, UStruct 등을 참조할 때 사용합니다. 14 | // 15 | class FSUE4LuaNativeValue : public FRefCountedObject 16 | { 17 | public: 18 | FSUE4LuaNativeValue(); 19 | virtual ~FSUE4LuaNativeValue(); 20 | 21 | FORCEINLINE bool IsValid() 22 | { 23 | return GetValueAddress() != nullptr; 24 | } 25 | 26 | // 값의 주소를 반환한다. 27 | // UObject*처럼 약참조되는 값들은 null을 반환할 수 있다. 28 | virtual void* GetValueAddress() = 0; 29 | 30 | public: 31 | static int32 GetInstanceCount() { return InstanceCount; } 32 | 33 | static int32 InstanceCount; 34 | }; 35 | 36 | // 37 | // UObject에 대한 FSUE4LuaNativeValue 구현 38 | // 대상 UObject에 대한 약참조를 갖고 있습니다. 39 | // 40 | class FSUE4LuaUObjectValue : public FSUE4LuaNativeValue 41 | { 42 | public: 43 | FSUE4LuaUObjectValue(UObject* InTargetUObject); 44 | 45 | public: 46 | // Begin FSUE4LuaNativeValue Interface 47 | virtual void* GetValueAddress() override; 48 | // End FSUE4LuaNativeValue Interface 49 | 50 | private: 51 | TWeakObjectPtr TargetUObject; 52 | }; 53 | 54 | // 55 | // 동적으로 생성한 UStruct에 대한 FSUE4LuaNativeValue 구현 56 | // 57 | class FSUE4LuaUStructValue : public FSUE4LuaNativeValue 58 | { 59 | public: 60 | FSUE4LuaUStructValue(const UStruct* InStruct); 61 | 62 | public: 63 | // Begin FSUE4LuaNativeValue Interface 64 | virtual void* GetValueAddress() override; 65 | // End FSUE4LuaNativeValue Interface 66 | 67 | private: 68 | FStructOnScope StructInstance; 69 | }; 70 | 71 | // 72 | // 동적으로 생성한 UProperty에 대한 FSUE4LuaNativeValue 구현. 73 | // UStructProperty는 이 클래스 대신 FSUE4LuaUStructValue를 사용합니다. 74 | // 75 | class FSUE4LuaUPropertyValue : public FSUE4LuaNativeValue 76 | { 77 | public: 78 | FSUE4LuaUPropertyValue(const UProperty* InProperty); 79 | virtual ~FSUE4LuaUPropertyValue(); 80 | 81 | public: 82 | // Begin FSUE4LuaNativeValue Interface 83 | virtual void* GetValueAddress() override; 84 | // End FSUE4LuaNativeValue Interface 85 | 86 | private: 87 | const UProperty* Property = nullptr; 88 | void* Buffer = nullptr; 89 | }; 90 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaStaticBinding.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaStaticBinding.h" 5 | 6 | #include "LuaAPI.h" 7 | #include "LuaLog.h" 8 | #include "LuaUFunction.h" 9 | 10 | 11 | FSUE4LuaFunctionStaticBindingContext::FSUE4LuaFunctionStaticBindingContext(lua_State* InL, int32 InArgStackBaseIndex, const TCHAR* InFunctionName) 12 | : L(InL) 13 | , ArgStackBaseIndex(InArgStackBaseIndex) 14 | , FunctionName(InFunctionName) 15 | { 16 | bPassByName = SUE4LuaUFunction::IsParameterTable(L, ArgStackBaseIndex); 17 | 18 | if (bPassByName) 19 | { 20 | // pass-by-name 방식에서는 인자 수를 확인하지 않습니다. 21 | ArgCount = 0; 22 | } 23 | else 24 | { 25 | ArgCount = lua_gettop(L) - ArgStackBaseIndex + 1; 26 | } 27 | } 28 | 29 | void FSUE4LuaFunctionStaticBindingContext::LuaPushValue(int32 Index) 30 | { 31 | lua_pushvalue(L, Index); 32 | } 33 | 34 | bool FSUE4LuaFunctionStaticBindingContext::LuaGetField(const char* Name) 35 | { 36 | return lua_getfield(L, ArgStackBaseIndex, Name) != LUA_TNIL; 37 | } 38 | 39 | void FSUE4LuaFunctionStaticBindingContext::LuaSetField(const char* Name) 40 | { 41 | lua_setfield(L, ArgStackBaseIndex, Name); 42 | } 43 | 44 | void FSUE4LuaFunctionStaticBindingContext::HandleMissingParameter(const char* ArgName) 45 | { 46 | SUE4LVM_WARNING(L, TEXT("Found missing parameter '%s' while calling function '%s'."), UTF8_TO_TCHAR(ArgName), FunctionName); 47 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaThread.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaThread.h" 5 | 6 | #include "LuaAPI.h" 7 | #include "LuaLog.h" 8 | #include "LuaVirtualMachine.h" 9 | 10 | 11 | FSUE4LuaThread::FSUE4LuaThread(TSharedRef InVM, lua_State* InLuaState) 12 | : WeakVM(InVM) 13 | , LuaState(InLuaState) 14 | { 15 | check(LuaState != nullptr); 16 | } 17 | 18 | FSUE4LuaThread::~FSUE4LuaThread() 19 | { 20 | LuaState = nullptr; 21 | } 22 | 23 | TSharedPtr FSUE4LuaThread::Create(TSharedRef VM, lua_State* LuaState) 24 | { 25 | if (VM->IsDisposed()) 26 | { 27 | UE_LOG(LogSUE4L, Warning, TEXT("Disposed VM is passed. [%s]"), __SUE4LUA_FUNCTION__); 28 | return nullptr; 29 | } 30 | if (LuaState == nullptr) 31 | { 32 | UE_LOG(LogSUE4L, Warning, TEXT("Invalid lua state. [%s]"), __SUE4LUA_FUNCTION__); 33 | return nullptr; 34 | } 35 | 36 | auto LuaThread = TSharedPtr(new FSUE4LuaThread(VM, LuaState)); 37 | 38 | return LuaThread; 39 | } 40 | 41 | void FSUE4LuaThread::SetDisposed() 42 | { 43 | if (LuaState == nullptr) 44 | { 45 | UE_LOG(LogSUE4L, Warning, TEXT("Already disposed. [%s]"), __SUE4LUA_FUNCTION__); 46 | return; 47 | } 48 | 49 | LuaState = nullptr; 50 | } 51 | 52 | TSharedPtr FSUE4LuaThread::PinVM() const 53 | { 54 | auto VM = WeakVM.Pin(); 55 | 56 | if (VM.IsValid() && !VM->IsDisposed()) 57 | { 58 | return VM; 59 | } 60 | 61 | return nullptr; 62 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUFunction.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreUObject.h" 7 | 8 | 9 | struct lua_State; 10 | 11 | // 12 | // lua에서 UFunction을 호출할 때 사용. 13 | // 14 | namespace SUE4LuaUFunction 15 | { 16 | // pass-by-name 방식으로 함수를 호출할 때 사용하는 파라메터 테이블인지 조사합니다. 17 | bool IsParameterTable(lua_State* L, int32 StackIndex); 18 | 19 | // UFunction을 호출하는 lua 클로저를 푸시합니다. 20 | void PushClosure(lua_State* L, const UFunction* Function); 21 | 22 | // lua 스택의 파라메터를 사용해서 UFunction을 호출합니다. 23 | // 24 | // 함수 전달 방식은 pass-by-positions과 pass-by-names를 지원합니다. 25 | // 예: -- void Foo(int32 P1, int32 P2) {} 26 | // Foo(1, 2) -- pass-by-positions 27 | // Foo({ P1 = 1, P2 = 2}) -- pass-by-names 28 | // 29 | // 함수의 반환값과 출력 파라메터(non const referenced type)가 lua 스택에 반환됩니다. 30 | // 예: -- int32 Foo(const int32& P1, int32& Out1, int32& Out2) 31 | // local Ret, Out1, Out2 = Foo(1) 32 | int32 CallFunction(lua_State* L, const UFunction* Function); 33 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUObject.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | 8 | 9 | struct lua_State; 10 | 11 | // 12 | // lua와 UObject를 주고받을 때 사용합니다. 13 | // 14 | namespace SUE4LuaUObject 15 | { 16 | // FSUE4LuaVirtualMachine이 생성될 때 호출됩니다. 17 | void Register(lua_State* L); 18 | 19 | // UObject를 lua 스택에 푸시합니다. 20 | void PushRef(lua_State* L, UObject* TargetUObject); 21 | // UObject를 lua 스택에서 팝합니다. 22 | UObject* PopRef(lua_State* L); 23 | // UObject를 lua 스택에서 팝 하지 않고 가져옵니다. 24 | UObject* ToRef(lua_State* L, int32 Index); 25 | // ToRef()와 비슷하지만 실패해도 조용히 넘어갑니다. 26 | UObject* TryToRef(lua_State* L, int32 Index); 27 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUProperty.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreUObject.h" 7 | 8 | #include "LuaFunction.h" 9 | #include "LuaNativeValue.h" 10 | 11 | 12 | struct lua_State; 13 | 14 | // 15 | // lua에서 UProperty를 통해 c++의 객체에 접근할 때 사용합니다. 16 | // 17 | namespace SUE4LuaUProperty 18 | { 19 | // FSUE4LuaVirtualMachine이 생성될 때 호출됩니다. 20 | void Register(lua_State* L); 21 | 22 | // 고정 크기 배열(int32[] 등)인지 조사 23 | bool IsFixedArray(lua_State* L, int32 StackIndex); 24 | // TArray 인지 조사 25 | bool IsArray(lua_State* L, int32 StackIndex); 26 | // TMap 인지 조사 27 | bool IsMap(lua_State* L, int32 StackIndex); 28 | // TSet 인지 조사 29 | bool IsSet(lua_State* L, int32 StackIndex); 30 | 31 | // 값타입(int32, FVector, ...)은 항상 사본이 푸시됩니다. 32 | // UObject는 포인터로 처리되므로 값타입과 같이 사본이 푸시됩니다. 33 | // 그 외의 타입은 Owner가 null이 아니면 참조를, null이면 사본값이 생성된 후에 그 참조가 푸시됩니다. 34 | void Push(lua_State* L, const UProperty* Property, const void* ValueAddress, FSUE4LuaNativeValue* Owner); 35 | 36 | // lua 스택에 있는 값을 해당 주소로 복사합니다. 37 | bool CopyToNative(lua_State* L, int32 StackIndex, const UProperty* DestProperty, void* DestValueAddress); 38 | // 해당 주소의 값을 lua 스택으로 복사합니다. 실패할 경우 조용히 넘어갑니다. 39 | bool TryCopyToLua(lua_State* L, int32 StackIndex, const UProperty* SrcProperty, const void* SrcValueAddress); 40 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUStruct.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreUObject.h" 7 | 8 | #include "LuaNativeValue.h" 9 | 10 | 11 | struct lua_State; 12 | 13 | // 14 | // lua와 UStruct를 주고받을 때 사용합니다. 15 | // 16 | namespace SUE4LuaUStruct 17 | { 18 | // FSUE4LuaVirtualMachine이 생성될 때 호출됩니다. 19 | void Register(lua_State* L); 20 | 21 | // UStruct 구조체인지 조사 22 | bool IsUStruct(lua_State* L, int32 StackIndex); 23 | 24 | // lua 스택에서 UStruct 구조체에 대한 참조(메모리 주소)를 가져옵니다. 25 | void* GetRef(lua_State* L, int32 StackIndex, const UScriptStruct* Struct); 26 | 27 | // lua 스택에 UStruct 구조체의 사본을 푸시합니다. 28 | // ValueAddress가 null이면 기본값으로 초기화합니다. 29 | void PushValue(lua_State* L, const UScriptStruct* Struct, const void* ValueAddress = nullptr); 30 | // lua 스택에 UStruct 구조체의 참조를 푸시합니다. 31 | void PushRef(lua_State* L, const UScriptStruct* Struct, const void* ValueAddress, FSUE4LuaNativeValue* Owner); 32 | 33 | // lua 스택에 있는 값을 해당 주소로 복사합니다. 34 | bool CopyToNative(lua_State* L, int32 StackIndex, const UScriptStruct* DestStruct, void* DestValueAddress); 35 | // 해당 주소의 값을 lua 스택으로 복사합니다. 실패할 경우 조용히 넘어갑니다. 36 | bool TryCopyToLua(lua_State* L, int32 StackIndex, const UScriptStruct* SrcStruct, const void* SrcValueAddress); 37 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUserData.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUserData.h" 5 | 6 | #include "LuaAPI.h" 7 | #include "LuaLog.h" 8 | #include "LuaThread.h" 9 | #include "LuaVirtualMachine.h" 10 | 11 | 12 | FSUE4LuaUserData::FSUE4LuaUserData() 13 | { 14 | } 15 | 16 | FSUE4LuaUserData::~FSUE4LuaUserData() 17 | { 18 | if (!bDisposed) 19 | { 20 | if (OwnerVM != nullptr) 21 | { 22 | OwnerVM->RemoveUserData(this); 23 | } 24 | 25 | bDisposed = true; 26 | } 27 | } 28 | 29 | void FSUE4LuaUserData::Initialize(lua_State* L) 30 | { 31 | if (auto VM = FSUE4LuaVirtualMachine::PinVM(L)) 32 | { 33 | OwnerVM = VM.Get(); 34 | OwnerVM->AddUserData(this); 35 | } 36 | 37 | UE_CLOG(OwnerVM == nullptr, LogSUE4L, Error, TEXT("Invalid OwnerVM. [%s]"), __SUE4LUA_FUNCTION__); 38 | } 39 | 40 | void FSUE4LuaUserData::Dispose() 41 | { 42 | if (bDisposed) 43 | { 44 | return; 45 | } 46 | 47 | this->~FSUE4LuaUserData(); 48 | } 49 | 50 | void* FSUE4LuaUserData::LuaNewUserData(lua_State* L, int32 Size) 51 | { 52 | return lua_newuserdata(L, Size); 53 | } 54 | 55 | void* FSUE4LuaUserData::LuaToUserData(lua_State* L, int32 StackIndex) 56 | { 57 | return lua_touserdata(L, StackIndex); 58 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaUserData.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "UObject/GCObject.h" 7 | 8 | 9 | class FSUE4LuaVirtualMachine; 10 | struct lua_State; 11 | 12 | // 13 | // lua의 fulluserdata를 생성하고 gc관리자에 등록하는 클래스 14 | // 15 | class FSUE4LuaUserData 16 | { 17 | public: 18 | FSUE4LuaUserData(); 19 | virtual ~FSUE4LuaUserData(); 20 | 21 | template 22 | static UserDataType* NewUserData(lua_State* L, ArgTypes&&... Args); 23 | 24 | template 25 | static UserDataType* ToUserData(lua_State* L, int32 StackIndex); 26 | 27 | // userdata가 lua에서 gc될 때 반드시 호출해줘야 합니다. 28 | void Dispose(); 29 | 30 | private: 31 | static void* LuaNewUserData(lua_State* L, int32 Size); 32 | static void* LuaToUserData(lua_State* L, int32 StackIndex); 33 | 34 | void Initialize(lua_State* L); 35 | 36 | bool bDisposed = false; 37 | FSUE4LuaVirtualMachine* OwnerVM = nullptr; 38 | }; 39 | 40 | template 41 | UserDataType* FSUE4LuaUserData::NewUserData(lua_State* L, ArgTypes&&... Args) 42 | { 43 | // 여기서 컴파일 에러가 난다면 UserDataType이 FSUE4LuaUserData의 파생 클래스인지 확인할 것 44 | FSUE4LuaUserData* UserData = new (LuaNewUserData(L, sizeof(UserDataType))) UserDataType(Forward(Args)...); 45 | 46 | UserData->Initialize(L); 47 | 48 | return static_cast(UserData); 49 | } 50 | 51 | template 52 | UserDataType* FSUE4LuaUserData::ToUserData(lua_State* L, int32 StackIndex) 53 | { 54 | // 여기서 컴파일 에러가 난다면 UserDataType이 FSUE4LuaUserData의 파생 클래스인지 확인할 것 55 | return static_cast(reinterpret_cast(LuaToUserData(L, StackIndex))); 56 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/LuaValueReferencer.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaValueReferencer.h" 5 | 6 | #include "LuaAPI.h" 7 | #include "LuaLog.h" 8 | #include "LuaVirtualMachine.h" 9 | 10 | 11 | FSUE4LuaValueReferencer::FSUE4LuaValueReferencer(lua_State* L, int32 StackIndex) 12 | { 13 | if (auto VM = FSUE4LuaVirtualMachine::PinVM(L)) 14 | { 15 | LuaMainThread = VM->GetLuaMainThread(); 16 | 17 | // 음수 StackIndex를 처리하기 위해서 일단 스택에 푸시 18 | lua_pushvalue(L, StackIndex); 19 | // Stack: Value 20 | 21 | // SUE4LuaBinding.AddReference(this, Value) 22 | { 23 | // Stack: func 24 | lua_getglobal(L, "SUE4LuaBinding"); 25 | lua_getfield(L, -1, "AddReference"); 26 | lua_remove(L, -2); 27 | // Stack: Value, AddReference 28 | 29 | lua_pushlightuserdata(L, this); 30 | lua_pushvalue(L, -3); 31 | // Stack: Value, AddReference, this, Value 32 | 33 | lua_pcall(L, 2, 0, 0); 34 | // Stack: Value 35 | } 36 | 37 | // Stack: Value 38 | lua_pop(L, 1); 39 | // Stack: (empty) 40 | } 41 | } 42 | 43 | FSUE4LuaValueReferencer::~FSUE4LuaValueReferencer() 44 | { 45 | if (auto VM = PinVM()) 46 | { 47 | auto L = VM->GetCurrentLuaState(); 48 | 49 | // SUE4LuaBinding.RemoveReference(this) 50 | { 51 | lua_getglobal(L, "SUE4LuaBinding"); 52 | lua_getfield(L, -1, "RemoveReference"); 53 | lua_remove(L, -2); 54 | // Stack: RemoveReference 55 | 56 | lua_pushlightuserdata(L, this); 57 | // Stack: RemoveReference, this 58 | lua_pcall(L, 1, 0, 0); 59 | // Stack: (empty) 60 | } 61 | } 62 | } 63 | 64 | TSharedPtr FSUE4LuaValueReferencer::PinVM() const 65 | { 66 | if (LuaMainThread.IsValid()) 67 | { 68 | return LuaMainThread->PinVM(); 69 | } 70 | 71 | return nullptr; 72 | } 73 | 74 | void FSUE4LuaValueReferencer::Push(lua_State* L) 75 | { 76 | // SUE4LuaBinding.GetlReferencedObj(LuaFunction*) 77 | { 78 | lua_getglobal(L, "SUE4LuaBinding"); 79 | lua_getfield(L, -1, "GetReferenced"); 80 | lua_remove(L, -2); 81 | 82 | lua_pushlightuserdata(L, this); 83 | 84 | lua_pcall(L, 1, 1, 0); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Framework/DefaultParameters.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | 5 | DefaultParameters = {} 6 | DefaultParameterClass = Class() 7 | 8 | -- USceneComponent 9 | do 10 | DefaultParameters.SceneComponent = {} 11 | 12 | -- SetupAttachment 13 | DefaultParameters.SceneComponent.SetupAttachment = Class(DefaultParameterClass) 14 | DefaultParameters.SceneComponent.SetupAttachment.InSocketName = "" 15 | end -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Framework/Prerequisite.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | 5 | --============================================================================================================================= 6 | -- strictness 7 | -- https://github.com/lua-stdlib/strict 8 | --============================================================================================================================= 9 | do 10 | local declared = { loadstring = true, setfenv = true } 11 | 12 | local mt = {} 13 | setmetatable(_G, mt) 14 | 15 | --- What kind of variable declaration is this? 16 | -- @treturn string 'C', 'Lua' or 'main' 17 | local function what() 18 | local d = debug.getinfo(3, 'S') 19 | return d and d.what or 'C' 20 | end 21 | 22 | mt.__newindex = function (t, k, v) 23 | if not declared[k] then 24 | local w = what() 25 | if w ~= 'main' and w ~= 'C' then 26 | error("assignment to undeclared variable '" .. k .. "'", 2) 27 | end 28 | 29 | declared[k] = true 30 | end 31 | 32 | rawset(t, k, v) 33 | end 34 | 35 | mt.__index = function (t, k) 36 | if not declared[k] and what() ~= 'C' then 37 | error("variable '" .. k .. "' is not declared", 2) 38 | end 39 | 40 | return rawget(t, k) 41 | end 42 | end 43 | 44 | --============================================================================================================================= 45 | -- Class 46 | -- 간단한 클래스 구현 47 | --============================================================================================================================= 48 | do 49 | -- 모든 클래스의 기본 클래스 50 | local Object = {} 51 | Object.isClass = true 52 | 53 | function Class(super) 54 | local c = setmetatable({}, { __index = super or Object }) 55 | local mt = { __index = c } 56 | 57 | c.metaTable = mt 58 | c.new = function (...) 59 | local obj = setmetatable({}, mt) 60 | if obj.init ~= nil then obj:init(...) end 61 | return obj 62 | end 63 | 64 | return c 65 | end 66 | end -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Framework/SUE4Lua.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | 5 | -- SUE4Lua 6 | assert(type(SUE4Lua) == 'table') 7 | 8 | -- SUE4Lua.VM에는 FSUE4LuaVirtualMachine*가 lightuserdata 타입으로 들어있습니다. 9 | -- c++에서 lua_State로부터 FSUE4LuaVirtualMachine을 얻을 때 사용합니다. 10 | assert(type(SUE4Lua.VM) == 'userdata') 11 | 12 | -- xpcall() 등에서 사용할 수 있는 에러 핸들러 13 | assert(type(SUE4Lua.ErrorHandler) == 'function') 14 | 15 | -- WorldContextObject 입니다. 주로 UE4.NewObject()할 때 Outer로 사용합니다. 16 | assert(SUE4Lua.WorldContextObject == nil or type(SUE4Lua.WorldContextObject) == 'userdata') 17 | 18 | -- 로그 함수 19 | assert(type(SUE4Lua.Log) == 'function') 20 | assert(type(SUE4Lua.Warning) == 'function') 21 | assert(type(SUE4Lua.Error) == 'function') 22 | 23 | -- 빌드 정보 24 | do 25 | assert(type(SUE4Lua.Build) == 'table') 26 | 27 | assert(type(SUE4Lua.Build.WITH_EDITOR) == 'boolean') 28 | end 29 | 30 | -- SUE4Lua.Log() 등으로 디버그 텍스트를 출력했을 때 호출됩니다. 31 | function SUE4Lua.OnDebugPrint(text) 32 | end 33 | 34 | -- 엔진 틱 이벤트시 호출됩니다. 35 | function SUE4Lua.OnTick(DeltaTime) 36 | end 37 | 38 | -- 개발빌드 전용: 파일이 변경되었을 때 호출됩니다. 39 | function SUE4Lua.OnFileModifiled(Filename) 40 | end 41 | 42 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Libraries/AllLIbraries.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | SUE4Lua.ExecuteFile("SUE4Lua/Libraries/CaseInsensitiveTable.lua") -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Libraries/CaseInsensitiveTable.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | --============================================================================================================================= 5 | -- CaseInsensitiveTable 6 | -- 스트링 키의 대소문자를 구별하지 않는 테이블 7 | -- 스트링 키는 모두 소문자로 저장됩니다. 8 | --============================================================================================================================= 9 | CaseInsensitiveTable = {} 10 | 11 | local mt = {} 12 | function CaseInsensitiveTable.new() 13 | return setmetatable({}, mt) 14 | end 15 | 16 | mt.__index = function (t, k) 17 | if type(k) == 'string' then 18 | k = k:lower() 19 | end 20 | return rawget(t, k) 21 | end 22 | 23 | mt.__newindex = function (t, k, v) 24 | if type(k) == 'string' then 25 | k = k:lower() 26 | end 27 | rawset(t, k, v) 28 | end 29 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/AllTests.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/AllTests.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/CoroutineTest.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/CoroutineTest.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/PCallTest.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/PCallTest.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/PerformanceTest.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/PerformanceTest.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/TimerTest.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/TimerTest.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/UEnumTest.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts/Tests/UEnumTest.lua -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/SilvervineUE4LuaSettings.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "SilvervineUE4LuaSettings.h" 5 | 6 | #include "Misc/Paths.h" 7 | 8 | #include "LuaBindingRegistry.h" 9 | #include "LuaBundleFileLoader.h" 10 | #include "LuaLocalFileLoader.h" 11 | #include "SilvervineUE4Lua.h" 12 | 13 | 14 | const USUE4LuaSettings* USUE4LuaSettings::Get() 15 | { 16 | return GetDefault(); 17 | } 18 | 19 | FName USUE4LuaSettings::GetCategoryName() const 20 | { 21 | return TEXT("Plugins"); 22 | } 23 | 24 | void USUE4LuaSettings::SetFileLoader() const 25 | { 26 | FString ProjectDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()); 27 | if (bUseBundleFileLoader) 28 | { 29 | auto BundleFileLoader = TSharedPtr(new FSUE4LuaBundleFileLoader); 30 | for (const auto& Set : BundleFileLoadMap) 31 | { 32 | BundleFileLoader->Map(*Set.Key, *FPaths::Combine(ProjectDir, *Set.Value)); 33 | } 34 | FSilvervineUE4LuaModule::Get().SetFileLoader(BundleFileLoader); 35 | } 36 | else 37 | { 38 | auto LocalFileLoader = TSharedPtr(new FSUE4LuaLocalFileLoader); 39 | for (const auto& Set : LocalFileLoadMap) 40 | { 41 | LocalFileLoader->Map(*Set.Key, *FPaths::Combine(ProjectDir, *Set.Value)); 42 | } 43 | FSilvervineUE4LuaModule::Get().SetFileLoader(LocalFileLoader); 44 | } 45 | } 46 | 47 | #if WITH_EDITOR 48 | FText USUE4LuaSettings::GetSectionText() const 49 | { 50 | return NSLOCTEXT("SilvervineUE4Lua", "SilvervineUE4LuaSettingsName", "SilvervineUE4Lua"); 51 | } 52 | FText USUE4LuaSettings::GetSectionDescription() const 53 | { 54 | return NSLOCTEXT("SilvervineUE4Lua", "SilvervineUE4LuaSettingsDescription", "Configuration for SilvervineUE4Lua"); 55 | } 56 | 57 | void USUE4LuaSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) 58 | { 59 | if (PropertyChangedEvent.Property != nullptr) 60 | { 61 | SetFileLoader(); 62 | FSUE4LuaBindingRegistry::Get().SetStaticBindingEnabled(bEnableStaticBinding); 63 | } 64 | } 65 | #endif // WITH_EDITOR -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestCaseInsensitiveTable.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseCaseInsensitiveTable 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseCaseInsensitiveTable, "Silvervine.UE4Lua.CaseInsensitiveTable", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseCaseInsensitiveTable::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | { 22 | VM->ExecuteString( 23 | TEXT("\n function Test()") 24 | TEXT("\n local t = CaseInsensitiveTable.new()") 25 | TEXT("\n local value = 123") 26 | TEXT("\n t.aBc = value") 27 | TEXT("\n return t.Abc == value") 28 | TEXT("\n end")); 29 | TestTrue(TEXT("CaseInsensitiveTable StringKey"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 30 | } 31 | { 32 | VM->ExecuteString( 33 | TEXT("\n function Test()") 34 | TEXT("\n local t = CaseInsensitiveTable.new()") 35 | TEXT("\n local value = 123") 36 | TEXT("\n t[1] = value") 37 | TEXT("\n return t[1] == value") 38 | TEXT("\n end")); 39 | TestTrue(TEXT("CaseInsensitiveTable IntKey"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 40 | } 41 | 42 | return true; 43 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestCoroutine.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseCoroutine 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseCoroutine, "Silvervine.UE4Lua.Coroutine", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseCoroutine::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | auto TestUObject = NewObject(); 22 | 23 | { 24 | int32 TestValue = 123; 25 | TestUObject->ValueProperty = nullptr; 26 | 27 | VM->ExecuteString( 28 | TEXT("\n function Test(uobj, arg)") 29 | TEXT("\n local co = coroutine.create(function ()") 30 | TEXT("\n return uobj:TestCoroutine(arg)") 31 | TEXT("\n end)") 32 | TEXT("\n uobj.ValueProperty = function (arg) return arg end") 33 | TEXT("\n local _, ret = coroutine.resume(co)") 34 | TEXT("\n return ret") 35 | TEXT("\n end")); 36 | TestTrue(TEXT("Call<>() in Coroutine"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject, TestValue) == TestValue); 37 | } 38 | { 39 | int32 TestValue = 123; 40 | TestUObject->ValueProperty = nullptr; 41 | 42 | VM->ExecuteString( 43 | TEXT("\n function Test(uobj, arg)") 44 | TEXT("\n local co = coroutine.create(function ()") 45 | TEXT("\n uobj.ValueProperty = function (arg) return arg end") 46 | TEXT("\n return uobj.ValueProperty(arg)") 47 | TEXT("\n end)") 48 | TEXT("\n local _, ret = coroutine.resume(co)") 49 | TEXT("\n return ret") 50 | TEXT("\n end")); 51 | TestTrue(TEXT("Create LuaFunction in Coroutine"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject, TestValue) == TestValue); 52 | } 53 | 54 | return true; 55 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestFunction.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseFunction 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseFunction, "Silvervine.UE4Lua.Function", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseFunction::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | VM->ExecuteString( 22 | TEXT("\n function ReturnArg(arg1, ...)") 23 | TEXT("\n return arg1") 24 | TEXT("\n end") 25 | TEXT("\n function ReturnFunc(...)") 26 | TEXT("\n return ReturnArg") 27 | TEXT("\n end")); 28 | 29 | auto LuaFunc_ReturnArg = FSUE4LuaFunction::CreateFromGlobal(VM.ToSharedRef(), TEXT("ReturnArg")); 30 | TestTrue(TEXT("Function.CreateFromGlobal()"), LuaFunc_ReturnArg.IsValid()); 31 | 32 | if (!LuaFunc_ReturnArg.IsValid()) 33 | { 34 | return false; 35 | } 36 | 37 | { 38 | const int32 Arg = 123; 39 | const int32 UnusedArg = 456; 40 | TestTrue(TEXT("Function(Arg, UnusedArg)"), LuaFunc_ReturnArg->Call(Arg, UnusedArg) == Arg); 41 | } 42 | { 43 | auto ReturnedLuaFunction = FSUE4LuaFunction::CallGlobal>(VM.ToSharedRef(), TEXT("ReturnFunc")); 44 | TestTrue(TEXT("Function() Returns Function"), ReturnedLuaFunction.IsValid()); 45 | 46 | if (ReturnedLuaFunction.IsValid()) 47 | { 48 | const int32 Arg = 123; 49 | TestTrue(TEXT("ReturnedLuaFunction()"), ReturnedLuaFunction->Call(Arg) == Arg); 50 | } 51 | } 52 | 53 | { 54 | auto TestFunction = FSUE4LuaFunction::CreateFromGlobal(VM.ToSharedRef(), TEXT("ReturnArg")); 55 | TestTrue(TEXT("Function.IsSame()"), LuaFunc_ReturnArg->IsSame(TestFunction)); 56 | } 57 | 58 | return true; 59 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestSUE4Lua.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseSUE4Lua 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseSUE4Lua, "Silvervine.UE4Lua.SUE4Lua", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseSUE4Lua::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | auto TestUObject = NewObject(); 22 | 23 | { 24 | VM->ExecuteString( 25 | TEXT("\n function Test(uobj)") 26 | TEXT("\n return SUE4Lua.IsFixedArray(uobj.FixedIntArrayProperty)") 27 | TEXT("\n end")); 28 | TestTrue(TEXT("SUE4Lua.IsFixedArray()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject)); 29 | } 30 | { 31 | VM->ExecuteString( 32 | TEXT("\n function Test(uobj)") 33 | TEXT("\n return SUE4Lua.IsArray(uobj.IntArrayProperty)") 34 | TEXT("\n end")); 35 | TestTrue(TEXT("SUE4Lua.IntArray()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject)); 36 | } 37 | { 38 | VM->ExecuteString( 39 | TEXT("\n function Test(uobj)") 40 | TEXT("\n return SUE4Lua.IsMap(uobj.IntMapProperty)") 41 | TEXT("\n end")); 42 | TestTrue(TEXT("SUE4Lua.IsMap()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject)); 43 | } 44 | { 45 | VM->ExecuteString( 46 | TEXT("\n function Test(uobj)") 47 | TEXT("\n return SUE4Lua.IsSet(uobj.IntSetProperty)") 48 | TEXT("\n end")); 49 | TestTrue(TEXT("SUE4Lua.IsSet()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject)); 50 | } 51 | 52 | return true; 53 | } 54 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestTextFormatter.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseTextFormatter 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseTextFormatter, "Silvervine.UE4Lua.TextFormatter", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseTextFormatter::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | { 22 | VM->ExecuteString( 23 | TEXT("\n function Test()") 24 | TEXT("\n return UE4.TextFormatter.Format() == ''") 25 | TEXT("\n end")); 26 | TestTrue(TEXT("TextFormatter.Format() with no argument"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 27 | } 28 | { 29 | VM->ExecuteString( 30 | TEXT("\n function Test()") 31 | TEXT("\n return UE4.TextFormatter.Format('123') == '123'") 32 | TEXT("\n end")); 33 | TestTrue(TEXT("TextFormatter.Format() with one argument"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 34 | } 35 | { 36 | VM->ExecuteString( 37 | TEXT("\n function Test()") 38 | TEXT("\n return UE4.TextFormatter.Format('{0} {1}', 123, 'str') == '123 str'") 39 | TEXT("\n end")); 40 | TestTrue(TEXT("TextFormatter.Format() with many arguments"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 41 | } 42 | { 43 | VM->ExecuteString( 44 | TEXT("\n function Test()") 45 | TEXT("\n return UE4.TextFormatter.Format('{Arg1} {Arg2}', {Arg1 = 123, Arg2 = 'str'}) == '123 str'") 46 | TEXT("\n end")); 47 | TestTrue(TEXT("TextFormatter.Format() with NamedArg"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 48 | } 49 | 50 | return true; 51 | } -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestUE4.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "Kismet/KismetSystemLibrary.h" 7 | 8 | #include "LuaVirtualMachine.h" 9 | 10 | 11 | //============================================================================================================================= 12 | // FSUE4LuaTestCaseUE4 13 | //============================================================================================================================= 14 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseUE4, "Silvervine.UE4Lua.UE4", SUE4LUA_ATF_UNITTEST) 15 | bool FSUE4LuaTestCaseUE4::RunTest(const FString& Parameters) 16 | { 17 | auto VM = FSUE4LuaVirtualMachine::Create(); 18 | if (!VM.IsValid()) 19 | { 20 | return false; 21 | } 22 | 23 | auto TestUObject = NewObject(); 24 | 25 | { 26 | VM->ExecuteString( 27 | TEXT("\n function Test(uobj)") 28 | TEXT("\n return UE4.IsValid(uobj)") 29 | TEXT("\n end")); 30 | TestTrue(TEXT("UE4.IsValid() == true"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), TestUObject)); 31 | } 32 | { 33 | VM->ExecuteString( 34 | TEXT("\n function Test()") 35 | TEXT("\n return UE4.IsValid(nil)") 36 | TEXT("\n end")); 37 | TestTrue(TEXT("UE4.IsValid() == false"), !FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 38 | } 39 | { 40 | 41 | VM->ExecuteString( 42 | TEXT("\n function Test()") 43 | TEXT("\n return UE4.FindClass('SUE4LuaTestUObject') ~= nil") 44 | TEXT("\n end")); 45 | TestTrue(TEXT("UE.FindClass()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"))); 46 | } 47 | { 48 | VM->ExecuteString( 49 | TEXT("\n local UKismetSystemLibrary = UE4.FindClass('KismetSystemLibrary')") 50 | TEXT("\n function Test(uobj) return UKismetSystemLibrary.GetObjectName(uobj) end")); 51 | 52 | auto Arg = NewObject(); 53 | TestTrue(TEXT("UKismetSystemLibrary.GetObjectName()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), Arg) == UKismetSystemLibrary::GetObjectName(Arg)); 54 | } 55 | 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestUEnum.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseEnum 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseEnum, "Silvervine.UE4Lua.Enum", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseEnum::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | if (!VM.IsValid()) 17 | { 18 | return false; 19 | } 20 | 21 | VM->ExecuteString( 22 | TEXT("\n ESUE4LuaTestEnum = SUE4Lua.GetEnumTable('ESUE4LuaTestEnum')")); 23 | 24 | { 25 | VM->ExecuteString( 26 | TEXT("\n function Test()") 27 | TEXT("\n return ESUE4LuaTestEnum.Enum2") 28 | TEXT("\n end")); 29 | TestTrue(TEXT("SUE4Lua.GetEnumTable()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test")) == ESUE4LuaTestEnum::Enum2); 30 | } 31 | { 32 | VM->ExecuteString( 33 | TEXT("\n function Test(arg)") 34 | TEXT("\n return ESUE4LuaTestEnum:ToString(arg)") 35 | TEXT("\n end")); 36 | TestTrue(TEXT("SUE4Lua.Enum.ToString()"), FSUE4LuaFunction::CallGlobal(VM.ToSharedRef(), TEXT("Test"), ESUE4LuaTestEnum::Enum2) == FString("Enum2")); 37 | } 38 | 39 | return true; 40 | } 41 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestUnknownUObjectType.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTestUnknownUObjectType.h" -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestUnknownUObjectType.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | 8 | #include "LuaUnitTestUnknownUObjectType.generated.h" 9 | 10 | // 11 | // This class is used for unit test. 12 | // 13 | UCLASS() 14 | class USUE4LuaTestUnknownUObjectType : public UObject 15 | { 16 | GENERATED_BODY() 17 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Tests/LuaUnitTestVM.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "LuaUnitTests.h" 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | 9 | //============================================================================================================================= 10 | // FSUE4LuaTestCaseVM 11 | //============================================================================================================================= 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSUE4LuaTestCaseVM, "Silvervine.UE4Lua.VM", SUE4LUA_ATF_UNITTEST) 13 | bool FSUE4LuaTestCaseVM::RunTest(const FString& Parameters) 14 | { 15 | auto VM = FSUE4LuaVirtualMachine::Create(); 16 | 17 | TestTrue(TEXT("VM.Create()"), VM.IsValid()); 18 | 19 | return true; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaActorBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "GameFramework/Actor.h" 7 | 8 | #include "LuaBindingRegistry.h" 9 | 10 | #include "LuaActorBinding.generated.h" 11 | 12 | 13 | // 14 | // AActor에 대한 lua 바인딩 15 | // 16 | UCLASS(NotBlueprintType) 17 | class SILVERVINEUE4LUA_API USUE4LuaActorBinding : public USUE4LuaBinding 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | // Begin USUE4LuaBinding Interface 23 | virtual UClass* GetBindingClass() const override; 24 | // End USUE4LuaBinding Interface 25 | 26 | UFUNCTION() 27 | static FString LuaStaticGetDebugName(const AActor* Actor); 28 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaActorComponentBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Components/ActorComponent.h" 7 | 8 | #include "LuaBindingRegistry.h" 9 | 10 | #include "LuaActorComponentBinding.generated.h" 11 | 12 | 13 | // 14 | // UActorComponent에 대한 lua 바인딩 15 | // 16 | UCLASS(NotBlueprintType) 17 | class SILVERVINEUE4LUA_API USUE4LuaActorComponentBinding : public USUE4LuaBinding 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | // Begin USUE4LuaBinding Interface 23 | virtual UClass* GetBindingClass() const override; 24 | // End USUE4LuaBinding Interface 25 | 26 | UFUNCTION() 27 | static void LuaRegisterComponent(UActorComponent* InSelf); 28 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaClassBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaBindingRegistry.h" 7 | 8 | #include "LuaClassBinding.generated.h" 9 | 10 | 11 | // 12 | // UClass에 대한 lua 바인딩 13 | // 14 | UCLASS(NotBlueprintType) 15 | class SILVERVINEUE4LUA_API USUE4LuaClassBinding : public USUE4LuaBinding 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | // Begin USUE4LuaBinding Interface 21 | virtual UClass* GetBindingClass() const override; 22 | // End USUE4LuaBinding Interface 23 | 24 | UFUNCTION() 25 | static UObject* LuaGetDefaultObject(UClass* InSelf); 26 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaObjectBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaBindingRegistry.h" 7 | 8 | #include "LuaObjectBinding.generated.h" 9 | 10 | 11 | // 12 | // UObject에 대한 lua 바인딩 13 | // 14 | UCLASS(NotBlueprintType) 15 | class SILVERVINEUE4LUA_API USUE4LuaObjectBinding : public USUE4LuaBinding 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | // Begin USUE4LuaBinding Interface 21 | virtual UClass* GetBindingClass() const override; 22 | // End USUE4LuaBinding Interface 23 | 24 | UFUNCTION() 25 | static FString LuaGetName(UObject* InSelf); 26 | 27 | UFUNCTION() 28 | static UClass* LuaGetClass(UObject* InSelf); 29 | 30 | UFUNCTION() 31 | static bool LuaIsA(UObject* InSelf, FName ClassName); 32 | 33 | UFUNCTION() 34 | static class UWorld* LuaGetWorld(UObject* InSelf); 35 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaSceneComponentBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Components/SceneComponent.h" 7 | 8 | #include "LuaBindingRegistry.h" 9 | 10 | #include "LuaSceneComponentBinding.generated.h" 11 | 12 | 13 | // 14 | // USceneObject에 대한 lua 바인딩 15 | // 16 | UCLASS(NotBlueprintType) 17 | class SILVERVINEUE4LUA_API USUE4LuaSceneComponentBinding : public USUE4LuaBinding 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | // Begin USUE4LuaBinding Interface 23 | virtual UClass* GetBindingClass() const override; 24 | // End USUE4LuaBinding Interface 25 | 26 | UFUNCTION() 27 | static void LuaSetupAttachment(USceneComponent* InSelf, USceneComponent* InParent, FName InSocketName = NAME_None); 28 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaStructBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaBindingRegistry.h" 7 | 8 | #include "LuaStructBinding.generated.h" 9 | 10 | 11 | // 12 | // UStruct에 대한 lua 바인딩 13 | // 14 | UCLASS(NotBlueprintType) 15 | class SILVERVINEUE4LUA_API USUE4LuaStructBinding : public USUE4LuaBinding 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | // Begin USUE4LuaBinding Interface 21 | virtual UClass* GetBindingClass() const override; 22 | // End USUE4LuaBinding Interface 23 | 24 | UFUNCTION() 25 | static UStruct* LuaGetSuperStruct(UStruct* InSelf); 26 | 27 | UFUNCTION() 28 | static TArray LuaGetFieldNames(UStruct* InSelf); 29 | 30 | UFUNCTION() 31 | static TArray LuaGetPropertyNames(UStruct* InSelf); 32 | 33 | UFUNCTION() 34 | static TArray LuaGetFunctionNames(UStruct* InSelf); 35 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/Bindings/LuaUserWidgetBinding.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Blueprint/UserWidget.h" 7 | 8 | #include "LuaBindingRegistry.h" 9 | 10 | #include "LuaUserWidgetBinding.generated.h" 11 | 12 | 13 | // 14 | // UUserWidget에 대한 lua 바인딩 15 | // 16 | UCLASS(NotBlueprintType) 17 | class SILVERVINEUE4LUA_API USUE4LuaUserWidgetBinding : public USUE4LuaBinding 18 | { 19 | GENERATED_BODY() 20 | 21 | public: 22 | // Begin USUE4LuaBinding Interface 23 | virtual UClass* GetBindingClass() const override; 24 | // End USUE4LuaBinding Interface 25 | 26 | UFUNCTION() 27 | static UWidget* LuaGetWidgetFromName(UUserWidget* InSelf, const FName& Name); 28 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/LuaBundleFileLoader.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaFileLoader.h" 7 | 8 | 9 | class FSUE4LuaBundleArchive; 10 | 11 | // 12 | // zip 압축 파일에서 lua 파일을 읽는 로더 클래스 13 | // 14 | class SILVERVINEUE4LUA_API FSUE4LuaBundleFileLoader : public FSUE4LuaFileLoader 15 | { 16 | public: 17 | FSUE4LuaBundleFileLoader(); 18 | ~FSUE4LuaBundleFileLoader(); 19 | 20 | virtual bool LoadFileToString(FString& Result, const TCHAR* Filename) override; 21 | virtual FString GetLocalFilePath(const TCHAR* Filename) override; 22 | virtual TArray GetFilenames(const TCHAR* Path) override; 23 | 24 | public: 25 | // 로그 출력을 비활성화 26 | void SuppressLogs(); 27 | 28 | // 가상 경로를 실제 경로의 번들에 연결 29 | bool Map(const TCHAR* VirtualPath, const TCHAR* Path); 30 | 31 | private: 32 | TMap> PathMappings; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/LuaFileLoader.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | 8 | // 9 | // 실행 환경마다 lua 파일이 있는 위치가 다를 수 있기 때문에, 모든 lua 코드는 이 클래스의 자식 인스턴스로부터 로드됩니다. 10 | // 11 | // 사용자가 로더 종류에 상관없이 lua 파일을 로드할 수 있도록 다음과 같은 규칙으로 경로를 지정: 12 | // 13 | // * SUE4Lua 플러그인이 사용하는 파일은 '/SUE4Lua'로 시작. 예) '/SUE4Lua/Framework/Core.lua' 14 | // * 게임 모듈이 사용하는 파일은 '/Game'으로 시작. 예) '/Game/Scenario/Volume01.lua' 15 | // 16 | // 각각의 가상 경로를 실제 파일 경로로 변환하는 역할은 파생 클래스가 처리합니다. 17 | // 18 | class SILVERVINEUE4LUA_API FSUE4LuaFileLoader : public TSharedFromThis 19 | { 20 | public: 21 | FSUE4LuaFileLoader(); 22 | virtual ~FSUE4LuaFileLoader(); 23 | 24 | // 주어진 가상 경로에 대한 lua 소스 스트링을 반환 25 | virtual bool LoadFileToString(FString& Result, const TCHAR* Filename) = 0; 26 | // 주어진 가상 경로에 대한 실제 파일 경로를 반환 27 | virtual FString GetLocalFilePath(const TCHAR* Filename) = 0; 28 | // 주어진 가상 경로 및 모든 하위 경로에 존재하는 파일들의 가상 경로 목록을 반환 29 | virtual TArray GetFilenames(const TCHAR* Path) = 0; 30 | 31 | public: 32 | // 경로 문자 33 | static const TCHAR PathSeperator = TCHAR('/'); 34 | 35 | // 깨끗한 경로 형식으로 바꾼다. 36 | // - 좌우 공백문자 제거 37 | // - 좌우 경로문자 각각 최대 1개 제거 38 | static FString MakeCleanPath(const TCHAR* Path); 39 | }; 40 | 41 | // 42 | // lua 파일 로더를 쉽게 사용하기 위한 헬퍼 클래스 43 | // 44 | struct SILVERVINEUE4LUA_API FSUE4LuaFileLoaderHelper 45 | { 46 | static bool LoadFileToString(FString& Result, const TCHAR* Filename); 47 | static FString GetLocalFilePath(const TCHAR* Filename); 48 | static TArray GetFilenames(const TCHAR* Path); 49 | }; 50 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/LuaLocalFileLoader.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaFileLoader.h" 7 | 8 | 9 | // 10 | // 로컬 경로에서 lua 파일을 읽는 로더 클래스 11 | // 12 | class SILVERVINEUE4LUA_API FSUE4LuaLocalFileLoader : public FSUE4LuaFileLoader 13 | { 14 | public: 15 | FSUE4LuaLocalFileLoader(bool bInUsedForUnitTest = false); 16 | virtual ~FSUE4LuaLocalFileLoader(); 17 | 18 | virtual bool LoadFileToString(FString& Result, const TCHAR* Filename) override; 19 | virtual FString GetLocalFilePath(const TCHAR* Filename) override; 20 | virtual TArray GetFilenames(const TCHAR* Path) override; 21 | 22 | bool MakeVirtualPath(FString& LocalPath) const; 23 | 24 | public: 25 | // 가상 경로를 실제 경로에 연결 26 | bool Map(const TCHAR* VirtualPath, const TCHAR* LocalPath); 27 | 28 | private: 29 | void OnFileChanged(const TArray& FileChanges); 30 | 31 | private: 32 | TMap PathMappings; 33 | bool bUsedForUnitTest = false; 34 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/LuaThread.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | 8 | 9 | class FSUE4LuaVirtualMachine; 10 | class FSUE4LuaFunction; 11 | struct lua_State; 12 | 13 | // 14 | // lua state에 해당하는 클래스 15 | // 16 | // VM에 대한 참조를 보관하고 싶다면 대신 이 클래스의 참조를 보관한 후에 PinVM()을 호출하세요. 17 | // 18 | class SILVERVINEUE4LUA_API FSUE4LuaThread : public TSharedFromThis, public FNoncopyable 19 | { 20 | public: 21 | ~FSUE4LuaThread(); 22 | 23 | static TSharedPtr Create(TSharedRef VM, lua_State* LuaState); 24 | 25 | // 디스포즈된 상태면 true 26 | bool IsDisposed() const { return LuaState == nullptr; } 27 | 28 | // VM에 대한 강참조를 가져옵니다. 29 | // VM이 파괴되었거나 디스포즈 상태면 null이 반환됩니다. 30 | TSharedPtr PinVM() const; 31 | 32 | public: 33 | // 34 | // 아래는 내부 구현에만 사용됩니다. 35 | // 36 | 37 | // VM이 디스포즈될 때 호출됩니다. 38 | void SetDisposed(); 39 | 40 | private: 41 | FSUE4LuaThread(TSharedRef VM, lua_State* LuaState); 42 | 43 | private: 44 | TWeakPtr WeakVM; 45 | lua_State* LuaState = nullptr; 46 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/LuaValueReferencer.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaThread.h" 7 | 8 | 9 | // 10 | // lua 값을 c++에 저장하고 싶을 때 사용합니다. 내부 구현에만 사용됩니다. 11 | // 12 | class FSUE4LuaValueReferencer : public FNoncopyable 13 | { 14 | public: 15 | FSUE4LuaValueReferencer(lua_State* L, int32 StackIndex); 16 | ~FSUE4LuaValueReferencer(); 17 | 18 | TSharedPtr PinVM() const; 19 | void Push(lua_State* L); 20 | 21 | private: 22 | TSharedPtr LuaMainThread; 23 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/SilvervineUE4Lua.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Modules/ModuleInterface.h" 7 | 8 | #include "LuaFileLoader.h" 9 | 10 | // 11 | // SUE4Lua 모듈 정의 12 | // 13 | class SILVERVINEUE4LUA_API FSilvervineUE4LuaModule : public IModuleInterface 14 | { 15 | /** IModuleInterface implementation */ 16 | virtual void StartupModule() override; 17 | virtual void ShutdownModule() override; 18 | 19 | public: 20 | static FSilvervineUE4LuaModule& Get(); 21 | 22 | DECLARE_MULTICAST_DELEGATE_OneParam(FFileModifiedDelegate, const FString& /*Filename*/); 23 | 24 | public: 25 | // 설정되어 있는 파일 로더를 반환. 26 | // 기본값은 내부에서 생성한 null 로더 인스턴스. 이 로더는 아무 동작도 하지 않고 경고 메시지만 출력합니다. 27 | FSUE4LuaFileLoader& GetFileLoader() const; 28 | 29 | // 파일 로더를 설정합니다. 30 | // null 객체를 전달하면 기본값(null 로더 인스턴스)으로 설정된다. 31 | // 반환값은 이전에 설정된 파일 로더. 32 | TSharedPtr SetFileLoader(TSharedPtr NewFileLoader); 33 | 34 | // 파일이 수정되었을 때 발생하는 이벤트 35 | FFileModifiedDelegate FileModifiedDelegate; 36 | 37 | private: 38 | // 현재 설정된 파일 로더 39 | TSharedPtr FileLoader; 40 | }; 41 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/SilvervineUE4LuaSettings.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Engine/DeveloperSettings.h" 7 | 8 | #include "SilvervineUE4LuaSettings.generated.h" 9 | 10 | 11 | // 12 | // SUE4Lua 설정 파일 클래스 13 | // 14 | UCLASS(config = SilvervineUE4Lua) 15 | class SILVERVINEUE4LUA_API USUE4LuaSettings : public UDeveloperSettings 16 | { 17 | GENERATED_BODY() 18 | 19 | public: 20 | static const USUE4LuaSettings* Get(); 21 | 22 | // 번들 파일 로더를 사용 23 | UPROPERTY(config, EditAnywhere, Category = FileLoader) 24 | bool bUseBundleFileLoader = false; 25 | 26 | // 번들 파일 로더의 가상 경로 매핑 27 | UPROPERTY(config, EditAnywhere, Category = FileLoader, meta = (EditCondition = "bUseBundleFileLoader")) 28 | TMap BundleFileLoadMap; 29 | 30 | // 로컬 파일 로더의 가상 경로 매핑 31 | UPROPERTY(config, EditAnywhere, Category = FileLoader, meta = (EditCondition = "!bUseBundleFileLoader")) 32 | TMap LocalFileLoadMap; 33 | 34 | // 스태틱 바인딩을 사용 35 | UPROPERTY(config, EditAnywhere, Category = Binding) 36 | bool bEnableStaticBinding = true; 37 | 38 | void SetFileLoader() const; 39 | 40 | public: 41 | // Begin UDeveloperSettings Interface 42 | virtual FName GetCategoryName() const override; 43 | #if WITH_EDITOR 44 | virtual FText GetSectionText() const override; 45 | virtual FText GetSectionDescription() const override; 46 | // End UDeveloperSettings Interface 47 | private: 48 | // Begin UObject Interface 49 | virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; 50 | // End UObject Interface 51 | #endif // WITH_EDITOR 52 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Public/SilvervineUE4LuaVirtualMachine.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaVirtualMachine.h" 7 | 8 | #include "SilvervineUE4LuaVirtualMachine.generated.h" 9 | 10 | 11 | class UGameInstance; 12 | 13 | USTRUCT() 14 | struct FSUE4LuaVMInstance 15 | { 16 | GENERATED_BODY() 17 | 18 | TSharedPtr VM; 19 | 20 | UPROPERTY() 21 | UGameInstance* GameInstance = nullptr; 22 | }; 23 | 24 | // 25 | // luaVM을 UObject로 관리하기 위해서 작성된 클래스 입니다. 26 | // 27 | UCLASS(Blueprintable) 28 | class SILVERVINEUE4LUA_API USUE4LuaVirtualMachine : public UObject 29 | { 30 | GENERATED_BODY() 31 | 32 | public: 33 | // lua VM을 생성할 때마다 이 경로의 파일을 자동으로 실행합니다. 34 | UPROPERTY(BlueprintReadWrite, EditAnywhere) 35 | FString StartupFilePath; 36 | 37 | // 게임 인스턴스를 등록하고 luaVM을 생성합니다. 38 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "RegisterGameInstance")) 39 | bool BlueprintRegisterGameInstance(UGameInstance* GameInstance); 40 | TSharedPtr RegisterGameInstance(UGameInstance* GameInstance); 41 | 42 | // 게임 인스턴스 등록을 해제하고 luaVM을 제거합니다. 43 | UFUNCTION(BlueprintCallable, meta = (DisplayName = "UnregisterGameInstance")) 44 | bool BlueprintUnregisterGameInstance(UGameInstance* GameInstance); 45 | bool UnregisterGameInstance(UGameInstance* GameInstance); 46 | 47 | // 등록된 게임 인스턴스에 대한 luaVM을 반환합니다. 48 | FSUE4LuaVirtualMachine* FindVMFromGameInstance(UGameInstance* GameInstance); 49 | FSUE4LuaVirtualMachine* FindVMFromWorldContext(UObject* WorldContext); 50 | 51 | protected: 52 | FSUE4LuaVMInstance* FindVMInstanceFromGameInstance(UGameInstance* GameInstance); 53 | FSUE4LuaVMInstance* FindVMInstanceFromWorldContext(UObject* WorldContext); 54 | 55 | protected: 56 | // 등록된 게임 인스턴스 VM 57 | UPROPERTY(Transient) 58 | TArray GameVMInstances; 59 | 60 | private: 61 | FSUE4LuaVMInstance* GetEditorVMInstance(); 62 | void OnPreExit(); 63 | 64 | private: 65 | // 에디터 VM 인스턴스 66 | UPROPERTY(Transient) 67 | FSUE4LuaVMInstance EditorVMInstance; 68 | }; 69 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/SilvervineUE4Lua.Build.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnrealBuildTool; 3 | 4 | namespace UnrealBuildTool.Rules 5 | { 6 | public class SilvervineUE4Lua : ModuleRules 7 | { 8 | public SilvervineUE4Lua(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | PrivatePCHHeaderFile = "SilvervineUE4LuaPCH.h"; 12 | 13 | PublicIncludePaths.AddRange(new string[] 14 | { 15 | }); 16 | 17 | PrivateIncludePaths.AddRange(new string[] 18 | { 19 | "SilvervineUE4Lua/Public", 20 | "SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src", 21 | }); 22 | 23 | PublicDependencyModuleNames.AddRange(new string[] 24 | { 25 | "Core", 26 | "CoreUObject", 27 | "Engine", 28 | }); 29 | 30 | PrivateDependencyModuleNames.AddRange(new string[] 31 | { 32 | "InputCore", 33 | "SlateCore", 34 | "Slate", 35 | "UMG", 36 | "GameplayTags", // For StaticBinding 37 | "MovieScene", // For StaticBinding 38 | }); 39 | 40 | if (Target.bBuildEditor) 41 | { 42 | PrivateDependencyModuleNames.Add("DirectoryWatcher"); 43 | } 44 | 45 | // 4.20 build error workaround 46 | PrivateDefinitions.Add("WIN32_LEAN_AND_MEAN"); 47 | PrivateDefinitions.Add("__STDC_WANT_SECURE_LIB__"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/SilvervineUE4LuaPCH.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | 57 | {LUA_SOCKETLIBNAME, luaopen_socket_core}, 58 | 59 | {NULL, NULL} 60 | }; 61 | 62 | 63 | LUALIB_API void luaL_openlibs (lua_State *L) { 64 | const luaL_Reg *lib; 65 | /* "require" functions from 'loadedlibs' and set results to global table */ 66 | for (lib = loadedlibs; lib->func; lib++) { 67 | luaL_requiref(L, lib->name, lib->func, 1); 68 | lua_pop(L, 1); /* remove lib */ 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 45 | TValue *value); 46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 51 | LUAI_FUNC Table *luaH_new (lua_State *L); 52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 53 | unsigned int nhsize); 54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 57 | LUAI_FUNC int luaH_getn (Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | 55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 59 | 60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 62 | TMS event); 63 | LUAI_FUNC void luaT_init (lua_State *L); 64 | 65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 66 | const TValue *p2, TValue *p3, int hasres); 67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 68 | StkId res, TMS event); 69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 70 | StkId res, TMS event); 71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 72 | const TValue *p2, TMS event); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | #define LUA_SOCKETLIBNAME "socket.core" 51 | LUAMOD_API int (luaopen_socket_core)(lua_State *L); 52 | 53 | 54 | /* open all previous libraries */ 55 | LUALIB_API void (luaL_openlibs) (lua_State *L); 56 | 57 | 58 | 59 | #if !defined(lua_assert) 60 | #define lua_assert(x) ((void)0) 61 | #endif 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/5.3.4/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/auxiliar.h: -------------------------------------------------------------------------------- 1 | #ifndef AUXILIAR_H 2 | #define AUXILIAR_H 3 | /*=========================================================================*\ 4 | * Auxiliar routines for class hierarchy manipulation 5 | * LuaSocket toolkit (but completely independent of other LuaSocket modules) 6 | * 7 | * A LuaSocket class is a name associated with Lua metatables. A LuaSocket 8 | * group is a name associated with a class. A class can belong to any number 9 | * of groups. This module provides the functionality to: 10 | * 11 | * - create new classes 12 | * - add classes to groups 13 | * - set the class of objects 14 | * - check if an object belongs to a given class or group 15 | * - get the userdata associated to objects 16 | * - print objects in a pretty way 17 | * 18 | * LuaSocket class names follow the convention {}. Modules 19 | * can define any number of classes and groups. The module tcp.c, for 20 | * example, defines the classes tcp{master}, tcp{client} and tcp{server} and 21 | * the groups tcp{client,server} and tcp{any}. Module functions can then 22 | * perform type-checking on their arguments by either class or group. 23 | * 24 | * LuaSocket metatables define the __index metamethod as being a table. This 25 | * table has one field for each method supported by the class, and a field 26 | * "class" with the class name. 27 | * 28 | * The mapping from class name to the corresponding metatable and the 29 | * reverse mapping are done using lauxlib. 30 | \*=========================================================================*/ 31 | 32 | #include "lua.h" 33 | #include "lauxlib.h" 34 | 35 | int auxiliar_open(lua_State *L); 36 | void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func); 37 | void auxiliar_add2group(lua_State *L, const char *classname, const char *group); 38 | void auxiliar_setclass(lua_State *L, const char *classname, int objidx); 39 | void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx); 40 | void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx); 41 | void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); 42 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); 43 | int auxiliar_checkboolean(lua_State *L, int objidx); 44 | int auxiliar_tostring(lua_State *L); 45 | int auxiliar_typeerror(lua_State *L, int narg, const char *tname); 46 | 47 | #endif /* AUXILIAR_H */ 48 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUF_H 2 | #define BUF_H 3 | /*=========================================================================*\ 4 | * Input/Output interface for Lua programs 5 | * LuaSocket toolkit 6 | * 7 | * Line patterns require buffering. Reading one character at a time involves 8 | * too many system calls and is very slow. This module implements the 9 | * LuaSocket interface for input/output on connected objects, as seen by 10 | * Lua programs. 11 | * 12 | * Input is buffered. Output is *not* buffered because there was no simple 13 | * way of making sure the buffered output data would ever be sent. 14 | * 15 | * The module is built on top of the I/O abstraction defined in io.h and the 16 | * timeout management is done with the timeout.h interface. 17 | \*=========================================================================*/ 18 | #include "lua.h" 19 | 20 | #include "io.h" 21 | #include "timeout.h" 22 | 23 | /* buffer size in bytes */ 24 | #define BUF_SIZE 8192 25 | 26 | /* buffer control structure */ 27 | typedef struct t_buffer_ { 28 | double birthday; /* throttle support info: creation time, */ 29 | size_t sent, received; /* bytes sent, and bytes received */ 30 | p_io io; /* IO driver used for this buffer */ 31 | p_timeout tm; /* timeout management for this buffer */ 32 | size_t first, last; /* index of first and last bytes of stored data */ 33 | char data[BUF_SIZE]; /* storage space for buffer data */ 34 | } t_buffer; 35 | typedef t_buffer *p_buffer; 36 | 37 | int buffer_open(lua_State *L); 38 | void buffer_init(p_buffer buf, p_io io, p_timeout tm); 39 | int buffer_meth_send(lua_State *L, p_buffer buf); 40 | int buffer_meth_receive(lua_State *L, p_buffer buf); 41 | int buffer_meth_getstats(lua_State *L, p_buffer buf); 42 | int buffer_meth_setstats(lua_State *L, p_buffer buf); 43 | int buffer_isempty(p_buffer buf); 44 | 45 | #endif /* BUF_H */ 46 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/except.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPT_H 2 | #define EXCEPT_H 3 | /*=========================================================================*\ 4 | * Exception control 5 | * LuaSocket toolkit (but completely independent from other modules) 6 | * 7 | * This provides support for simple exceptions in Lua. During the 8 | * development of the HTTP/FTP/SMTP support, it became aparent that 9 | * error checking was taking a substantial amount of the coding. These 10 | * function greatly simplify the task of checking errors. 11 | * 12 | * The main idea is that functions should return nil as its first return 13 | * value when it finds an error, and return an error message (or value) 14 | * following nil. In case of success, as long as the first value is not nil, 15 | * the other values don't matter. 16 | * 17 | * The idea is to nest function calls with the "try" function. This function 18 | * checks the first value, and calls "error" on the second if the first is 19 | * nil. Otherwise, it returns all values it received. 20 | * 21 | * The protect function returns a new function that behaves exactly like the 22 | * function it receives, but the new function doesn't throw exceptions: it 23 | * returns nil followed by the error message instead. 24 | * 25 | * With these two function, it's easy to write functions that throw 26 | * exceptions on error, but that don't interrupt the user script. 27 | \*=========================================================================*/ 28 | 29 | #include "lua.h" 30 | 31 | int except_open(lua_State *L); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/inet.h: -------------------------------------------------------------------------------- 1 | #ifndef INET_H 2 | #define INET_H 3 | /*=========================================================================*\ 4 | * Internet domain functions 5 | * LuaSocket toolkit 6 | * 7 | * This module implements the creation and connection of internet domain 8 | * sockets, on top of the socket.h interface, and the interface of with the 9 | * resolver. 10 | * 11 | * The function inet_aton is provided for the platforms where it is not 12 | * available. The module also implements the interface of the internet 13 | * getpeername and getsockname functions as seen by Lua programs. 14 | * 15 | * The Lua functions toip and tohostname are also implemented here. 16 | \*=========================================================================*/ 17 | #include "lua.h" 18 | #include "socket.h" 19 | #include "timeout.h" 20 | 21 | #ifdef _WIN32 22 | #define LUASOCKET_INET_ATON 23 | #endif 24 | 25 | int inet_open(lua_State *L); 26 | 27 | const char *inet_trycreate(p_socket ps, int family, int type); 28 | const char *inet_tryconnect(p_socket ps, int *family, const char *address, 29 | const char *serv, p_timeout tm, struct addrinfo *connecthints); 30 | const char *inet_trybind(p_socket ps, const char *address, const char *serv, 31 | struct addrinfo *bindhints); 32 | const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm); 33 | const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm); 34 | 35 | int inet_meth_getpeername(lua_State *L, p_socket ps, int family); 36 | int inet_meth_getsockname(lua_State *L, p_socket ps, int family); 37 | 38 | int inet_optfamily(lua_State* L, int narg, const char* def); 39 | int inet_optsocktype(lua_State* L, int narg, const char* def); 40 | 41 | #ifdef LUASOCKET_INET_ATON 42 | int inet_aton(const char *cp, struct in_addr *inp); 43 | #endif 44 | 45 | #ifdef LUASOCKET_INET_PTON 46 | const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); 47 | int inet_pton(int af, const char *src, void *dst); 48 | #endif 49 | 50 | #endif /* INET_H */ 51 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/io.c: -------------------------------------------------------------------------------- 1 | /*=========================================================================*\ 2 | * Input/Output abstraction 3 | * LuaSocket toolkit 4 | \*=========================================================================*/ 5 | #include "io.h" 6 | 7 | /*=========================================================================*\ 8 | * Exported functions 9 | \*=========================================================================*/ 10 | /*-------------------------------------------------------------------------*\ 11 | * Initializes C structure 12 | \*-------------------------------------------------------------------------*/ 13 | void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) { 14 | io->send = send; 15 | io->recv = recv; 16 | io->error = error; 17 | io->ctx = ctx; 18 | } 19 | 20 | /*-------------------------------------------------------------------------*\ 21 | * I/O error strings 22 | \*-------------------------------------------------------------------------*/ 23 | const char *io_strerror(int err) { 24 | switch (err) { 25 | case IO_DONE: return NULL; 26 | case IO_CLOSED: return "closed"; 27 | case IO_TIMEOUT: return "timeout"; 28 | default: return "unknown error"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/luasocket.h: -------------------------------------------------------------------------------- 1 | #ifndef LUASOCKET_H 2 | #define LUASOCKET_H 3 | #define LUA_COMPAT_APIINTCASTS 1 4 | /*=========================================================================*\ 5 | * LuaSocket toolkit 6 | * Networking support for the Lua language 7 | * Diego Nehab 8 | * 9/11/1999 9 | \*=========================================================================*/ 10 | #include "lua.h" 11 | 12 | /*-------------------------------------------------------------------------*\ 13 | * Current socket library version 14 | \*-------------------------------------------------------------------------*/ 15 | #define LUASOCKET_VERSION "LuaSocket 3.0-rc1" 16 | #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2013 Diego Nehab" 17 | 18 | /*-------------------------------------------------------------------------*\ 19 | * This macro prefixes all exported API functions 20 | \*-------------------------------------------------------------------------*/ 21 | #ifndef LUASOCKET_API 22 | #define LUASOCKET_API extern 23 | #endif 24 | 25 | /*-------------------------------------------------------------------------*\ 26 | * Initializes the library. 27 | \*-------------------------------------------------------------------------*/ 28 | LUASOCKET_API int luaopen_socket_core(lua_State *L); 29 | 30 | #endif /* LUASOCKET_H */ 31 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/mime.h: -------------------------------------------------------------------------------- 1 | #ifndef MIME_H 2 | #define MIME_H 3 | /*=========================================================================*\ 4 | * Core MIME support 5 | * LuaSocket toolkit 6 | * 7 | * This module provides functions to implement transfer content encodings 8 | * and formatting conforming to RFC 2045. It is used by mime.lua, which 9 | * provide a higher level interface to this functionality. 10 | \*=========================================================================*/ 11 | #include "lua.h" 12 | 13 | /*-------------------------------------------------------------------------*\ 14 | * Current MIME library version 15 | \*-------------------------------------------------------------------------*/ 16 | #define MIME_VERSION "MIME 1.0.3" 17 | #define MIME_COPYRIGHT "Copyright (C) 2004-2013 Diego Nehab" 18 | #define MIME_AUTHORS "Diego Nehab" 19 | 20 | /*-------------------------------------------------------------------------*\ 21 | * This macro prefixes all exported API functions 22 | \*-------------------------------------------------------------------------*/ 23 | #ifndef MIME_API 24 | #define MIME_API extern 25 | #endif 26 | 27 | MIME_API int luaopen_mime_core(lua_State *L); 28 | 29 | #endif /* MIME_H */ 30 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/select.h: -------------------------------------------------------------------------------- 1 | #ifndef SELECT_H 2 | #define SELECT_H 3 | /*=========================================================================*\ 4 | * Select implementation 5 | * LuaSocket toolkit 6 | * 7 | * Each object that can be passed to the select function has to export 8 | * method getfd() which returns the descriptor to be passed to the 9 | * underlying select function. Another method, dirty(), should return 10 | * true if there is data ready for reading (required for buffered input). 11 | \*=========================================================================*/ 12 | 13 | int select_open(lua_State *L); 14 | 15 | #endif /* SELECT_H */ 16 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_H 2 | #define TCP_H 3 | /*=========================================================================*\ 4 | * TCP object 5 | * LuaSocket toolkit 6 | * 7 | * The tcp.h module is basicly a glue that puts together modules buffer.h, 8 | * timeout.h socket.h and inet.h to provide the LuaSocket TCP (AF_INET, 9 | * SOCK_STREAM) support. 10 | * 11 | * Three classes are defined: master, client and server. The master class is 12 | * a newly created tcp object, that has not been bound or connected. Server 13 | * objects are tcp objects bound to some local address. Client objects are 14 | * tcp objects either connected to some address or returned by the accept 15 | * method of a server object. 16 | \*=========================================================================*/ 17 | #include "lua.h" 18 | 19 | #include "buffer.h" 20 | #include "timeout.h" 21 | #include "socket.h" 22 | 23 | typedef struct t_tcp_ { 24 | t_socket sock; 25 | t_io io; 26 | t_buffer buf; 27 | t_timeout tm; 28 | int family; 29 | } t_tcp; 30 | 31 | typedef t_tcp *p_tcp; 32 | 33 | int tcp_open(lua_State *L); 34 | 35 | #endif /* TCP_H */ 36 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/timeout.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEOUT_H 2 | #define TIMEOUT_H 3 | /*=========================================================================*\ 4 | * Timeout management functions 5 | * LuaSocket toolkit 6 | \*=========================================================================*/ 7 | #include "lua.h" 8 | 9 | /* timeout control structure */ 10 | typedef struct t_timeout_ { 11 | double block; /* maximum time for blocking calls */ 12 | double total; /* total number of miliseconds for operation */ 13 | double start; /* time of start of operation */ 14 | } t_timeout; 15 | typedef t_timeout *p_timeout; 16 | 17 | int timeout_open(lua_State *L); 18 | void timeout_init(p_timeout tm, double block, double total); 19 | double timeout_get(p_timeout tm); 20 | double timeout_getretry(p_timeout tm); 21 | p_timeout timeout_markstart(p_timeout tm); 22 | double timeout_getstart(p_timeout tm); 23 | double timeout_gettime(void); 24 | int timeout_meth_settimeout(lua_State *L, p_timeout tm); 25 | 26 | #define timeout_iszero(tm) ((tm)->block == 0.0) 27 | 28 | #endif /* TIMEOUT_H */ 29 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/udp.h: -------------------------------------------------------------------------------- 1 | #ifndef UDP_H 2 | #define UDP_H 3 | /*=========================================================================*\ 4 | * UDP object 5 | * LuaSocket toolkit 6 | * 7 | * The udp.h module provides LuaSocket with support for UDP protocol 8 | * (AF_INET, SOCK_DGRAM). 9 | * 10 | * Two classes are defined: connected and unconnected. UDP objects are 11 | * originally unconnected. They can be "connected" to a given address 12 | * with a call to the setpeername function. The same function can be used to 13 | * break the connection. 14 | \*=========================================================================*/ 15 | #include "lua.h" 16 | 17 | #include "timeout.h" 18 | #include "socket.h" 19 | 20 | /* can't be larger than wsocket.c MAXCHUNK!!! */ 21 | #define UDP_DATAGRAMSIZE 8192 22 | 23 | typedef struct t_udp_ { 24 | t_socket sock; 25 | t_timeout tm; 26 | int family; 27 | } t_udp; 28 | typedef t_udp *p_udp; 29 | 30 | int udp_open(lua_State *L); 31 | 32 | #endif /* UDP_H */ 33 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/ThirdParty/Lua/extension/luasocket/wsocket.h: -------------------------------------------------------------------------------- 1 | #ifndef WSOCKET_H 2 | #define WSOCKET_H 3 | /*=========================================================================*\ 4 | * Socket compatibilization module for Win32 5 | * LuaSocket toolkit 6 | \*=========================================================================*/ 7 | 8 | /*=========================================================================*\ 9 | * WinSock include files 10 | \*=========================================================================*/ 11 | #include 12 | #include 13 | 14 | typedef int socklen_t; 15 | typedef SOCKADDR_STORAGE t_sockaddr_storage; 16 | typedef SOCKET t_socket; 17 | typedef t_socket *p_socket; 18 | 19 | #ifndef IPV6_V6ONLY 20 | #define IPV6_V6ONLY 27 21 | #endif 22 | 23 | #define SOCKET_INVALID (INVALID_SOCKET) 24 | 25 | #ifndef SO_REUSEPORT 26 | #define SO_REUSEPORT SO_REUSEADDR 27 | #endif 28 | 29 | #ifndef AI_NUMERICSERV 30 | #define AI_NUMERICSERV (0) 31 | #endif 32 | 33 | #endif /* WSOCKET_H */ 34 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaCodeGen/Private/LuaDefaultParameterCodeGen.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "LuaCodeGeneratorBase.h" 7 | 8 | 9 | // 10 | // UFUNCTION()의 파라메터 기본값을 lua 파일로 출력합니다. 11 | // 12 | // 생성된 파일 경로: Private/Scripts/Framework/CodeGen/DefaultParameters.g.lua 13 | // 14 | class FSUE4LuaDefaultParameterCodeGen : public FSUE4LuaCodeGeneratorBase 15 | { 16 | public: 17 | FSUE4LuaDefaultParameterCodeGen(const FString& InOutputDirectory); 18 | 19 | public: 20 | // Begin FSUE4LuaCodeGeneratorBase Interface 21 | virtual void ExportClass(const FSUE4LuaCodeGenContext& CodeGenContext) override; 22 | virtual void FinishExport(const FSUE4LuaCodeGenContext& CodeGenContext) override; 23 | // End FSUE4LuaCodeGeneratorBase Interface 24 | 25 | private: 26 | void ExportDefaultParameters(const UClass* Class); 27 | 28 | FString GetLuaDefaultParameter(const UFunction* Function, const UProperty* Param); 29 | 30 | private: 31 | FSUE4LuaCodeBuilder CodeBuilder; 32 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaCodeGen/Private/SilvervineUE4LuaCodeGen.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "Programs/UnrealHeaderTool/Public/IScriptGeneratorPluginInterface.h" 7 | 8 | #include "LuaCodeGeneratorBase.h" 9 | 10 | 11 | // 12 | // IScriptGeneratorPluginInterface를 사용해서 다음의 두 코드를 생성하는 모듈입니다. 13 | // - 스태틱 바인딩을 위한 c++ 코드 14 | // - 함수의 인자 기본값이 저장되어 있는 lua 코드 15 | // 16 | // 자세한 사항은 FSUE4LuaDefaultParameterCodeGen, FSUE4LuaStaticBindingCodeGen 클래스를 참고하세요 17 | // 18 | class FSilvervineUE4LuaCodeGenModule : public IScriptGeneratorPluginInterface 19 | { 20 | public: 21 | // Begin IModuleInterface Interface 22 | virtual void StartupModule() override; 23 | virtual void ShutdownModule() override; 24 | // End IModuleInterface Interface 25 | 26 | // Begin IScriptGeneratorPlugin Interface 27 | virtual FString GetGeneratedCodeModuleName() const override; 28 | virtual bool ShouldExportClassesForModule(const FString& ModuleName, EBuildModuleType::Type ModuleType, const FString& ModuleGeneratedIncludeDirectory) const override; 29 | virtual bool SupportsTarget(const FString& TargetName) const override; 30 | virtual void Initialize(const FString& RootLocalPath, const FString& RootBuildPath, const FString& OutputDirectory, const FString& IncludeBase) override; 31 | virtual void ExportClass(UClass* Class, const FString& SourceHeaderFilename, const FString& GeneratedHeaderFilename, bool bHasChanged) override; 32 | virtual void FinishExport() override; 33 | virtual FString GetGeneratorName() const override; 34 | // End IScriptGeneratorPlugin Interface 35 | 36 | private: 37 | bool LoadConfig(); 38 | 39 | private: 40 | // 코드젠 결과 lua파일이 저장될 루트 경로 41 | FString LuaCodeGenPath; 42 | // 스태틱 바인딩하지 않을 엔진 모듈 목록 43 | TArray ExcludedEngineModules; 44 | // 스태틱 바인딩할 엔진 플러그인 목록 45 | TArray IncludedEnginePlugins; 46 | // 스태틱 바인딩할 게임 플러그인 목록 47 | TArray IncludedGamePlugins; 48 | 49 | FString IncludeBase; 50 | TArray> CodeGenerators; 51 | mutable FSUE4LuaCodeGenContext CodeGenContext; 52 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaCodeGen/SilvervineUE4LuaCodeGen.Build.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devcat-studio/SilvervineUE4Lua/9d5b92865aecae95b4d3c2a1ccae18d7e69b5052/Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaCodeGen/SilvervineUE4LuaCodeGen.Build.cs -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaEditor/Private/LuaVirtualMachineFactory.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once 5 | 6 | #include "CoreMinimal.h" 7 | #include "Factories/Factory.h" 8 | 9 | #include "LuaVirtualMachineFactory.generated.h" 10 | 11 | 12 | // 13 | // USUE4LuaVirtualMachine을 uasset으로 만들어주는 클래스 입니다. 14 | // 15 | UCLASS() 16 | class USUE4LuaVirtualMachineFactory : public UFactory 17 | { 18 | GENERATED_UCLASS_BODY() 19 | 20 | public: 21 | // Begin UFactory Interface 22 | virtual bool ConfigureProperties() override; 23 | virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override; 24 | // End UFactory Interface 25 | 26 | private: 27 | UPROPERTY() 28 | UClass* SelectedClass = nullptr; 29 | }; -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaEditor/Private/SilvervineUE4LuaEditor.cpp: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #include "CoreMinimal.h" 5 | #include "Modules/ModuleInterface.h" 6 | 7 | #include "Modules/ModuleManager.h" 8 | 9 | 10 | #define LOCTEXT_NAMESPACE "SilvervineUE4LuaEditor" 11 | 12 | class FSilvervineUE4LuaEditorModule : public IModuleInterface 13 | { 14 | // Begin IModuleInterface 15 | virtual void StartupModule() override 16 | { 17 | } 18 | 19 | virtual void ShutdownModule() override 20 | { 21 | } 22 | // End IModuleInterface 23 | }; 24 | 25 | IMPLEMENT_MODULE(FSilvervineUE4LuaEditorModule, SilvervineUE4LuaEditor) 26 | 27 | #undef LOCTEXT_NAMESPACE -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaEditor/SilvervineUE4LuaEditor.Build.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnrealBuildTool; 3 | 4 | namespace UnrealBuildTool.Rules 5 | { 6 | public class SilvervineUE4LuaEditor : ModuleRules 7 | { 8 | public SilvervineUE4LuaEditor(ReadOnlyTargetRules Target) : base(Target) 9 | { 10 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 11 | PrivatePCHHeaderFile = "SilvervineUE4LuaEditorPCH.h"; 12 | 13 | PublicIncludePaths.AddRange(new string[] 14 | { 15 | }); 16 | 17 | PrivateIncludePaths.AddRange(new string[] 18 | { 19 | }); 20 | 21 | PublicDependencyModuleNames.AddRange(new string[] 22 | { 23 | "Core", 24 | "CoreUObject", 25 | "Engine", 26 | "InputCore", 27 | "SlateCore", 28 | "UnrealEd", 29 | 30 | "SilvervineUE4Lua", 31 | }); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Plugins/SilvervineUE4Lua/Source/SilvervineUE4LuaEditor/SilvervineUE4LuaEditorPCH.h: -------------------------------------------------------------------------------- 1 | // SilvervineUE4Lua / devCAT studio 2 | // Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | #pragma once -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SilvervineUE4Lua 2 | ================ 3 | 4 | * [README(한국어)](https://github.com/devcat-studio/SilvervineUE4Lua/blob/master/Plugins/SilvervineUE4Lua/Documents/README_ko.md) 5 | * [README(English)](https://github.com/devcat-studio/SilvervineUE4Lua/blob/master/Plugins/SilvervineUE4Lua/Documents/README.md) 6 | 7 | Presentations: 8 | * NDC2019(한국어) : [SilvervineUE4Lua: UE4에서 Lua 사용하기](https://www.slideshare.net/devcatpublications/silvervineue4lua-ue4-lua-ndc2019) 9 | -------------------------------------------------------------------------------- /SUE4LuaSample_21.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.21", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "SUE4LuaSample", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "PhysXVehicles", 16 | "Enabled": true 17 | }, 18 | { 19 | "Name": "RawInput", 20 | "Enabled": true 21 | }, 22 | { 23 | "Name": "SilvervineUE4Lua", 24 | "Enabled": true 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /SUE4LuaSample_22.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.22", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "SUE4LuaSample", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "PhysXVehicles", 16 | "Enabled": true 17 | }, 18 | { 19 | "Name": "RawInput", 20 | "Enabled": true 21 | }, 22 | { 23 | "Name": "SilvervineUE4Lua", 24 | "Enabled": true 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /SUE4LuaSample_23.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.23", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "SUE4LuaSample", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "PhysXVehicles", 16 | "Enabled": true 17 | }, 18 | { 19 | "Name": "RawInput", 20 | "Enabled": true 21 | }, 22 | { 23 | "Name": "SilvervineUE4Lua", 24 | "Enabled": true 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /SUE4LuaSample_24.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.24", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "SUE4LuaSample", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ], 13 | "Plugins": [ 14 | { 15 | "Name": "PhysXVehicles", 16 | "Enabled": true 17 | }, 18 | { 19 | "Name": "RawInput", 20 | "Enabled": true 21 | }, 22 | { 23 | "Name": "SilvervineUE4Lua", 24 | "Enabled": true 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /SilvervineUE4Lua.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "SilvervineUE4Lua", 5 | "path": "Plugins/SilvervineUE4Lua/Source/SilvervineUE4Lua/Private/Scripts" 6 | }, 7 | { 8 | "name": "SUE4LuaSample", 9 | "path": "Source/SUE4LuaSample/Scripts", 10 | }, 11 | { 12 | "name": "Documents", 13 | "path": "Plugins/SilvervineUE4Lua/Documents", 14 | } 15 | ], 16 | "settings": {}, 17 | "launch": { 18 | "version": "0.2.0", 19 | "configurations": [ 20 | { 21 | "name": "lua-wait-for-debuggee", 22 | "type": "lua", 23 | "request": "attach", 24 | "workingDirectory": "${fileDirname}", 25 | "sourceBasePath": "${fileDirname}", 26 | "listenPublicly": false, 27 | "listenPort": 56789, 28 | "encoding": "UTF-8" 29 | } 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /Source/SUE4LuaSample.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class SUE4LuaSampleTarget : TargetRules 7 | { 8 | public SUE4LuaSampleTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | 12 | #if UE_4_24_OR_LATER 13 | DefaultBuildSettings = BuildSettingsVersion.Latest; 14 | #endif 15 | 16 | ExtraModuleNames.AddRange( new string[] { "SUE4LuaSample" } ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/SUE4LuaSample/SUE4LuaSample.Build.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class SUE4LuaSample : ModuleRules 6 | { 7 | public SUE4LuaSample(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | PrivatePCHHeaderFile = "SUE4LuaSample.h"; 11 | 12 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 13 | 14 | PrivateDependencyModuleNames.AddRange(new string[] { }); 15 | 16 | // Uncomment if you are using Slate UI 17 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 18 | 19 | // Uncomment if you are using online features 20 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 21 | 22 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 23 | 24 | PrivateDependencyModuleNames.Add("SilvervineUE4Lua"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/SUE4LuaSample/SUE4LuaSample.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "SUE4LuaSample.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | #include "SilvervineUE4LuaCodeGen_Game.g.inl" 7 | 8 | class FSUE4LuaSampleGameModuleImpl : public FDefaultGameModuleImpl 9 | { 10 | public: 11 | // Begin IModuleInterface 12 | virtual void StartupModule() override 13 | { 14 | SUE4LUA_REGISTER_BINDINGS(); 15 | } 16 | 17 | virtual void ShutdownModule() override 18 | { 19 | } 20 | // End IModuleInterface 21 | }; 22 | 23 | IMPLEMENT_PRIMARY_GAME_MODULE(FSUE4LuaSampleGameModuleImpl, SUE4LuaSample, "SUE4LuaSample"); 24 | 25 | -------------------------------------------------------------------------------- /Source/SUE4LuaSample/SUE4LuaSample.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | 7 | -------------------------------------------------------------------------------- /Source/SUE4LuaSample/Scripts/Main.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | 5 | SUE4Lua.Log("Main.lua was called.") 6 | 7 | SUE4Lua.SetDispatchHandlerFactory(function (CallerClass) 8 | local ClassName = CallerClass:GetName() 9 | 10 | SUE4Lua.Log("DispatchHandlerFactory: ", ClassName) 11 | 12 | local Filenames = { 13 | Sedan_C = "Game/Sedan.lua", 14 | VehicleHUD_C = "Game/VehicleHUD.lua", 15 | } 16 | 17 | return Filenames[ClassName] or "" 18 | end) 19 | 20 | if SUE4Lua.IsDebuggable() then 21 | SUE4Lua.ExecuteFile("SUE4Lua/Debug/dkjson.lua") 22 | 23 | local debuggee = SUE4Lua.LoadFile("SUE4Lua/Debug/vscode-debuggee.lua")() 24 | 25 | local addUE4Var = function(userdata, addVarFunction) 26 | if SUE4Lua.IsFixedArray(userdata) or SUE4Lua.IsArray(userdata) or SUE4Lua.IsMap(userdata) or SUE4Lua.IsSet(userdata) then 27 | for key, value in pairs(userdata) do 28 | addVarFunction(key, value) 29 | end 30 | else 31 | local curType = userdata:getType() 32 | while curType do 33 | addVarFunction('['..curType:GetName()..']', "", true) 34 | for _, name in pairs(curType:GetPropertyNames()) do 35 | addVarFunction(name, userdata[name]) 36 | end 37 | curType = curType:GetSuperStruct() 38 | end 39 | end 40 | end 41 | 42 | if debuggee.start(json, { addUserdataVar = addUE4Var }) then 43 | SUE4Lua.OnDebugPrint = function (Text) 44 | local category = 'log' 45 | if Text:find("%[Log%]") then 46 | category = 'log' -- white 47 | elseif Text:find("%[Warning%]") then 48 | category = 'warning'-- yellow 49 | elseif Text:find("%[Error%]") then 50 | category = 'error'-- red 51 | end 52 | debuggee.print(category, Text) 53 | end 54 | SUE4Lua.OnTick = function (DeltaTime) debuggee.poll() end 55 | end 56 | end 57 | 58 | SUE4Lua.OnFileModifiled = function (Filename) 59 | SUE4Lua.Log("OnFileModified:", Filename) 60 | end 61 | 62 | SUE4Lua.ExecuteFile("SUE4Lua/Tests/AllTests.lua") -------------------------------------------------------------------------------- /Source/SUE4LuaSample/Scripts/VehicleHUD.lua: -------------------------------------------------------------------------------- 1 | -- SilvervineUE4Lua / devCAT studio 2 | -- Copyright 2016 - 2020. Nexon Korea Corporation. All rights reserved. 3 | 4 | 5 | local VehicleHUD = Class() 6 | 7 | function VehicleHUD:ReceiveDrawHUD(Params) 8 | --SUE4Lua.Log("VehicleHUD:ReceiveDrawHUD() was called.") 9 | 10 | local SizeX = Params.SizeX 11 | local SizeY = Params.SizeY 12 | 13 | local OwningPawn = self:GetOwningPawn() 14 | local Sedan = (UE4.IsValid(OwningPawn) and OwningPawn:IsA('Sedan_C')) and OwningPawn or nil 15 | 16 | if Sedan ~= nil and not Sedan.IsInCar then 17 | -- Calculate ratio from 720p 18 | local HUDXRatio, HUDYRatio = 0.0, 0.0 19 | 20 | HUDXRatio = SizeX / 1280.0 21 | HUDYRatio = SizeY / 720.0 22 | 23 | -- Print vehicle speed 24 | self:DrawText({ 25 | Text = Sedan.SpeedDisplayString, 26 | TextColor = UE4.LinearColor.new(1.0, 1.0, 1.0, 1.0), 27 | ScreenX = HUDXRatio * 805, 28 | ScreenY = HUDYRatio * 455, 29 | Font = self.Font, 30 | Scale = HUDYRatio * 1.4, 31 | }) 32 | 33 | -- Print vehicle gear 34 | self:DrawText({ 35 | Text = "Gear:" .. Sedan.GearDisplayString, 36 | TextColor = Sedan.InReverseGear and Sedan.GearDisplayReverseColor or Sedan.GearDisplayColor, 37 | ScreenX = HUDXRatio * 805, 38 | ScreenY = HUDYRatio * 500, 39 | Font = self.Font, 40 | Scale = HUDYRatio * 1.4, 41 | }) 42 | 43 | end 44 | end 45 | 46 | return VehicleHUD -------------------------------------------------------------------------------- /Source/SUE4LuaSampleEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class SUE4LuaSampleEditorTarget : TargetRules 7 | { 8 | public SUE4LuaSampleEditorTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | 12 | #if UE_4_24_OR_LATER 13 | DefaultBuildSettings = BuildSettingsVersion.Latest; 14 | #endif 15 | 16 | ExtraModuleNames.AddRange( new string[] { "SUE4LuaSample" } ); 17 | } 18 | } 19 | --------------------------------------------------------------------------------