This commit is contained in:
Quentin
2023-07-02 00:59:02 +02:00
committed by GitHub
parent 346960b012
commit 4c71be4142
56 changed files with 2804 additions and 24 deletions

View File

@ -0,0 +1,27 @@
# Class: base_text_element
Class representing a gui text element.
## Functions (2)
### `set_text(new_text)`
- **Parameters:**
- `new_text` (string): The new text for that gui text element.
**Exemple Usage:**
```lua
base_text_element:set_text(new_text)
```
### `get_text()`
- **Returns:**
- `string`: Returns the current text for that gui text element.
**Exemple Usage:**
```lua
string = base_text_element:get_text()
```

View File

@ -0,0 +1,6 @@
# Class: button
## Inherit from 1 class: base_text_element
Class representing a gui button.

View File

@ -0,0 +1,29 @@
# Class: checkbox
## Inherit from 1 class: base_text_element
Class representing a gui checkbox.
## Functions (2)
### `is_enabled()`
- **Returns:**
- `boolean`: Is the checkbox checked?
**Exemple Usage:**
```lua
boolean = checkbox:is_enabled()
```
### `set_enabled(enabled)`
- **Parameters:**
- `enabled` (boolean): The desired enabled state of the checkbox.
**Exemple Usage:**
```lua
checkbox:set_enabled(enabled)
```

View File

@ -0,0 +1,29 @@
# Class: input_float
## Inherit from 1 class: base_text_element
Class for representing an input field for editing a float value within the GUI.
## Functions (2)
### `get_value()`
- **Returns:**
- `float`: Get the value currently written inside the input field.
**Exemple Usage:**
```lua
float = input_float:get_value()
```
### `set_value(val)`
- **Parameters:**
- `val` (float): Set the value currently written inside the input field.
**Exemple Usage:**
```lua
input_float:set_value(val)
```

View File

@ -0,0 +1,29 @@
# Class: input_int
## Inherit from 1 class: base_text_element
Class for representing an input field for editing an integer value within the GUI.
## Functions (2)
### `get_value()`
- **Returns:**
- `integer`: Get the value currently written inside the input field.
**Exemple Usage:**
```lua
integer = input_int:get_value()
```
### `set_value(val)`
- **Parameters:**
- `val` (integer): Set the value currently written inside the input field.
**Exemple Usage:**
```lua
input_int:set_value(val)
```

View File

@ -0,0 +1,29 @@
# Class: input_string
## Inherit from 1 class: base_text_element
Class for representing an input field for editing a string value within the GUI.
## Functions (2)
### `get_value()`
- **Returns:**
- `string`: Get the value currently written inside the input field.
**Exemple Usage:**
```lua
string = input_string:get_value()
```
### `set_value(val)`
- **Parameters:**
- `val` (string): Set the value currently written inside the input field.
**Exemple Usage:**
```lua
input_string:set_value(val)
```

View File

@ -0,0 +1,25 @@
# Class: lua_patch
Class representing a in-memory patch.
## Functions (2)
### `apply()`
Apply the modified value.
**Exemple Usage:**
```lua
lua_patch:apply()
```
### `restore()`
Restore the original value.
**Exemple Usage:**
```lua
lua_patch:restore()
```

322
docs/lua/classes/pointer.md Normal file
View File

