mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 02:26:44 +00:00
Added example plugin project
This commit is contained in:
parent
a652992861
commit
79c232a4ac
3 changed files with 71 additions and 0 deletions
|
@ -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
|
||||
|
|
17
ExamplePlugin/ExamplePlugin.csproj
Normal file
17
ExamplePlugin/ExamplePlugin.csproj
Normal file
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Capy64\Capy64.csproj">
|
||||
<Private>false</Private>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
48
ExamplePlugin/MyPlugin.cs
Normal file
48
ExamplePlugin/MyPlugin.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue