Browse Source

revert README.md

Akeit0 4 months ago
parent
commit
098db5c484
1 changed files with 28 additions and 58 deletions
  1. 28 58
      README.md

+ 28 - 58
README.md

@@ -12,19 +12,13 @@ English | [日本語](README_JA.md)
 
 ## Overview
 
-Lua-CSharp is a library that provides a Lua interpreter implemented in C#. By integrating Lua-CSharp, you can easily
-embed Lua scripts into your .NET applications.
+Lua-CSharp is a library that provides a Lua interpreter implemented in C#. By integrating Lua-CSharp, you can easily embed Lua scripts into your .NET applications.
 
-Lua-CSharp leverages the latest C# features, designed with low allocation and high performance in mind. It is optimized
-to deliver maximum performance when used for interoperation between C# and Lua in C# applications. Below is a benchmark
-comparison with [MoonSharp](https://github.com/moonsharp-devs/moonsharp/) and [NLua](https://github.com/NLua/NLua):
+Lua-CSharp leverages the latest C# features, designed with low allocation and high performance in mind. It is optimized to deliver maximum performance when used for interoperation between C# and Lua in C# applications. Below is a benchmark comparison with [MoonSharp](https://github.com/moonsharp-devs/moonsharp/) and [NLua](https://github.com/NLua/NLua):
 
 ![img](docs/Benchmark.png)
 
-MoonSharp generally provides good speed but incurs significant allocations due to its design. NLua, being a C-binding
-implementation, is fast, but introduces substantial overhead when interacting with the C# layer. Lua-CSharp, fully
-implemented in C#, allows for seamless interaction with C# code without additional overhead. Moreover, it operates
-reliably in AOT environments since it does not rely on IL generation.
+MoonSharp generally provides good speed but incurs significant allocations due to its design. NLua, being a C-binding implementation, is fast, but introduces substantial overhead when interacting with the C# layer. Lua-CSharp, fully implemented in C#, allows for seamless interaction with C# code without additional overhead. Moreover, it operates reliably in AOT environments since it does not rely on IL generation.
 
 ## Features
 
@@ -58,8 +52,7 @@ You can also use Lua-CSharp with Unity. For details, see the [Lua.Unity](#luauni
 
 ## Quick Start
 
-By using the `LuaState` class, you can execute Lua scripts from C#. Below is a sample code that evaluates a simple
-calculation written in Lua.
+By using the `LuaState` class, you can execute Lua scripts from C#. Below is a sample code that evaluates a simple calculation written in Lua.
 
 ```cs
 using Lua;
@@ -79,8 +72,7 @@ Console.WriteLine(results[0]);
 
 ## LuaValue
 
-Values in Lua scripts are represented by the `LuaValue` type. The value of a `LuaValue` can be read using
-`TryRead<T>(out T value)` or `Read<T>()`.
+Values in Lua scripts are represented by the `LuaValue` type. The value of a `LuaValue` can be read using `TryRead<T>(out T value)` or `Read<T>()`.
 
 ```cs
 var results = await state.DoStringAsync("return 1 + 1");
@@ -98,7 +90,7 @@ var isNil = results[0].Type == LuaValueType.Nil;
 Below is a table showing the type mapping between Lua and C#.
 
 | Lua        | C#                |
-|------------|-------------------|
+| ---------- | ----------------- |
 | `nil`      | `LuaValue.Nil`    |
 | `boolean`  | `bool`            |
 | `string`   | `string`          |
@@ -119,8 +111,7 @@ value = new LuaTable() // LuaTable ->  LuaValue
 
 ## LuaTable
 
-Lua tables are represented by the `LuaTable` type. They can be used similarly to `LuaValue[]` or
-`Dictionary<LuaValue, LuaValue>`.
+Lua tables are represented by the `LuaTable` type. They can be used similarly to `LuaValue[]` or `Dictionary<LuaValue, LuaValue>`.
 
 ```cs
 // Create a table in Lua
@@ -140,8 +131,7 @@ Console.WriteLine(table2[1]);
 
 ## Global Environment
 
-You can access Lua's global environment through `state.Environment`. This table allows for easy value exchange between
-Lua and C#.
+You can access Lua's global environment through `state.Environment`. This table allows for easy value exchange between Lua and C#.
 
 ```cs
 // Set a = 10
@@ -155,8 +145,7 @@ Console.WriteLine(results[0]);
 
 ## Standard Libraries
 
-You can use Lua's standard libraries as well. By calling `state.OpenStandardLibraries()`, the standard library tables
-are added to the `LuaState`.
+You can use Lua's standard libraries as well. By calling `state.OpenStandardLibraries()`, the standard library tables are added to the `LuaState`.
 
 ```cs
 using Lua;
@@ -171,17 +160,14 @@ var results = await state.DoStringAsync("return math.pi");
 Console.WriteLine(results[0]); // 3.141592653589793
 ```
 
-For more details on standard libraries, refer to
-the [Lua official manual](https://www.lua.org/manual/5.2/manual.html#6).
+For more details on standard libraries, refer to the [Lua official manual](https://www.lua.org/manual/5.2/manual.html#6).
 
 > [!WARNING]
-> Lua-CSharp does not support all functions of the standard libraries. For details, refer to
-> the [Compatibility](#compatibility) section.
+> Lua-CSharp does not support all functions of the standard libraries. For details, refer to the [Compatibility](#compatibility) section.
 
 ## Functions
 
-Lua functions are represented by the `LuaFunction` type. With `LuaFunction`, you can call Lua functions from C#, or
-define functions in C# that can be called from Lua.
+Lua functions are represented by the `LuaFunction` type. With `LuaFunction`, you can call Lua functions from C#, or define functions in C# that can be called from Lua.
 
 ### Calling Lua Functions from C#
 
@@ -239,13 +225,11 @@ return add(1, 2)
 ```
 
 > [!TIP]  
-> Defining functions with `LuaFunction` can be somewhat verbose. When adding multiple functions, it is recommended to
-> use the Source Generator with the `[LuaObject]` attribute. For more details, see the [LuaObject](#luaobject) section.
+> Defining functions with `LuaFunction` can be somewhat verbose. When adding multiple functions, it is recommended to use the Source Generator with the `[LuaObject]` attribute. For more details, see the [LuaObject](#luaobject) section.
 
 ## Integration with async/await
 
-`LuaFunction` operates asynchronously. Therefore, you can define a function that waits for an operation in Lua, such as
-the example below:
+`LuaFunction` operates asynchronously. Therefore, you can define a function that waits for an operation in Lua, such as the example below:
 
 ```cs
 // Define a function that waits for the given number of seconds using Task.Delay
@@ -273,8 +257,7 @@ wait(1.0) -- wait 1 sec
 print "goodbye!"
 ```
 
-This code can resume the execution of the Lua script after waiting with await, as shown in the following figure. This is
-very useful when writing scripts to be incorporated into games.
+This code can resume the execution of the Lua script after waiting with await, as shown in the following figure. This is very useful when writing scripts to be incorporated into games.
 
 ![img](docs/img1.png)
 
@@ -313,9 +296,7 @@ for (int i = 0; i < 10; i++)
 
 ## LuaObject
 
-By applying the `[LuaObject]` attribute, you can create custom classes that run within Lua. Adding this attribute to a
-class that you wish to use in Lua allows the Source Generator to automatically generate the code required for
-interaction from Lua.
+By applying the `[LuaObject]` attribute, you can create custom classes that run within Lua. Adding this attribute to a class that you wish to use in Lua allows the Source Generator to automatically generate the code required for interaction from Lua.
 
 The following is an example implementation of a wrapper class for `System.Numerics.Vector3` that can be used in Lua:
 
@@ -395,11 +376,9 @@ local v2 = v1:normalized()
 print(v2.x, v2.y, v2.z)
 ```
 
-The types of fields/properties with the `[LuaMember]` attribute, as well as the argument and return types of methods,
-must be either `LuaValue` or convertible to/from `LuaValue`.
+The types of fields/properties with the `[LuaMember]` attribute, as well as the argument and return types of methods, must be either `LuaValue` or convertible to/from `LuaValue`.
 
-Return types such as `void`, `Task/Task<T>`, `ValueTask/ValueTask<T>`, `UniTask/UniTask<T>`, and
-`Awaitable/Awaitable<T>` are also supported.
+Return types such as `void`, `Task/Task<T>`, `ValueTask/ValueTask<T>`, `UniTask/UniTask<T>`, and `Awaitable/Awaitable<T>` are also supported.
 
 If the type is not supported, the Source Generator will output a compile-time error.
 
@@ -457,8 +436,7 @@ print(v1 - v2) -- <-1, -1, -1>
 
 ## Module Loading
 
-In Lua, you can load modules using the `require` function. In regular Lua, modules are managed by searchers within the
-`package.searchers` function list. In Lua-CSharp, this is replaced by the `ILuaModuleLoader` interface.
+In Lua, you can load modules using the `require` function. In regular Lua, modules are managed by searchers within the `package.searchers` function list. In Lua-CSharp, this is replaced by the `ILuaModuleLoader` interface.
 
 ```cs
 public interface ILuaModuleLoader
@@ -468,8 +446,7 @@ public interface ILuaModuleLoader
 }
 ```
 
-You can set the `LuaState.ModuleLoader` to change how modules are loaded. By default, the `FileModuleLoader` is set to
-load modules from Lua files.
+You can set the `LuaState.ModuleLoader` to change how modules are loaded. By default, the `FileModuleLoader` is set to load modules from Lua files.
 
 You can also combine multiple loaders using `CompositeModuleLoader.Create(loader1, loader2, ...)`.
 
@@ -480,13 +457,11 @@ state.ModuleLoader = CompositeModuleLoader.Create(
 );
 ```
 
-Loaded modules are cached in the `package.loaded` table, just like regular Lua. This can be accessed via
-`LuaState.LoadedModules`.
+Loaded modules are cached in the `package.loaded` table, just like regular Lua. This can be accessed via `LuaState.LoadedModules`.
 
 ## Exception Handling
 
-Lua script parsing errors and runtime exceptions throw exceptions that inherit from `LuaException`. You can catch these
-to handle errors during execution.
+Lua script parsing errors and runtime exceptions throw exceptions that inherit from `LuaException`. You can catch these to handle errors during execution.
 
 ```cs
 try
@@ -515,11 +490,9 @@ Lua-CSharp can also be used in Unity (works with both Mono and IL2CPP).
 
 1. Install [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
 
-2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install
-   it.
+2. Open the NuGet window by going to `NuGet > Manage NuGet Packages`, search for the `LuaCSharp` package, and install it.
 
-3. Open the Package Manager window by selecting `Window > Package Manager`, then click on
-   `[+] > Add package from git URL` and enter the following URL:
+3. Open the Package Manager window by selecting `Window > Package Manager`, then click on `[+] > Add package from git URL` and enter the following URL:
 
     ```
     https://github.com/AnnulusGames/Lua-CSharp.git?path=src/Lua.Unity/Assets/Lua.Unity
@@ -560,8 +533,7 @@ Lua-CSharp does not support Lua bytecode (tools like `luac` cannot be used). Onl
 
 ### Character Encoding
 
-The character encoding used in Lua-CSharp is UTF-16. Since standard Lua assumes a single-byte character encoding, string
-behavior differs significantly.
+The character encoding used in Lua-CSharp is UTF-16. Since standard Lua assumes a single-byte character encoding, string behavior differs significantly.
 
 For example, in regular Lua, the following code outputs `15`, but in Lua-CSharp, it outputs `5`.
 
@@ -574,12 +546,10 @@ All string library functions handle strings as UTF-16.
 
 ### Garbage Collection
 
-Since Lua-CSharp is implemented in C#, it relies on .NET's garbage collector. As a result, memory management behavior
-differs from regular Lua.
+Since Lua-CSharp is implemented in C#, it relies on .NET's garbage collector. As a result, memory management behavior differs from regular Lua.
 
-While `collectgarbage()` is available, it simply calls the corresponding .NET garbage collection method and may not
-exhibit the same behavior as C's Lua garbage collector.
+While `collectgarbage()` is available, it simply calls the corresponding .NET garbage collection method and may not exhibit the same behavior as C's Lua garbage collector.
 
 ## License
 
-Lua-CSharp is licensed under the [MIT License](LICENSE).
+Lua-CSharp is licensed under the [MIT License](LICENSE).