You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* NLua: support passing `byte[]` and `Memory<byte>` as Lua strings
* Add `read`/`write_bytes_as_string` APIs
* Add tests for `params` string arguments
* Reduce code duplication
* Show as string type in Lua docs
* Rename to `as_binary_string`
* Add mainmemory methods
* Add explanation to wiki text
#pragma warning disable MA0136// [LuaMethodExample] normalizes line endings
73
+
[LuaMethodExample("""
74
+
local data = memory.read_bytes_as_binary_string(0x100, 32, "WRAM")
75
+
local some_s32_le, some_float = string.unpack("<i4f", data)
76
+
for i = 1, #data do
77
+
print(data:byte(i))
78
+
end
79
+
""")]
80
+
[LuaMethod("read_bytes_as_binary_string","Reads {{length}} bytes starting at {{addr}} into a binary string. This string can be read with functions such as {{string.byte}} and {{string.unpack}}. This string can contain any bytes including null bytes, and is not suitable for display as text.")]
[LuaMethod("write_bytes_as_binary_string","Writes bytes from a binary string to {{addr}}. The string can be created with functions such as {{string.pack}}, and can contain any bytes including null bytes. This is not a text encoding function.")]
Copy file name to clipboardExpand all lines: src/BizHawk.Client.Common/lua/LuaDocumentation.cs
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,12 @@ public string ToTASVideosWikiMarkup()
46
46
** Some callbacks will be called with arguments, if the function you register has the right number of parameters. This will be noted in the registration function's docs.
47
47
* table
48
48
** A standard Lua table
49
+
* binary string
50
+
** A regular Lua string containing raw bytes instead of text, used in some memory functions. Can contain any bytes including null bytes.
51
+
** Not encoded as hex or any valid text encoding. Should not be written to the console.
52
+
** Can be read using {{string.byte(some_string, index)}} or {{some_string:byte(index)}}
53
+
** Created as {{""\x00\x01\x02\x03""}} or {{string.char(0x00, 0x01, 0x02, 0x03)}}
54
+
** Can be converted from and to other data types with [https://www.lua.org/manual/5.4/manual.html#pdf-string.pack|string.pack] and [https://www.lua.org/manual/5.4/manual.html#pdf-string.unpack|string.unpack]
#pragma warning disable MA0136// [LuaMethodExample] normalizes line endings
73
+
[LuaMethodExample("""
74
+
local data = mainmemory.read_bytes_as_binary_string(0x100, 32)
75
+
local some_s32_le, some_float = string.unpack("<i4f", data)
76
+
for i = 1, #data do
77
+
print(data:byte(i))
78
+
end
79
+
""")]
80
+
[LuaMethod("read_bytes_as_binary_string","Reads {{length}} bytes starting at {{addr}} into a binary string. This string can be read with functions such as {{string.byte}} and {{string.unpack}}. This string can contain any bytes including null bytes, and is not suitable for display as text.")]
[LuaMethod("write_bytes_as_binary_string","Writes bytes from a binary string to {{addr}}. The string can be created with functions such as {{string.pack}}, and can contain any bytes including null bytes. This is not a text encoding function.")]
0 commit comments