Download
(13 Kb)
Download
Updated: 03/03/23 07:25 AM
Compatibility:
Scribes of Fate (8.3.5)
Firesong (8.2.5)
Updated:03/03/23 07:25 AM
Created:03/03/23 07:25 AM
Monthly downloads:16,626
Total downloads:37,356
Favorites:43
MD5:
LibId64  Popular! (More than 5000 hits)
Version: 1.0.0
by: sirinsidiator [More]
LibId64 is a wrapper around the id64 (=uint64) datatype in Elder Scrolls Online.
It aims to make working with id64s as convenient as possible, while hiding away all the computer science, undocumented Lua features and dark (meta table) magic.
The source code can be found on github.

Simply pass an id64 or a string containing a number to the function `id64()` and it will hand you the wrapper object. Passing `nil` or an already wrapped id64 will return them unchanged. Other value types will throw an error.
There are also two additional functions `id64.isSafeNumber()` and `id64.fromNumber()` which can be used to convert certain Lua numbers. Check the reference section below for more details.

Lua Code:
  1. local value1 = id64(GetNextMailId())
  2. local value2 = id64("1234567890")
  3. local value3 = id64.fromNumber(1)
  4. local value4 = id64(value1)

The wrapper has three properties `id64`, `string` and `number`, which return the underlying id64 and string representation for use with APIs and the saved variables and optionally the numeric presentation if the id64 is in the range that can be represented by Lua numbers.

Lua Code:
  1. GetMailItemInfo(value1.id64)
  2. mySaveData.someValue = value2.string -- or tostring(value2)
  3. mySaveData.anotherValue = value3.number

But that's not all - you can use the wrapper to do math operations with other id64s!
It's limited to additions and subtractions only and numbers starting from `9007199254740992` (2^53) will use string based arithmetic, which will have abysmal performance.

Lua Code:
  1. local result1 = 1 + value2
  2. local result2 = value2 + value3
  3. local result3 = value4 - 1337

It also supports logic operators, allowing you to do comparisons between two id64 objects with regular Lua syntax instead of having to call the API functions yourself.

Lua Code:
  1. d(value1 == value4) -- true
  2. if value1 > result1 then d("checks out") end

Last but not least you can concatenate the wrapper to a string!
Lua Code:
  1. d("my result: " .. result2)

The wrapper objects are immutable and only exist once per value, which makes them somewhat memory efficient. You should still try to avoid keeping every single id64 wrapped all the time and instead only wrap them when you actually work with them, so the garbage collector can free up the memory.


Reference

id64()
Code:
id64obj|nil = id64(string|id64|id64obj|nil)
Creates an id64 wrapper from a string containing a number or an id64. `nil` and already wrapped id64s are returned as is. Other value types are not supported and will throw an error.

id64.fromNumber()
Code:
id64obj = id64.fromNumber(luaint53)
Creates an id64 wrapper from integers between `-9007199254740992` (-2^53) and `9007199254740992` (2^53). Other integer values cannot be safely represented as a Lua number and will throw an error.

id64.isSafeNumber()
Code:
bool = id64.isSafeNumber(number)
Returns true if the passed number is between `-9007199254740992` (-2^53) and `9007199254740992` (2^53).

id64.isInstance()
Code:
bool = id64.isInstance(any)
Returns `true` if the passed value is an id64 wrapper object.

Properties

Code:
| name       | type           | comment                                                                                         |
|------------|----------------|-------------------------------------------------------------------------------------------------|
| string     | `string`       | The string representing the id64 value. Mainly used for storing them in saved variables.        |
| id64       | `id64`         | The actual id64 value for use with API functions.                                               |
| number     | `luaint53|nil` | Either a Lua number or nil, if the id64 is outside of the range that can be safely represented. |
Operators

Code:
| type       | supported                        |
|------------|----------------------------------|
| arithmetic | `+`, `-`                         |
| logic      | `==`, `~=`, `<`, `>`, `<=`, `>=` |
| string     | `..`                             |
There have been no comments posted to this file.
Be the first to add one.



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.