diff --git a/Capy64.sln b/Capy64.sln index 5b1d463..77a85cf 100644 --- a/Capy64.sln +++ b/Capy64.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.4.33110.190 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capy64", "Capy64\Capy64.csproj", "{D38FAB55-99A5-4C5B-9BF7-CC76443AC43A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExamplePlugin", "ExamplePlugin\ExamplePlugin.csproj", "{7176CC2D-BB9E-4512-B216-CC49E9F8A89D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {D38FAB55-99A5-4C5B-9BF7-CC76443AC43A}.Debug|Any CPU.Build.0 = Debug|Any CPU {D38FAB55-99A5-4C5B-9BF7-CC76443AC43A}.Release|Any CPU.ActiveCfg = Release|Any CPU {D38FAB55-99A5-4C5B-9BF7-CC76443AC43A}.Release|Any CPU.Build.0 = Release|Any CPU + {7176CC2D-BB9E-4512-B216-CC49E9F8A89D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7176CC2D-BB9E-4512-B216-CC49E9F8A89D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7176CC2D-BB9E-4512-B216-CC49E9F8A89D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7176CC2D-BB9E-4512-B216-CC49E9F8A89D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ExamplePlugin/ExamplePlugin.csproj b/ExamplePlugin/ExamplePlugin.csproj new file mode 100644 index 0000000..350c4a8 --- /dev/null +++ b/ExamplePlugin/ExamplePlugin.csproj @@ -0,0 +1,17 @@ + + + + net7.0 + enable + enable + true + + + + + false + runtime + + + + diff --git a/ExamplePlugin/MyPlugin.cs b/ExamplePlugin/MyPlugin.cs new file mode 100644 index 0000000..05eb4bf --- /dev/null +++ b/ExamplePlugin/MyPlugin.cs @@ -0,0 +1,48 @@ +using Capy64; +using Capy64.API; +using KeraLua; + +namespace ExamplePlugin; + +public class MyPlugin : IPlugin +{ + private static IGame _game; + public MyPlugin(IGame game) + { + _game = game; + } + + + private static LuaRegister[] MyLib = new LuaRegister[] + { + new() + { + name = "hello", + function = L_HelloWorld, + }, + + new(), + }; + public void LuaInit(Lua L) + { + L.RequireF("mylib", OpenLib, false); + } + + private static int OpenLib(IntPtr state) + { + var L = Lua.FromIntPtr(state); + + L.NewLib(MyLib); + + return 1; + } + + private static int L_HelloWorld(IntPtr state) + { + var L = Lua.FromIntPtr(state); + + L.PushString("Hello, World"); + + return 1; + } +} \ No newline at end of file