@ -0,0 +1,322 @@
# Class: pointer
Class representing a 64-bit memory address.
## Constructors (1)
### `new(address)`
Returns a memory instance, with the given address.
- **Parameters:**
- `address` (integer): Address
**Exemple Usage:**
```lua
myInstance = pointer:new(address)
```
## Functions (23)
### `add(offset)`
Adds an offset to the current memory address and returns a new pointer object.
- **Parameters:**
- `offset` (integer): offset
- **Returns:**
- `pointer`: new pointer object.
**Exemple Usage:**
```lua
pointer = pointer:add(offset)
```
### `sub(offset)`
Subs an offset to the current memory address and returns a new pointer object.
- **Parameters:**
- `offset` (integer): offset
- **Returns:**
- `pointer`: new pointer object.
**Exemple Usage:**
```lua
pointer = pointer:sub(offset)
```
### `rip(offset)`
Rips the current memory address and returns a new pointer object.
- **Parameters:**
- `offset` (integer): offset
- **Returns:**
- `pointer`: new pointer object.
**Exemple Usage:**
```lua
pointer = pointer:rip(offset)
```
### `get_byte()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
number = pointer:get_byte()
```
### `get_word()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
number = pointer:get_word()
```
### `get_dword()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
number = pointer:get_dword()
```
### `get_float()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `float`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
float = pointer:get_float()
```
### `get_qword()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `number`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
number = pointer:get_qword()
```
### `set_byte(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Exemple Usage:**
```lua
pointer:set_byte(value)
```
### `set_word(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Exemple Usage:**
```lua
pointer:set_word(value)
```
### `set_dword(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Exemple Usage:**
```lua
pointer:set_dword(value)
```
### `set_float(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (float): new value.
**Exemple Usage:**
```lua
pointer:set_float(value)
```
### `set_qword(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (number): new value.
**Exemple Usage:**
```lua
pointer:set_qword(value)
```
### `get_string()`
Retrieves the value stored at the memory address as the specified type.
- **Returns:**
- `string`: the value stored at the memory address as the specified type.
**Exemple Usage:**
```lua
string = pointer:get_string()
```
### `set_string(value)`
Sets the value at the memory address to the specified value of the given type.
- **Parameters:**
- `value` (string): new value.
**Exemple Usage:**
```lua
pointer:set_string(value)
```
### `patch_byte(value)`
Creates a memory patch for modifying the value at the memory address with the specified value.
The modified value is applied when you call the apply function on the lua_patch object.
The original value is restored when you call the restore function on the lua_patch object.
- **Parameters:**
- `value` (number): new value.
- **Returns:**
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
**Exemple Usage:**
```lua
lua_patch = pointer:patch_byte(value)
```
### `patch_word(value)`
Creates a memory patch for modifying the value at the memory address with the specified value.
The modified value is applied when you call the apply function on the lua_patch object.
The original value is restored when you call the restore function on the lua_patch object.
- **Parameters:**
- `value` (number): new value.
- **Returns:**
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
**Exemple Usage:**
```lua
lua_patch = pointer:patch_word(value)
```
### `patch_dword(value)`
Creates a memory patch for modifying the value at the memory address with the specified value.
The modified value is applied when you call the apply function on the lua_patch object.
The original value is restored when you call the restore function on the lua_patch object.
- **Parameters:**
- `value` (number): new value.
- **Returns:**
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
**Exemple Usage:**
```lua
lua_patch = pointer:patch_dword(value)
```
### `patch_qword(value)`
Creates a memory patch for modifying the value at the memory address with the specified value.
The modified value is applied when you call the apply function on the lua_patch object.
The original value is restored when you call the restore function on the lua_patch object.
- **Parameters:**
- `value` (number): new value.
- **Returns:**
- `lua_patch`: memory patch instance for modifying the value at the memory address with the specified value. Can call apply / restore on the object.
**Exemple Usage:**
```lua
lua_patch = pointer:patch_qword(value)
```
### `is_null()`
- **Returns:**
- `boolean`: Returns true if the address is null.
**Exemple Usage:**
```lua
boolean = pointer:is_null()
```
### `is_valid()`
- **Returns:**
- `boolean`: Returns true if the address is not null.
**Exemple Usage:**
```lua
boolean = pointer:is_valid()
```
### `deref()`
Dereferences the memory address and returns a new pointer object pointing to the value at that address.
- **Returns:**
- `pointer`: A new pointer object pointing to the value at that address.
**Exemple Usage:**
```lua
pointer = pointer:deref()
```
### `get_address()`
Retrieves the memory address stored in the pointer object.
- **Returns:**
- `number`: The memory address stored in the pointer object as a number.
**Exemple Usage:**
```lua
number = pointer:get_address()
```

View File

@ -0,0 +1,4 @@
# Class: sameline
Class for ImGui::SameLine() - Puts a sameline between widgets or groups to layout them horizontally.

View File

@ -0,0 +1,4 @@
# Class: separator
Class for ImGui::Separator() - separator, generally horizontal. Inside a menu bar or in horizontal layout mode, this becomes a vertical separator.

119
docs/lua/classes/tab.md Normal file
View File

@ -0,0 +1,119 @@
# Class: tab
Class for representing a tab within the GUI.
## Functions (8)
### `add_button(name, callback)`
Add a button to the gui tab.
- **Parameters:**
- `name` (string): Text written inside the button.
- `callback` (function): function that will be called when the button is clicked.
**Exemple Usage:**
```lua
tab:add_button(name, callback)
```
### `add_text(name)`
Add text to the gui tab.
- **Parameters:**
- `name` (string): Text that will be written.
- **Returns:**
- `text`: The text object instance.
**Exemple Usage:**
```lua
text = tab:add_text(name)
```
### `add_checkbox(name)`
Add a checkbox widget to the gui tab.
- **Parameters:**
- `name` (string): Text that will be written next to the checkbox.
- **Returns:**
- `checkbox`: The checkbox object instance.
**Exemple Usage:**
```lua
checkbox = tab:add_checkbox(name)
```
### `add_sameline()`
Add a ImGui::SameLine.
- **Returns:**
- `sameline`: The sameline object instance.
**Exemple Usage:**
```lua
sameline = tab:add_sameline()
```
### `add_separator()`
Add a ImGui::Separator.
- **Returns:**
- `separator`: The separator object instance.
**Exemple Usage:**
```lua
separator = tab:add_separator()
```
### `add_input_int(name)`
Add a ImGui::InputInt.
- **Parameters:**
- `name` (string): Text that will be written next to the input field.
- **Returns:**
- `input_int`: The input_int object instance.
**Exemple Usage:**
```lua
input_int = tab:add_input_int(name)
```
### `add_input_float(name)`
Add a ImGui::InputFloat.
- **Parameters:**
- `name` (string): Text that will be written next to the input field.
- **Returns:**
- `input_float`: The input_float object instance.
**Exemple Usage:**
```lua
input_float = tab:add_input_float(name)
```
### `add_input_string(name)`
Add a ImGui::InputText.
- **Parameters:**
- `name` (string): Text that will be written next to the input field.
- **Returns:**
- `input_string`: The input_string object instance.
**Exemple Usage:**
```lua
input_string = tab:add_input_string(name)
```

19
docs/lua/classes/text.md Normal file
View File

@ -0,0 +1,19 @@
# Class: text
## Inherit from 1 class: base_text_element
Class representing an imgui text element.
## Functions (1)
### `set_font(font)`
- **Parameters:**
- `font` (string): The new font name for that imgui text element.
**Exemple Usage:**
```lua
text:set_font(font)
```

40
docs/lua/classes/vec3.md Normal file
View File

@ -0,0 +1,40 @@
# Class: vec3
Class representing a 3D vector.
## Fields (3)
### `x`
x component of the vector.
- Type: `float`
### `y`
y component of the vector.
- Type: `float`
### `z`
z component of the vector.
- Type: `float`
## Constructors (1)
### `new(x, y, z)`
Returns a vector that contains the x, y, and z values.
- **Parameters:**
- `x` (float): x component of the vector.
- `y` (float): y component of the vector.
- `z` (float): z component of the vector.
**Exemple Usage:**
```lua
myInstance = vec3:new(x, y, z)
```

556
docs/lua/doc_gen.py Normal file
View File

@ -0,0 +1,556 @@
import os
from enum import Enum
src_folder = "../../src/"
lua_api_comment_identifier = "lua api"
lua_api_comment_separator = ":"
tables = {}
classes = {}
functions = {}
class DocKind(Enum):
Table = "table"
Class = "class"
Field = "field"
Constructor = "constructor"
Function = "function"
class Table:
def __init__(self, name, fields, functions, description):
self.name = name.strip()
self.fields = fields
self.functions = functions
self.description = description
def __str__(self):
s = f"# Table: {self.name}\n"
s += "\n"
if len(self.description) > 0:
s += f"{self.description}\n"
s += "\n"
if len(self.fields) > 0:
s += f"## Fields ({len(self.fields)})\n"
s += "\n"
self.check_for_duplicate_fields_names()
for field in self.fields:
s += field.print_markdown()
if len(self.functions) > 0:
s += f"## Functions ({len(self.functions)})\n"
s += "\n"
self.check_for_duplicate_function_names()
for func in self.functions:
s += func.print_markdown(f"{self.name}.")
s += "\n"
return s
def check_for_duplicate_fields_names(self):
seen = set()
duplicates = [x for x in self.fields if x.name in seen or seen.add(x.name)]
if len(duplicates) > 0:
print("Error while building lua doc. Duplicate field names:")
for dup in duplicates:
print(dup)
exit(1)
def check_for_duplicate_function_names(self):
seen = set()
duplicates = [x for x in self.functions if x.name in seen or seen.add(x.name)]
if len(duplicates) > 0:
print("Error while building lua doc. Duplicate function names:")
for dup in duplicates:
print(dup)
exit(1)
class Class:
def __init__(self, name, inheritance, fields, constructors, functions, description):
self.name = name.strip()
self.inheritance = inheritance
self.fields = fields
self.constructors = constructors
self.functions = functions
self.description = description
def __str__(self):
s = f"# Class: {self.name}\n"
s += "\n"
if len(self.inheritance) > 0:
inherited_class_names = ", ".join(self.inheritance)
s += f"## Inherit from {len(self.inheritance)} class: {inherited_class_names}\n"
s += "\n"
if len(self.description) > 0:
s += f"{self.description}\n"
s += "\n"
if len(self.fields) > 0:
s += f"## Fields ({len(self.fields)})\n"
s += "\n"
self.check_for_duplicate_fields_names()
for field in self.fields:
s += field.print_markdown()
if len(self.constructors) > 0:
s += f"## Constructors ({len(self.constructors)})\n"
s += "\n"
for ctor in self.constructors:
s += ctor.print_markdown()
if len(self.functions) > 0:
s += f"## Functions ({len(self.functions)})\n"
s += "\n"
self.check_for_duplicate_function_names()
for func in self.functions:
s += func.print_markdown(f"{self.name}:")
s += "\n"
return s
def check_for_duplicate_fields_names(self):
seen = set()
duplicates = [x for x in self.fields if x.name in seen or seen.add(x.name)]
if len(duplicates) > 0:
print("Error while building lua doc. Duplicate field names:")
for dup in duplicates:
print(dup)
exit(1)
def check_for_duplicate_function_names(self):
seen = set()
duplicates = [x for x in self.functions if x.name in seen or seen.add(x.name)]
if len(duplicates) > 0:
print("Error while building lua doc. Duplicate function names:")
for dup in duplicates:
print(dup)
exit(1)
class Field:
def __init__(self, name, type_, description):
self.name = name.strip()
self.type_ = type_.strip()
self.description = description
def __str__(self):
s = f"Field: {self.name}\n"
s += f"Type: {self.type_}\n"
s += f"Description: {self.description.strip()}\n"
return s
def print_markdown(self):
s = ""
s += f"### `{self.name}`\n"
s += "\n"
if len(self.description) > 0:
s += f"{self.description}\n"
s += "\n"
if self.type_ is not None and len(self.type_) > 0:
s += f"- Type: `{self.type_}`\n"
s += "\n"
return s
class Constructor:
def __init__(self, parent, parameters, description):
self.parent = parent
self.parameters = parameters
self.description = description
def print_markdown(self):
s = ""
parameters_str = ", ".join(p.name for p in self.parameters)
s += f"### `new({parameters_str})`\n"
s += "\n"
if len(self.description) > 0:
s += f"{self.description}\n"
s += "\n"
if len(self.parameters) > 0:
s += f"- **Parameters:**\n"
for param in self.parameters:
s += f" - `{param.name}` ({param.type_})"
if len(param.description) > 0:
s += f": {param.description}\n"
else:
s += f"\n"
s += "\n"
s += f"**Exemple Usage:**\n"
s += "```lua\n"
s += f"myInstance = {self.parent.name}:new({parameters_str})\n"
s += "```\n"
s += "\n"
return s
class Parameter:
def __init__(self, name, type_, description):
self.name = name.strip()
self.type_ = type_.strip()
self.description = description
def __str__(self):
s = f"Parameter: {self.name}\n"
s += f"Type: {self.type_}\n"
s += f"Description: {self.description.strip()}\n"
return s
class Function:
def __init__(
self, name, parent, parameters, return_type, return_description, description
):
self.name = name.strip()
self.parent = parent
self.parameters = parameters
self.return_type = return_type
self.return_description = return_description
self.description = description
def __str__(self):
s = f"Function: {self.name}\n"
type_name = str(type(self.parent)).split(".")[1][:-2]
s += f"Parent: {self.parent.name} ({type_name})\n"
s += f"Parameters: {len(self.parameters)}\n"
i = 1
for param in self.parameters:
s += f"Parameter {i}\n"
s += str(param) + "\n"
i += 1
s += f"Return Type: {self.return_type}\n"
s += f"Return Description: {self.return_description}\n"
s += f"Description: {self.description}\n"
return s
def print_markdown(self, prefix):
s = ""
parameters_str = ", ".join(p.name for p in self.parameters)
s += f"### `{self.name}({parameters_str})`\n"
s += "\n"
if len(self.description) > 0:
s += f"{self.description}\n"
s += "\n"
if len(self.parameters) > 0:
s += f"- **Parameters:**\n"
for param in self.parameters:
s += f" - `{param.name}` ({param.type_})"
if len(param.description) > 0:
s += f": {param.description}\n"
else:
s += f"\n"
s += "\n"
if self.return_type is not None and len(self.return_type) > 0:
s += f"- **Returns:**\n"
s += f" - `{self.return_type}`: {self.return_description}\n"
s += "\n"
s += f"**Exemple Usage:**\n"
s += "```lua\n"
if self.return_type is not None and len(self.return_type) > 0:
s += self.return_type + " = "
if "Global Table" in prefix:
prefix = ""
s += f"{prefix}{self.name}({parameters_str})\n"
s += "```\n"
s += "\n"
return s
def make_table(table_name):
if table_name not in tables:
tables[table_name] = Table(table_name, [], [], "")
cur_table = tables[table_name]
return cur_table
def make_class(class_name):
if class_name not in classes:
classes[class_name] = Class(class_name, [], [], [], [], "")
cur_class = classes[class_name]
return cur_class
def is_comment_a_lua_api_doc_comment(text_lower):
return (
lua_api_comment_identifier in text_lower
and lua_api_comment_separator in text_lower
and "//" in text_lower
)
def parse_lua_api_doc(folder_path):
for root, dirs, files in os.walk(folder_path):
for file_name in files:
if os.path.splitext(file_name)[1].startswith((".c", ".h")):
file_path = os.path.join(root, file_name)
with open(file_path, "r") as file:
doc_kind = None
cur_table = None
cur_class = None
cur_function = None
cur_field = None
cur_constructor = None
for line in file:
line = line.strip()
line_lower = line.lower()
if is_comment_a_lua_api_doc_comment(line_lower):
doc_kind = DocKind(
line.split(lua_api_comment_separator, 1)[1]
.strip()
.lower()
)
continue
if doc_kind is not None and "//" in line:
match doc_kind:
case DocKind.Table:
cur_table = parse_table_doc(
cur_table, line, line_lower
)
case DocKind.Class:
cur_class = parse_class_doc(
cur_class, line, line_lower
)
case DocKind.Function:
(
cur_function,
cur_table,
cur_class,
) = parse_function_doc(
cur_function,
cur_table,
cur_class,
line,
line_lower,
)
case DocKind.Field:
(cur_field, cur_table, cur_class) = parse_field_doc(
cur_field,
cur_table,
cur_class,
line,
line_lower,
)
case DocKind.Constructor:
(
cur_constructor,
cur_class,
) = parse_constructor_doc(
cur_constructor,
cur_class,
line,
line_lower,
)
case _:
# print("unsupported doc kind: " + str(doc_kind))
pass
else:
doc_kind = None
def parse_table_doc(cur_table, line, line_lower):
if is_lua_doc_comment_startswith(line_lower, "name"):
table_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_table = make_table(table_name)
else:
if len(cur_table.description) != 0:
cur_table.description += "\n"
cur_table.description += sanitize_description(line)
return cur_table
def parse_class_doc(cur_class, line, line_lower):
if is_lua_doc_comment_startswith(line_lower, "name"):
class_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_class = make_class(class_name)
elif is_lua_doc_comment_startswith(line_lower, "inherit"):
inherited_class_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_class.inheritance.append(inherited_class_name)
else:
if len(cur_class.description) != 0:
cur_class.description += "\n"
cur_class.description += sanitize_description(line)
return cur_class
def parse_function_doc(cur_function, cur_table, cur_class, line, line_lower):
if is_lua_doc_comment_startswith(line_lower, "table") and lua_api_comment_separator in line_lower:
table_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_table = make_table(table_name)
cur_function = Function("Didnt get name yet", cur_table, [], None, "", "")
cur_table.functions.append(cur_function)
elif is_lua_doc_comment_startswith(line_lower, "class") and lua_api_comment_separator in line_lower:
class_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_class = make_class(class_name)
cur_function = Function("Didnt get name yet", cur_class, [], None, "", "")
cur_class.functions.append(cur_function)
elif is_lua_doc_comment_startswith(line_lower, "name") and lua_api_comment_separator in line_lower:
function_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_function.name = function_name
if function_name not in functions:
functions[function_name] = cur_function
elif is_lua_doc_comment_startswith(line_lower, "param") and lua_api_comment_separator in line_lower:
parameter = make_parameter_from_doc_line(line)
cur_function.parameters.append(parameter)
elif is_lua_doc_comment_startswith(line_lower, "return") and lua_api_comment_separator in line_lower:
return_info = line.split(lua_api_comment_separator, 2)
try:
cur_function.return_type = return_info[1].strip()
cur_function.return_description = return_info[2].strip()
except IndexError:
pass
else:
if len(cur_function.description) != 0:
cur_function.description += "\n"
cur_function.description += sanitize_description(line)
return cur_function, cur_table, cur_class
def parse_field_doc(cur_field, cur_table, cur_class, line, line_lower):
if is_lua_doc_comment_startswith(line_lower, "table") and lua_api_comment_separator in line_lower:
table_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_table = make_table(table_name)
cur_field = Field("Didnt get name yet", "", "")
cur_table.fields.append(cur_field)
elif is_lua_doc_comment_startswith(line_lower, "class") and lua_api_comment_separator in line_lower:
class_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_class = make_class(class_name)
cur_field = Field("Didnt get name yet", "", "")
cur_class.fields.append(cur_field)
elif is_lua_doc_comment_startswith(line_lower, "field") and lua_api_comment_separator in line_lower:
field_info = line.split(lua_api_comment_separator, 2)
cur_field.name = field_info[1].strip()
cur_field.type_ = field_info[2].strip()
else:
if len(cur_field.description) != 0:
cur_field.description += "\n"
if line.startswith("// "):
line = line[3:]
cur_field.description += sanitize_description(line)
return cur_field, cur_table, cur_class
def parse_constructor_doc(cur_constructor, cur_class, line, line_lower):
if is_lua_doc_comment_startswith(line_lower, "class") and lua_api_comment_separator in line_lower:
class_name = line.split(lua_api_comment_separator, 1)[1].strip()
cur_class = make_class(class_name)
cur_constructor = Constructor(cur_class, [], "")
cur_class.constructors.append(cur_constructor)
elif is_lua_doc_comment_startswith(line_lower, "param") and lua_api_comment_separator in line_lower:
parameter = make_parameter_from_doc_line(line)
cur_constructor.parameters.append(parameter)
else:
if len(cur_constructor.description) != 0:
cur_constructor.description += "\n"
cur_constructor.description += sanitize_description(line)
return cur_constructor, cur_class
def make_parameter_from_doc_line(line):
param_info = line.split(lua_api_comment_separator, 3)[1:]
param_name = param_type = param_desc = ""
try:
param_name = param_info[0].strip()
param_type = param_info[1].strip()
param_desc = param_info[2].strip()
except IndexError:
pass
return Parameter(param_name, param_type, param_desc)
def sanitize_description(line):
if line.startswith("// ") and line[3] != ' ':
line = line[3:]
if line.startswith("//"):
line = line[2:]
return line.rstrip()
def is_lua_doc_comment_startswith(line_lower, starts_with_text):
return line_lower.replace("//", "").strip().startswith(starts_with_text)
parse_lua_api_doc(src_folder)
try:
os.makedirs("./tables/")
except:
pass
for table_name, table in tables.items():
file_name = f"./tables/{table_name}.md"
if os.path.exists(file_name):
os.remove(file_name)
f = open(file_name, "a")
f.write(str(table))
f.close()
try:
os.makedirs("./classes/")
except:
pass
for class_name, class_ in classes.items():
file_name = f"./classes/{class_name}.md"
if os.path.exists(file_name):
os.remove(file_name)
f = open(file_name, "a")
f.write(str(class_))
f.close()

View File

@ -0,0 +1,20 @@
# Table: Global Table
Custom fields, functions, etc added to The Lua [Global Table](https://www.lua.org/pil/15.4.html).
## Functions (1)
### `joaat(str)`
- **Parameters:**
- `str` (string): The string that needs to be joaat hashed.
- **Returns:**
- `integer`: The joaat hashed input string.
**Exemple Usage:**
```lua
integer = joaat(str)
```

View File

@ -0,0 +1,34 @@
# Table: command
Table for calling menu commands.
## Functions (2)
### `call(command_name, _args)`
Call a menu command.
- **Parameters:**
- `command_name` (string): The name of the command that will be called.
- `_args` (table): Optional. List of arguments for the command.
**Exemple Usage:**
```lua
command.call(command_name, _args)
```
### `call_player(player_idx, command_name, _args)`
Call a menu command on a given player.
- **Parameters:**
- `player_idx` (integer): Index of the player on which the menu command will be executed.
- `command_name` (string): The name of the command that will be called.
- `_args` (table): Optional. List of arguments for the command.
**Exemple Usage:**
```lua
command.call_player(player_idx, command_name, _args)
```

20
docs/lua/tables/event.md Normal file
View File

@ -0,0 +1,20 @@
# Table: event
Table for responding to various events. The list of events is available in the menu_event table.
## Functions (1)
### `register_handler(menu_event, func)`
Register a function that will be called each time the corresponding menu_event is triggered.
- **Parameters:**
- `menu_event` (menu_event): The menu_event that we want to respond to.
- `func` (function): The function that will be called.
**Exemple Usage:**
```lua
event.register_handler(menu_event, func)
```

106
docs/lua/tables/globals.md Normal file
View File

@ -0,0 +1,106 @@
# Table: globals
Table containing functions for manipulating gta script globals.
## Functions (7)
### `get_int(global)`
Retrieves an int global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `integer`: value of the global
**Exemple Usage:**
```lua
integer = globals.get_int(global)
```
### `get_float(global)`
Retrieves a float global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `float`: value of the global
**Exemple Usage:**
```lua
float = globals.get_float(global)
```
### `get_string(global)`
Retrieves a string global value.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `string`: value of the global
**Exemple Usage:**
```lua
string = globals.get_string(global)
```
### `set_int(global, val)`
Sets an int global value.
- **Parameters:**
- `global` (integer): index of the global
- `val` (integer): new value for the global
**Exemple Usage:**
```lua
globals.set_int(global, val)
```
### `set_float(global, val)`
Sets a float global value.
- **Parameters:**
- `global` (integer): index of the global
- `val` (float): new value for the global
**Exemple Usage:**
```lua
globals.set_float(global, val)
```
### `set_string(global, str)`
Sets a string global value.
- **Parameters:**
- `global` (integer): index of the global
- `str` (string): new value for the global
**Exemple Usage:**
```lua
globals.set_string(global, str)
```
### `get_pointer(global)`
Retrieves a pointer global.
- **Parameters:**
- `global` (integer): index of the global
- **Returns:**
- `pointer`: value of the global
**Exemple Usage:**
```lua
pointer = globals.get_pointer(global)
```

69
docs/lua/tables/gui.md Normal file
View File

@ -0,0 +1,69 @@
# Table: gui
Table containing functions for modifying the menu GUI.
## Functions (5)
### `get_tab(tab_name)`
- **Parameters:**
- `tab_name` (string): Name of the tab to get.
- **Returns:**
- `tab`: A tab instance which corresponds to the tab in the GUI.
**Exemple Usage:**
```lua
tab = gui.get_tab(tab_name)
```
### `show_message(title, message)`
Shows a message to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_message(title, message)
```
### `show_warning(title, message)`
Shows a warning to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_warning(title, message)
```
### `show_error(title, message)`
Shows an error to the user with the given title and message.
- **Parameters:**
- `title` (string)
- `message` (string)
**Exemple Usage:**
```lua
gui.show_error(title, message)
```
### `is_open()`
- **Returns:**
- `bool`: Returns true if the GUI is open.
**Exemple Usage:**
```lua
bool = gui.is_open()
```

73
docs/lua/tables/locals.md Normal file
View File

@ -0,0 +1,73 @@
# Table: locals
Table for manipulating GTA scripts locals.
## Functions (5)
### `get_int(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `integer`: The value of the given local.
**Exemple Usage:**
```lua
integer = locals.get_int(script, index)
```
### `get_float(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `float`: The value of the given local.
**Exemple Usage:**
```lua
float = locals.get_float(script, index)
```
### `set_int(script, index, val)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- `val` (integer): The new value of the given local.
**Exemple Usage:**
```lua
locals.set_int(script, index, val)
```
### `set_float(script, index, val)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- `val` (float): The new value of the given local.
**Exemple Usage:**
```lua
locals.set_float(script, index, val)
```
### `get_pointer(script, index)`
- **Parameters:**
- `script` (string): The name of the script
- `index` (index): Index of the script local.
- **Returns:**
- `pointer`: The pointer to the given local.
**Exemple Usage:**
```lua
pointer = locals.get_pointer(script, index)
```

43
docs/lua/tables/log.md Normal file
View File

@ -0,0 +1,43 @@
# Table: log
Table containing functions for printing to console / log file.
## Functions (3)
### `info(data)`
Logs an informational message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.info(data)
```
### `warning(data)`
Logs a warning message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.warning(data)
```
### `debug(data)`
Logs a debug message.
- **Parameters:**
- `data` (string)
**Exemple Usage:**
```lua
log.debug(data)
```

71
docs/lua/tables/memory.md Normal file
View File

@ -0,0 +1,71 @@
# Table: memory
Table containing helper functions related to process memory.
## Functions (5)
### `scan_pattern(pattern)`
Scans the specified memory pattern within the "GTA5.exe" module and returns a pointer to the found address.
- **Parameters:**
- `pattern` (string): byte pattern (IDA format)
- **Returns:**
- `pointer`: A pointer to the found address.
**Exemple Usage:**
```lua
pointer = memory.scan_pattern(pattern)
```
### `handle_to_ptr(entity)`
- **Parameters:**
- `entity` (number): script game entity handle
- **Returns:**
- `pointer`: A rage::CDynamicEntity pointer to the script game entity handle
**Exemple Usage:**
```lua
pointer = memory.handle_to_ptr(entity)
```
### `ptr_to_handle(mem_addr)`
- **Parameters:**
- `mem_addr` (pointer): A rage::CDynamicEntity pointer.
- **Returns:**
- `number`: The script game entity handle linked to the given rage::CDynamicEntity pointer.
**Exemple Usage:**
```lua
number = memory.ptr_to_handle(mem_addr)
```
### `allocate(size)`
- **Parameters:**
- `size` (integer): The number of bytes to allocate on the heap.
- **Returns:**
- `pointer`: A pointer to the newly allocated memory.
**Exemple Usage:**
```lua
pointer = memory.allocate(size)
```
### `free(ptr)`
- **Parameters:**
- `ptr` (pointer): The pointer that must be freed.
**Exemple Usage:**
```lua
memory.free(ptr)
```

View File

@ -0,0 +1,81 @@
# Table: menu_event
Table containing all possible events to which you can respond.
## Fields (6)
### `PlayerLeave`
Event that is triggered when a player leave the game session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerLeave, function (player_name)
log.info(player_name)
end)
```
- Type: `integer`
### `PlayerJoin`
Event that is triggered when a player join the game session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerJoin, function (player_name, player_id)
log.info(player_name)
log.info(player_id)
end)
```
- Type: `integer`
### `PlayerMgrInit`
Event that is triggered when the player manager initialize. Usually called when we are joining a session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerMgrInit, function ()
log.info("Player manager inited, we just joined a session.")
end)
```
- Type: `integer`
### `PlayerMgrShutdown`
Event that is triggered when the player manager shutdown. Usually called when we are leaving a session.
**Exemple Usage:**
```lua
event.register_handler(menu_event.PlayerMgrShutdown, function ()
log.info("Player manager inited, we just joined a session.")
end)
```
- Type: `integer`
### `ChatMessageReceived`
Event that is triggered when we receive a in-game chat message.
**Exemple Usage:**
```lua
event.register_handler(menu_event.ChatMessageReceived, function (player_id, chat_message)
log.info(player_id)
log.info(chat_message)
end)
```
- Type: `integer`
### `ScriptedGameEventReceived`
Event that is triggered when we receive a scripted game event.
**Exemple Usage:**
```lua
event.register_handler(menu_event.ScriptedGameEventReceived, function (player_id, script_event_args)
log.info(player_id)
log.info(script_event_args)
end)
```
- Type: `integer`

132
docs/lua/tables/network.md Normal file
View File

@ -0,0 +1,132 @@
# Table: network
Table containing helper functions for network related features.
## Functions (10)
### `trigger_script_event(bitset, _args)`
Call trigger_script_event (TSE)
- **Parameters:**
- `bitset` (integer)
- `_args` (table)
**Exemple Usage:**
```lua
network.trigger_script_event(bitset, _args)
```
### `give_pickup_rewards(player, reward)`
Give the given pickup reward to the given player.
- **Parameters:**
- `player` (integer): Index of the player.
- `reward` (integer): Index of the reward pickup.
**Exemple Usage:**
```lua
network.give_pickup_rewards(player, reward)
```
### `set_player_coords(player_idx, x, y, z)`
Teleport the given player to the given position.
- **Parameters:**
- `player_idx` (integer): Index of the player.
- `x` (float): New x position.
- `y` (float): New y position.
- `z` (float): New z position.
**Exemple Usage:**
```lua
network.set_player_coords(player_idx, x, y, z)
```
### `set_all_player_coords(x, y, z)`
Teleport all players to the given position.
- **Parameters:**
- `x` (float): New x position.
- `y` (float): New y position.
- `z` (float): New z position.
**Exemple Usage:**
```lua
network.set_all_player_coords(x, y, z)
```
### `get_selected_player()`
- **Returns:**
- `integer`: Returns the index of the currently selected player in the GUI.
**Exemple Usage:**
```lua
integer = network.get_selected_player()
```
### `get_selected_database_player_rockstar_id()`
- **Returns:**
- `integer`: Returns the rockstar id of the currently selected player in the GUI.
**Exemple Usage:**
```lua
integer = network.get_selected_database_player_rockstar_id()
```
### `flag_player_as_modder(player_idx)`
Flags the given player as a modder in our local database.
- **Parameters:**
- `player_idx` (integer): Index of the player.
**Exemple Usage:**
```lua
network.flag_player_as_modder(player_idx)
```
### `is_player_flagged_as_modder(player_idx)`
- **Parameters:**
- `player_idx` (integer): Index of the player.
- **Returns:**
- `boolean`: Returns true if the given player is flagged as a modder.
**Exemple Usage:**
```lua
boolean = network.is_player_flagged_as_modder(player_idx)
```
### `force_script_host(script_name)`
Try to force ourself to be host for the given GTA Script.
- **Parameters:**
- `script_name` (string): Name of the script
**Exemple Usage:**
```lua
network.force_script_host(script_name)
```
### `send_chat_message(msg, team_only)`
Sends a message to the in game chat.
- **Parameters:**
- `msg` (string): Message to be sent.
- `team_only` (boolean): Should be true if the msg should only be sent to our team.
**Exemple Usage:**
```lua
network.send_chat_message(msg, team_only)
```

53
docs/lua/tables/script.md Normal file
View File

@ -0,0 +1,53 @@
# Table: script
Table containing helper functions related to gta scripts.
## Functions (4)
### `register_looped(name, func)`
Registers a function that will be looped as a gta script.
- **Parameters:**
- `name` (string): name of your new looped script
- `func` (function): function that will be executed in a forever loop.
**Exemple Usage:**
```lua
script.register_looped(name, func)
```
### `run_in_fiber(func)`
Executes a function inside the fiber pool, you can call natives inside it.
- **Parameters:**
- `func` (function): function that will be executed once in the fiber pool, you can call natives inside it.
**Exemple Usage:**
```lua
script.run_in_fiber(func)
```
### `yield()`
Yield execution.
**Exemple Usage:**
```lua
script.yield()
```
### `sleep(ms)`
Sleep for the given amount of time, time is in milliseconds.
- **Parameters:**
- `ms` (integer): The amount of time in milliseconds that we will sleep for.
**Exemple Usage:**
```lua
script.sleep(ms)
```

View File

@ -0,0 +1,79 @@
# Table: tunables
Table for manipulating gta tunables.
## Functions (6)
### `get_int(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `integer`: The value of the given tunable.
**Exemple Usage:**
```lua
integer = tunables.get_int(tunable_name)
```
### `get_float(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `float`: The value of the given tunable.
**Exemple Usage:**
```lua
float = tunables.get_float(tunable_name)
```
### `get_bool(tunable_name)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- **Returns:**
- `boolean`: The value of the given tunable.
**Exemple Usage:**
```lua
boolean = tunables.get_bool(tunable_name)
```
### `set_int(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (integer): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_int(tunable_name, val)
```
### `set_float(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (float): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_float(tunable_name, val)
```
### `set_bool(tunable_name, val)`
- **Parameters:**
- `tunable_name` (string): The name of the tunable.
- `val` (boolean): The new value of the given tunable.
**Exemple Usage:**
```lua
tunables.set_bool(tunable_name, val)
```