Skip to content

Commit

Permalink
chore: update Changelog and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
localcc committed Jan 17, 2025
1 parent 3675fb6 commit 8a0a43b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions assets/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Added search filter: `IncludeClassNames`. ([UE4SS #472](https://github.com/UE4SS

### Lua API

Added `TMap` implementation. [UE4SS #755](https://github.com/UE4SS-RE/RE-UE4SS/issues/755)

Added global function `CreateInvalidObject`, which returns an invalid UObject. ([UE4SS #652](https://github.com/UE4SS-RE/RE-UE4SS/issues/652))

Added GenerateLuaTypes function. ([UE4SS #664](https://github.com/UE4SS-RE/RE-UE4SS/pull/664))
Expand All @@ -53,6 +55,7 @@ Added global Dumpers functions to Types.lua. ([UE4SS #664](https://github.com/UE
- Added `NAME_None` definition
- Added `EFindName` enum definition
- Added `FName` function overloads with FindType parameter
- Added `TMap` definitions

#### UEHelpers
- Added function `GetPlayer` which is just a fast way to get player controlled Pawn (the majority of the time it will be the player character) [PR #650](https://github.com/UE4SS-RE/RE-UE4SS/pull/650)
Expand Down
39 changes: 39 additions & 0 deletions assets/Mods/shared/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,45 @@ function TArray:ForEach(Callback) end
---@class TSet<K> : { [K]: nil }

---@class TMap<K, V> : { [K]: V }
TMap = {}

---Find the specified key in the map
---Throws an exception if the key is not found
---@generic K
---@generic V
---@param key K
---@return V
function TMap:Find(key) end

---Inserts a key/value pair into the map
---If the key already exists in the map, replaces the value
---@generic K
---@generic V
---@param key K
---@param value V
function TMap:Add(key, value) end

---Checks if a key exists inside of the map
---@generic K
---@param key K
---@return boolean
function TMap:Contains(key) end

---Removes an element from the map
---If the element doesn't exist, does nothing
---@generic K
---@param key K
function TMap:Remove(key) end

---Clears the map
function TMap:Empty() end

--- Iterates the entire `TMap` and calls the callback function for each element in the array
--- The callback params are: `RemoteUnrealParam key`, `RemoteUnrealParam value` | `LocalUnrealParam value`
--- Use `elem:get()` and `elem:set()` to access/mutate the value
--- Mutating the key is undefined behavior
--- @param callback fun(key: RemoteUnrealParam, value: RemoteUnrealParam)
function TMap:ForEach(callback) end

---@class TScriptInterface<K>

Expand Down
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- [FText](./lua-api/classes/ftext.md)
- [FieldClass](./lua-api/classes/fieldclass.md)
- [TArray](./lua-api/classes/tarray.md)
- [TMap](./lua-api/classes/tmap.md)
- [RemoteUnrealParam](./lua-api/classes/remoteunrealparam.md)
- [LocalUnrealParam](./lua-api/classes/localunrealparam.md)
- [Property](./lua-api/classes/property.md)
Expand Down
39 changes: 39 additions & 0 deletions docs/lua-api/classes/tmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# TMap

## Inheritance
[RemoteObject](./remoteobject.md)

## Metamethods

### __len
- **Usage:** `#TMap`
- **Return type:** `integer`
- Returns the number of current pairs in the map.

## Methods

### Find(key)
- **Return type:** `RemoteUnrealParam` | `LocalUnrealParam`
- **Returns:** the element found in the map
- **Throws:** if an element was not found in the map
- Finds the specified key in the map

### Add(key, value)
- Inserts a key/value pair into the map. If the key already exists in the map, replaces the value.

### Contains(key)
- **Return type:** `bool`
- **Returns:** if the element exists in the map.
- Checks if a key exists inside of the map.

### Remove(key)
- Removes an element from the map. If an element doesn't exist, does nothing.

### Empty()
- Clears the map.

### ForEach(function Callback)
- Iterates the entire `TMap` and calls the callback function for each element in the array.
- The callback params are: `RemoteUnrealParam key`, `RemoteUnrealParam value` | `LocalUnrealParam value`.
- Use `elem:get()` and `elem:set()` to access/mutate the value.
- Mutating the key is undefined behavior.

0 comments on commit 8a0a43b

Please sign in to comment.