Skip to content

Commit b2cbd6e

Browse files
authored
Update README.md
1 parent bd90a9d commit b2cbd6e

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Lua.NET
22
C# .NET Core 6.0 Lua bindings and helper functions
33

4-
Example Usage:
4+
Example Usage Lua5.4.4:
55
```C#
66
namespace LuaNET;
77

@@ -38,3 +38,39 @@ class Project
3838
}
3939
```
4040

41+
Example Usage LuaJIT:
42+
```C#
43+
namespace LuaNET;
44+
45+
using static LuaJIT.Lua;
46+
47+
class Project
48+
{
49+
50+
public static int lfunc(IntPtr L)
51+
{
52+
lua_getglobal(L, "print");
53+
lua_pushstring(L, "lol");
54+
lua_pcall(L, 1, 0, 0);
55+
return 0;
56+
}
57+
58+
public static void Main(String[] args)
59+
{
60+
61+
IntPtr L = luaL_newstate();
62+
if (L == IntPtr.Zero)
63+
{
64+
Console.WriteLine("Unable to create context!");
65+
}
66+
luaL_openlibs(L);
67+
lua_pushcfunction(L, lfunc);
68+
Console.WriteLine(lua_pcall(L, 0, 0, 0));
69+
lua_close(L);
70+
71+
Console.WriteLine("Success");
72+
73+
}
74+
75+
}
76+
```

0 commit comments

Comments
 (0)