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:
@ -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)
|
||||
```
|
||||
|
Reference in New Issue
Block a user