Closed michieal closed 9 months ago
Just a little something something I put together, to help out with the project. Thank you @Trey2k for the work that you do!
Let me know if I missed anything, or if you want any changes.
will work on creating actual DotNet examples, once I figure out how to use the .PushVariant() function to actually accept a C# function
To push a function via PushVariaint it must be a Callable. Not sure what the c# syntax to create a callable is, but Callable.From() may be a good place to look.
Actually Callable.From will only help if using a lamda, this is how you would do it with a normal C# method
public void LuaPrint(string str)
{
GD.Print(str);
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
GD.Print("Hello from C#");
LuaApi lua = new LuaApi();
Callable print = new Callable(this, MethodName.LuaPrint);
lua.PushVariant("cs_print", print);
lua.DoString("cs_print(\"Hello from Lua\")");
}
Actually Callable.From will only help if using a lamda, this is how you would do it with a normal C# method
public void LuaPrint(string str) { GD.Print(str); } // Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print("Hello from C#"); LuaApi lua = new LuaApi(); Callable print = new Callable(this, MethodName.LuaPrint); lua.PushVariant("cs_print", print); lua.DoString("cs_print(\"Hello from Lua\")"); }
I thought that Callable had something to do with it, but I hit a snag and it was late late so I went to bed instead.
This will be perfect! Thank you
Looks good! This info should be duplicated to the wiki at some point too
Sounds good. Not sure where the Wiki source is at, otherwise I would have.
Sounds good. Not sure where the Wiki source is at, otherwise I would have.
Only if you have the time https://github.com/WeaselGames/godot_luaAPI_docs
I find myself with some extra time, and this is a good way to learn what I need to do what I want. I found an issue that is preventing me from testing the example that I wrote based on the Getting Started example, so I might as well work on integrating the additional documentation into the wiki. (I am fairly certain that the example works, just... issues. lol) Aren't growing pains fun?
Anyway, I described it in Issue #164
I've added in basic instructions as to how to set up the .NET / Mono version, along with some notes and a basic (very primitive) example of using the LuaAPI in C#. Also included is how to set up the Export Templates (with pictures). My hope here is that in making this, it will allow even the newest users the ability to get going.
I will work on creating actual DotNet examples, once I figure out how to use the .PushVariant() function to actually accept a C# function., and I know where the Wiki source is located so that I can do a pull request for it.
Added in DotNET and Export markdown files. Updated README.md to have links to said files.