mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-23 01:02:23 +08:00
Lua: can make new tabs from lua scripts, doc generation for available tabs to use (#1593)
* lua api: add globals.get_uint and globals.set_uint * lua doc: remove duplicate function check as we can overload so it doesn't make sense * lua doc gen: add support for parsing the tabs enum * gui: custom lua tabs don't have a `func` rendering function but can still have elements to draw * lua doc: update generated doc * chore: code style * chore: minor spelling mistake * chore: code style * gui_service: add runtime removal of tabs * refactor: make it so that it's less likely defining tabs and their translation key in a wrong way. * lua api: ability to add custom tabs to the gui from lua
This commit is contained in:
@ -9,7 +9,7 @@ Class representing a gui text element.
|
||||
- **Parameters:**
|
||||
- `new_text` (string): The new text for that gui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
base_text_element:set_text(new_text)
|
||||
```
|
||||
@ -19,7 +19,7 @@ base_text_element:set_text(new_text)
|
||||
- **Returns:**
|
||||
- `string`: Returns the current text for that gui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = base_text_element:get_text()
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class representing a gui checkbox.
|
||||
- **Returns:**
|
||||
- `boolean`: Is the checkbox checked?
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = checkbox:is_enabled()
|
||||
```
|
||||
@ -21,7 +21,7 @@ boolean = checkbox:is_enabled()
|
||||
- **Parameters:**
|
||||
- `enabled` (boolean): The desired enabled state of the checkbox.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
checkbox:set_enabled(enabled)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing a float value within the GUI.
|
||||
- **Returns:**
|
||||
- `float`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = input_float:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ float = input_float:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (float): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_float:set_value(val)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing an integer value within the GU
|
||||
- **Returns:**
|
||||
- `integer`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = input_int:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ integer = input_int:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (integer): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_int:set_value(val)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class for representing an input field for editing a string value within the GUI.
|
||||
- **Returns:**
|
||||
- `string`: Get the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = input_string:get_value()
|
||||
```
|
||||
@ -21,7 +21,7 @@ string = input_string:get_value()
|
||||
- **Parameters:**
|
||||
- `val` (string): Set the value currently written inside the input field.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_string:set_value(val)
|
||||
```
|
||||
|
@ -8,7 +8,7 @@ Class representing a in-memory patch.
|
||||
|
||||
Apply the modified value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch:apply()
|
||||
```
|
||||
@ -17,7 +17,7 @@ lua_patch:apply()
|
||||
|
||||
Restore the original value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch:restore()
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Returns a memory instance, with the given address.
|
||||
- **Parameters:**
|
||||
- `address` (integer): Address
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
myInstance = pointer:new(address)
|
||||
```
|
||||
@ -28,7 +28,7 @@ Adds an offset to the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:add(offset)
|
||||
```
|
||||
@ -43,7 +43,7 @@ Subs an offset to the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:sub(offset)
|
||||
```
|
||||
@ -58,7 +58,7 @@ Rips the current memory address and returns a new pointer object.
|
||||
- **Returns:**
|
||||
- `pointer`: new pointer object.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:rip(offset)
|
||||
```
|
||||
@ -70,7 +70,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_byte()
|
||||
```
|
||||
@ -82,7 +82,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_word()
|
||||
```
|
||||
@ -94,7 +94,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_dword()
|
||||
```
|
||||
@ -106,7 +106,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = pointer:get_float()
|
||||
```
|
||||
@ -118,7 +118,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_qword()
|
||||
```
|
||||
@ -130,7 +130,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_byte(value)
|
||||
```
|
||||
@ -142,7 +142,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_word(value)
|
||||
```
|
||||
@ -154,7 +154,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_dword(value)
|
||||
```
|
||||
@ -166,7 +166,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (float): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_float(value)
|
||||
```
|
||||
@ -178,7 +178,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (number): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_qword(value)
|
||||
```
|
||||
@ -190,7 +190,7 @@ 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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = pointer:get_string()
|
||||
```
|
||||
@ -202,7 +202,7 @@ Sets the value at the memory address to the specified value of the given type.
|
||||
- **Parameters:**
|
||||
- `value` (string): new value.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer:set_string(value)
|
||||
```
|
||||
@ -219,7 +219,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_byte(value)
|
||||
```
|
||||
@ -236,7 +236,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_word(value)
|
||||
```
|
||||
@ -253,7 +253,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_dword(value)
|
||||
```
|
||||
@ -270,7 +270,7 @@ The original value is restored when you call the restore function on the lua_pat
|
||||
- **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:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
lua_patch = pointer:patch_qword(value)
|
||||
```
|
||||
@ -280,7 +280,7 @@ lua_patch = pointer:patch_qword(value)
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the address is null.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = pointer:is_null()
|
||||
```
|
||||
@ -290,7 +290,7 @@ boolean = pointer:is_null()
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the address is not null.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = pointer:is_valid()
|
||||
```
|
||||
@ -302,7 +302,7 @@ Dereferences the memory address and returns a new pointer object pointing to the
|
||||
- **Returns:**
|
||||
- `pointer`: A new pointer object pointing to the value at that address.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = pointer:deref()
|
||||
```
|
||||
@ -314,7 +314,7 @@ Retrieves the memory address stored in the pointer object.
|
||||
- **Returns:**
|
||||
- `number`: The memory address stored in the pointer object as a number.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = pointer:get_address()
|
||||
```
|
||||
|
@ -2,7 +2,25 @@
|
||||
|
||||
Class for representing a tab within the GUI.
|
||||
|
||||
## Functions (8)
|
||||
## Functions (10)
|
||||
|
||||
### `clear()`
|
||||
|
||||
Clear the tab of all its custom lua content that you own.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:clear()
|
||||
```
|
||||
|
||||
### `add_tab()`
|
||||
|
||||
Add a sub tab to this tab.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:add_tab()
|
||||
```
|
||||
|
||||
### `add_button(name, callback)`
|
||||
|
||||
@ -12,7 +30,7 @@ Add a button to the gui tab.
|
||||
- `name` (string): Text written inside the button.
|
||||
- `callback` (function): function that will be called when the button is clicked.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab:add_button(name, callback)
|
||||
```
|
||||
@ -27,7 +45,7 @@ Add text to the gui tab.
|
||||
- **Returns:**
|
||||
- `text`: The text object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
text = tab:add_text(name)
|
||||
```
|
||||
@ -42,7 +60,7 @@ Add a checkbox widget to the gui tab.
|
||||
- **Returns:**
|
||||
- `checkbox`: The checkbox object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
checkbox = tab:add_checkbox(name)
|
||||
```
|
||||
@ -54,7 +72,7 @@ Add a ImGui::SameLine.
|
||||
- **Returns:**
|
||||
- `sameline`: The sameline object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
sameline = tab:add_sameline()
|
||||
```
|
||||
@ -66,7 +84,7 @@ Add a ImGui::Separator.
|
||||
- **Returns:**
|
||||
- `separator`: The separator object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
separator = tab:add_separator()
|
||||
```
|
||||
@ -81,7 +99,7 @@ Add a ImGui::InputInt.
|
||||
- **Returns:**
|
||||
- `input_int`: The input_int object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_int = tab:add_input_int(name)
|
||||
```
|
||||
@ -96,7 +114,7 @@ Add a ImGui::InputFloat.
|
||||
- **Returns:**
|
||||
- `input_float`: The input_float object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_float = tab:add_input_float(name)
|
||||
```
|
||||
@ -111,7 +129,7 @@ Add a ImGui::InputText.
|
||||
- **Returns:**
|
||||
- `input_string`: The input_string object instance.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
input_string = tab:add_input_string(name)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Class representing an imgui text element.
|
||||
- **Parameters:**
|
||||
- `font` (string): The new font name for that imgui text element.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
text:set_font(font)
|
||||
```
|
||||
|
@ -33,7 +33,7 @@ Returns a vector that contains the x, y, and z values.
|
||||
- `y` (float): y component of the vector.
|
||||
- `z` (float): z component of the vector.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
myInstance = vec3:new(x, y, z)
|
||||
```
|
||||
|
@ -17,6 +17,7 @@ class DocKind(Enum):
|
||||
Field = "field"
|
||||
Constructor = "constructor"
|
||||
Function = "function"
|
||||
Tabs = "tabs"
|
||||
|
||||
|
||||
class Table:
|
||||
@ -47,8 +48,6 @@ class Table:
|
||||
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}.")
|
||||
|
||||
@ -65,15 +64,6 @@ class Table:
|
||||
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):
|
||||
@ -117,8 +107,6 @@ class Class:
|
||||
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}:")
|
||||
|
||||
@ -135,15 +123,6 @@ class Class:
|
||||
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):
|
||||
@ -203,7 +182,7 @@ class Constructor:
|
||||
s += f"\n"
|
||||
s += "\n"
|
||||
|
||||
s += f"**Exemple Usage:**\n"
|
||||
s += f"**Example Usage:**\n"
|
||||
s += "```lua\n"
|
||||
|
||||
s += f"myInstance = {self.parent.name}:new({parameters_str})\n"
|
||||
@ -285,7 +264,7 @@ class Function:
|
||||
|
||||
s += "\n"
|
||||
|
||||
s += f"**Exemple Usage:**\n"
|
||||
s += f"**Example Usage:**\n"
|
||||
s += "```lua\n"
|
||||
if self.return_type is not None and len(self.return_type) > 0:
|
||||
s += self.return_type + " = "
|
||||
@ -345,7 +324,8 @@ def parse_lua_api_doc(folder_path):
|
||||
.lower()
|
||||
)
|
||||
|
||||
continue
|
||||
if doc_kind is not DocKind.Tabs:
|
||||
continue
|
||||
|
||||
if doc_kind is not None and "//" in line:
|
||||
match doc_kind:
|
||||
@ -387,6 +367,7 @@ def parse_lua_api_doc(folder_path):
|
||||
line,
|
||||
line_lower,
|
||||
)
|
||||
case DocKind.Tabs: parse_tabs_doc(file)
|
||||
case _:
|
||||
# print("unsupported doc kind: " + str(doc_kind))
|
||||
pass
|
||||
@ -503,6 +484,28 @@ def parse_constructor_doc(cur_constructor, cur_class, line, line_lower):
|
||||
return cur_constructor, cur_class
|
||||
|
||||
|
||||
tabs_enum = []
|
||||
def parse_tabs_doc(file):
|
||||
start_parsing = False
|
||||
for line in file:
|
||||
if "enum class" in line.lower():
|
||||
start_parsing = True
|
||||
continue
|
||||
|
||||
if start_parsing:
|
||||
if "};" in line.lower():
|
||||
return
|
||||
if "{" == line.lower().strip():
|
||||
continue
|
||||
if "//" in line.lower():
|
||||
continue
|
||||
if "" == line.lower().strip():
|
||||
continue
|
||||
else:
|
||||
tabs_enum.append(line.replace(",", "").strip())
|
||||
|
||||
|
||||
|
||||
def make_parameter_from_doc_line(line):
|
||||
param_info = line.split(lua_api_comment_separator, 3)[1:]
|
||||
param_name = param_type = param_desc = ""
|
||||
@ -542,6 +545,36 @@ for table_name, table in tables.items():
|
||||
f.write(str(table))
|
||||
f.close()
|
||||
|
||||
tabs_file_name = f"./tabs.md"
|
||||
if os.path.exists(tabs_file_name):
|
||||
os.remove(tabs_file_name)
|
||||
f = open(tabs_file_name, "a")
|
||||
|
||||
f.write("""# Tabs
|
||||
|
||||
All the tabs from the menu are listed below, used as parameter for adding gui elements to them.
|
||||
|
||||
**Example Usage:**
|
||||
|
||||
```lua
|
||||
missionsTab = gui.get_tab("GUI_TAB_MISSIONS")
|
||||
missionsTab:add_button("Click me", function ()
|
||||
log.info("You clicked!")
|
||||
end)
|
||||
```
|
||||
|
||||
For a complete list of available gui functions, please refer to the tab class documentation and the gui table documentation.
|
||||
|
||||
""")
|
||||
|
||||
f.write(f"## Tab Count: {len(tabs_enum)}\n\n")
|
||||
|
||||
# Minus the first, because it's the `NONE` tab, minus the last one because it's for runtime defined tabs.
|
||||
for i in range(1, len(tabs_enum) - 1 ):
|
||||
f.write("### `GUI_TAB_" + tabs_enum[i] + "`\n")
|
||||
|
||||
f.close()
|
||||
|
||||
try:
|
||||
os.makedirs("./classes/")
|
||||
except:
|
||||
|
@ -12,7 +12,7 @@ Custom fields, functions, etc added to The Lua [Global Table](https://www.lua.or
|
||||
- **Returns:**
|
||||
- `integer`: The joaat hashed input string.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = joaat(str)
|
||||
```
|
||||
|
@ -12,7 +12,7 @@ Call a menu command.
|
||||
- `command_name` (string): The name of the command that will be called.
|
||||
- `_args` (table): Optional. List of arguments for the command.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
command.call(command_name, _args)
|
||||
```
|
||||
@ -26,7 +26,7 @@ Call a menu command on a given player.
|
||||
- `command_name` (string): The name of the command that will be called.
|
||||
- `_args` (table): Optional. List of arguments for the command.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
command.call_player(player_idx, command_name, _args)
|
||||
```
|
||||
|
@ -12,7 +12,7 @@ Register a function that will be called each time the corresponding menu_event i
|
||||
- `menu_event` (menu_event): The menu_event that we want to respond to.
|
||||
- `func` (function): The function that will be called.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event, func)
|
||||
```
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Table containing functions for manipulating gta script globals.
|
||||
|
||||
## Functions (7)
|
||||
## Functions (9)
|
||||
|
||||
### `get_int(global)`
|
||||
|
||||
@ -14,11 +14,26 @@ Retrieves an int global value.
|
||||
- **Returns:**
|
||||
- `integer`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = globals.get_int(global)
|
||||
```
|
||||
|
||||
### `get_uint(global)`
|
||||
|
||||
Retrieves an uint global value.
|
||||
|
||||
- **Parameters:**
|
||||
- `global` (integer): index of the global
|
||||
|
||||
- **Returns:**
|
||||
- `integer`: value of the global
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = globals.get_uint(global)
|
||||
```
|
||||
|
||||
### `get_float(global)`
|
||||
|
||||
Retrieves a float global value.
|
||||
@ -29,7 +44,7 @@ Retrieves a float global value.
|
||||
- **Returns:**
|
||||
- `float`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = globals.get_float(global)
|
||||
```
|
||||
@ -44,7 +59,7 @@ Retrieves a string global value.
|
||||
- **Returns:**
|
||||
- `string`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
string = globals.get_string(global)
|
||||
```
|
||||
@ -57,11 +72,24 @@ Sets an int global value.
|
||||
- `global` (integer): index of the global
|
||||
- `val` (integer): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_int(global, val)
|
||||
```
|
||||
|
||||
### `set_uint(global, val)`
|
||||
|
||||
Sets an uint global value.
|
||||
|
||||
- **Parameters:**
|
||||
- `global` (integer): index of the global
|
||||
- `val` (integer): new value for the global
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_uint(global, val)
|
||||
```
|
||||
|
||||
### `set_float(global, val)`
|
||||
|
||||
Sets a float global value.
|
||||
@ -70,7 +98,7 @@ Sets a float global value.
|
||||
- `global` (integer): index of the global
|
||||
- `val` (float): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_float(global, val)
|
||||
```
|
||||
@ -83,7 +111,7 @@ Sets a string global value.
|
||||
- `global` (integer): index of the global
|
||||
- `str` (string): new value for the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
globals.set_string(global, str)
|
||||
```
|
||||
@ -98,7 +126,7 @@ Retrieves a pointer global.
|
||||
- **Returns:**
|
||||
- `pointer`: value of the global
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = globals.get_pointer(global)
|
||||
```
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Table containing functions for modifying the menu GUI.
|
||||
|
||||
## Functions (5)
|
||||
## Functions (6)
|
||||
|
||||
### `get_tab(tab_name)`
|
||||
|
||||
@ -12,11 +12,24 @@ Table containing functions for modifying the menu GUI.
|
||||
- **Returns:**
|
||||
- `tab`: A tab instance which corresponds to the tab in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab = gui.get_tab(tab_name)
|
||||
```
|
||||
|
||||
### `add_tab(tab_name)`
|
||||
|
||||
- **Parameters:**
|
||||
- `tab_name` (string): Name of the tab to add.
|
||||
|
||||
- **Returns:**
|
||||
- `tab`: A tab instance which corresponds to the new tab in the GUI.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tab = gui.add_tab(tab_name)
|
||||
```
|
||||
|
||||
### `show_message(title, message)`
|
||||
|
||||
Shows a message to the user with the given title and message.
|
||||
@ -25,7 +38,7 @@ Shows a message to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_message(title, message)
|
||||
```
|
||||
@ -38,7 +51,7 @@ Shows a warning to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_warning(title, message)
|
||||
```
|
||||
@ -51,7 +64,7 @@ Shows an error to the user with the given title and message.
|
||||
- `title` (string)
|
||||
- `message` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
gui.show_error(title, message)
|
||||
```
|
||||
@ -61,7 +74,7 @@ gui.show_error(title, message)
|
||||
- **Returns:**
|
||||
- `bool`: Returns true if the GUI is open.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
bool = gui.is_open()
|
||||
```
|
||||
|
@ -13,7 +13,7 @@ Table for manipulating GTA scripts locals.
|
||||
- **Returns:**
|
||||
- `integer`: The value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = locals.get_int(script, index)
|
||||
```
|
||||
@ -27,7 +27,7 @@ integer = locals.get_int(script, index)
|
||||
- **Returns:**
|
||||
- `float`: The value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = locals.get_float(script, index)
|
||||
```
|
||||
@ -39,7 +39,7 @@ float = locals.get_float(script, index)
|
||||
- `index` (index): Index of the script local.
|
||||
- `val` (integer): The new value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
locals.set_int(script, index, val)
|
||||
```
|
||||
@ -51,7 +51,7 @@ locals.set_int(script, index, val)
|
||||
- `index` (index): Index of the script local.
|
||||
- `val` (float): The new value of the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
locals.set_float(script, index, val)
|
||||
```
|
||||
@ -65,7 +65,7 @@ locals.set_float(script, index, val)
|
||||
- **Returns:**
|
||||
- `pointer`: The pointer to the given local.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = locals.get_pointer(script, index)
|
||||
```
|
||||
|
@ -11,7 +11,7 @@ Logs an informational message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.info(data)
|
||||
```
|
||||
@ -23,7 +23,7 @@ Logs a warning message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.warning(data)
|
||||
```
|
||||
@ -35,7 +35,7 @@ Logs a debug message.
|
||||
- **Parameters:**
|
||||
- `data` (string)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
log.debug(data)
|
||||
```
|
||||
|
@ -14,7 +14,7 @@ Scans the specified memory pattern within the "GTA5.exe" module and returns a po
|
||||
- **Returns:**
|
||||
- `pointer`: A pointer to the found address.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.scan_pattern(pattern)
|
||||
```
|
||||
@ -27,7 +27,7 @@ pointer = memory.scan_pattern(pattern)
|
||||
- **Returns:**
|
||||
- `pointer`: A rage::CDynamicEntity pointer to the script game entity handle
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.handle_to_ptr(entity)
|
||||
```
|
||||
@ -40,7 +40,7 @@ pointer = memory.handle_to_ptr(entity)
|
||||
- **Returns:**
|
||||
- `number`: The script game entity handle linked to the given rage::CDynamicEntity pointer.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
number = memory.ptr_to_handle(mem_addr)
|
||||
```
|
||||
@ -53,7 +53,7 @@ number = memory.ptr_to_handle(mem_addr)
|
||||
- **Returns:**
|
||||
- `pointer`: A pointer to the newly allocated memory.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
pointer = memory.allocate(size)
|
||||
```
|
||||
@ -63,7 +63,7 @@ pointer = memory.allocate(size)
|
||||
- **Parameters:**
|
||||
- `ptr` (pointer): The pointer that must be freed.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
memory.free(ptr)
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ Table containing all possible events to which you can respond.
|
||||
### `PlayerLeave`
|
||||
|
||||
Event that is triggered when a player leave the game session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerLeave, function (player_name)
|
||||
log.info(player_name)
|
||||
@ -19,7 +19,7 @@ end)
|
||||
### `PlayerJoin`
|
||||
|
||||
Event that is triggered when a player join the game session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerJoin, function (player_name, player_id)
|
||||
log.info(player_name)
|
||||
@ -32,7 +32,7 @@ end)
|
||||
### `PlayerMgrInit`
|
||||
|
||||
Event that is triggered when the player manager initialize. Usually called when we are joining a session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerMgrInit, function ()
|
||||
log.info("Player manager inited, we just joined a session.")
|
||||
@ -44,10 +44,10 @@ end)
|
||||
### `PlayerMgrShutdown`
|
||||
|
||||
Event that is triggered when the player manager shutdown. Usually called when we are leaving a session.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.PlayerMgrShutdown, function ()
|
||||
log.info("Player manager inited, we just joined a session.")
|
||||
log.info("Player manager inited, we just left a session.")
|
||||
end)
|
||||
```
|
||||
|
||||
@ -56,7 +56,7 @@ end)
|
||||
### `ChatMessageReceived`
|
||||
|
||||
Event that is triggered when we receive a in-game chat message.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.ChatMessageReceived, function (player_id, chat_message)
|
||||
log.info(player_id)
|
||||
@ -69,7 +69,7 @@ end)
|
||||
### `ScriptedGameEventReceived`
|
||||
|
||||
Event that is triggered when we receive a scripted game event.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
event.register_handler(menu_event.ScriptedGameEventReceived, function (player_id, script_event_args)
|
||||
log.info(player_id)
|
||||
|
@ -12,7 +12,7 @@ Call trigger_script_event (TSE)
|
||||
- `bitset` (integer)
|
||||
- `_args` (table)
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.trigger_script_event(bitset, _args)
|
||||
```
|
||||
@ -25,7 +25,7 @@ Give the given pickup reward to the given player.
|
||||
- `player` (integer): Index of the player.
|
||||
- `reward` (integer): Index of the reward pickup.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.give_pickup_rewards(player, reward)
|
||||
```
|
||||
@ -40,7 +40,7 @@ Teleport the given player to the given position.
|
||||
- `y` (float): New y position.
|
||||
- `z` (float): New z position.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.set_player_coords(player_idx, x, y, z)
|
||||
```
|
||||
@ -54,7 +54,7 @@ Teleport all players to the given position.
|
||||
- `y` (float): New y position.
|
||||
- `z` (float): New z position.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.set_all_player_coords(x, y, z)
|
||||
```
|
||||
@ -64,7 +64,7 @@ network.set_all_player_coords(x, y, z)
|
||||
- **Returns:**
|
||||
- `integer`: Returns the index of the currently selected player in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = network.get_selected_player()
|
||||
```
|
||||
@ -74,7 +74,7 @@ integer = network.get_selected_player()
|
||||
- **Returns:**
|
||||
- `integer`: Returns the rockstar id of the currently selected player in the GUI.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = network.get_selected_database_player_rockstar_id()
|
||||
```
|
||||
@ -86,7 +86,7 @@ Flags the given player as a modder in our local database.
|
||||
- **Parameters:**
|
||||
- `player_idx` (integer): Index of the player.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.flag_player_as_modder(player_idx)
|
||||
```
|
||||
@ -99,7 +99,7 @@ network.flag_player_as_modder(player_idx)
|
||||
- **Returns:**
|
||||
- `boolean`: Returns true if the given player is flagged as a modder.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = network.is_player_flagged_as_modder(player_idx)
|
||||
```
|
||||
@ -111,7 +111,7 @@ Try to force ourself to be host for the given GTA Script.
|
||||
- **Parameters:**
|
||||
- `script_name` (string): Name of the script
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.force_script_host(script_name)
|
||||
```
|
||||
@ -124,7 +124,7 @@ Sends a message to the in game chat.
|
||||
- `msg` (string): Message to be sent.
|
||||
- `team_only` (boolean): Should be true if the msg should only be sent to our team.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
network.send_chat_message(msg, team_only)
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ Table containing helper functions related to gta scripts.
|
||||
### `register_looped(name, func)`
|
||||
|
||||
Registers a function that will be looped as a gta script.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.register_looped("nameOfMyLoopedScript", function (script)
|
||||
-- sleep until next game frame
|
||||
@ -35,7 +35,7 @@ end)
|
||||
- `name` (string): name of your new looped script
|
||||
- `func` (function): function that will be executed in a forever loop.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.register_looped(name, func)
|
||||
```
|
||||
@ -43,7 +43,7 @@ script.register_looped(name, func)
|
||||
### `run_in_fiber(func)`
|
||||
|
||||
Executes a function once inside the fiber pool, you can call natives inside it and yield or sleep.
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.run_in_fiber(function (script)
|
||||
-- sleep until next game frame
|
||||
@ -70,9 +70,8 @@ end)
|
||||
- **Parameters:**
|
||||
- `func` (function): function that will be executed once in the fiber pool.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.run_in_fiber(func)
|
||||
```
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ Table for manipulating gta tunables.
|
||||
- **Returns:**
|
||||
- `integer`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
integer = tunables.get_int(tunable_name)
|
||||
```
|
||||
@ -25,7 +25,7 @@ integer = tunables.get_int(tunable_name)
|
||||
- **Returns:**
|
||||
- `float`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
float = tunables.get_float(tunable_name)
|
||||
```
|
||||
@ -38,7 +38,7 @@ float = tunables.get_float(tunable_name)
|
||||
- **Returns:**
|
||||
- `boolean`: The value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
boolean = tunables.get_bool(tunable_name)
|
||||
```
|
||||
@ -49,7 +49,7 @@ boolean = tunables.get_bool(tunable_name)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (integer): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_int(tunable_name, val)
|
||||
```
|
||||
@ -60,7 +60,7 @@ tunables.set_int(tunable_name, val)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (float): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_float(tunable_name, val)
|
||||
```
|
||||
@ -71,7 +71,7 @@ tunables.set_float(tunable_name, val)
|
||||
- `tunable_name` (string): The name of the tunable.
|
||||
- `val` (boolean): The new value of the given tunable.
|
||||
|
||||
**Exemple Usage:**
|
||||
**Example Usage:**
|
||||
```lua
|
||||
tunables.set_bool(tunable_name, val)
|
||||
```
|
||||
|
57
docs/lua/tabs.md
Normal file
57
docs/lua/tabs.md
Normal file
@ -0,0 +1,57 @@
|
||||
# Tabs
|
||||
|
||||
All the tabs from the menu are listed below, used as parameter for adding gui elements to them.
|
||||
|
||||
**Example Usage:**
|
||||
|
||||
```lua
|
||||
missionsTab = gui.get_tab("GUI_TAB_MISSIONS")
|
||||
missionsTab:add_button("Click me", function ()
|
||||
log.info("You clicked!")
|
||||
end)
|
||||
```
|
||||
|
||||
For a complete list of available gui functions, please refer to the tab class documentation and the gui table documentation.
|
||||
|
||||
## Tab Count: 42
|
||||
|
||||
### `GUI_TAB_SELF`
|
||||
### `GUI_TAB_WEAPONS`
|
||||
### `GUI_TAB_TELEPORT`
|
||||
### `GUI_TAB_MOBILE`
|
||||
### `GUI_TAB_OUTFIT_EDITOR`
|
||||
### `GUI_TAB_OUTFIT_SLOTS`
|
||||
### `GUI_TAB_VEHICLE`
|
||||
### `GUI_TAB_HANDLING`
|
||||
### `GUI_TAB_HANDLING_SEARCH`
|
||||
### `GUI_TAB_HANDLING_SAVED_PROFILE`
|
||||
### `GUI_TAB_HANDLING_MY_PROFILES`
|
||||
### `GUI_TAB_HANDLING_CURRENT_PROFILE`
|
||||
### `GUI_TAB_LSC`
|
||||
### `GUI_TAB_SPAWN_VEHICLE`
|
||||
### `GUI_TAB_FUN_VEHICLE`
|
||||
### `GUI_TAB_WORLD`
|
||||
### `GUI_TAB_SPAWN_PED`
|
||||
### `GUI_TAB_SQUAD_SPAWNER`
|
||||
### `GUI_TAB_CREATOR`
|
||||
### `GUI_TAB_TRAIN`
|
||||
### `GUI_TAB_BLACKHOLE`
|
||||
### `GUI_TAB_MODEL_SWAPPER`
|
||||
### `GUI_TAB_NETWORK`
|
||||
### `GUI_TAB_MISSIONS`
|
||||
### `GUI_TAB_SPOOFING`
|
||||
### `GUI_TAB_PLAYER_DATABASE`
|
||||
### `GUI_TAB_SESSION_BROWSER`
|
||||
### `GUI_TAB_STAT_EDITOR`
|
||||
### `GUI_TAB_SETTINGS`
|
||||
### `GUI_TAB_LUA_SCRIPTS`
|
||||
### `GUI_TAB_CONTEXT_MENU_SETTINGS`
|
||||
### `GUI_TAB_ESP_SETTINGS`
|
||||
### `GUI_TAB_GTA_CACHE_SETTINGS`
|
||||
### `GUI_TAB_GUI_SETTINGS`
|
||||
### `GUI_TAB_HOTKEY_SETTINGS`
|
||||
### `GUI_TAB_REACTION_SETTINGS`
|
||||
### `GUI_TAB_PROTECTION_SETTINGS`
|
||||
### `GUI_TAB_TRANSLATION_SETTINGS`
|
||||
### `GUI_TAB_DEBUG`
|
||||
### `GUI_TAB_PLAYER`
|
Reference in New Issue
Block a user