Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/empyreanx/rawpacker
A RawArray packer/unpacker for Godot.
https://github.com/empyreanx/rawpacker
Last synced: 2 months ago
JSON representation
A RawArray packer/unpacker for Godot.
- Host: GitHub
- URL: https://github.com/empyreanx/rawpacker
- Owner: empyreanx
- License: mit
- Created: 2015-06-22T21:01:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-27T16:58:57.000Z (over 9 years ago)
- Last Synced: 2024-08-02T06:19:32.705Z (5 months ago)
- Language: C++
- Homepage:
- Size: 166 KB
- Stars: 23
- Watchers: 6
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-godot - RawPacker - Simple binary packing/unpacking for RawArray. (Modules / 3D)
README
# RawPacker
Simple binary packing/unpacking for `RawArray` in Godot.
## About
`RawPacker` allows `Variant` arrays to be packed into and unpacked from a `RawArray` using a format string. The approach was inspired by Python's `struct.pack` and `struct.unpack` functions.
Packing/unpacking `RawArray` is useful for sending and storing data in a compact form.## Installation
Simply drop the `rawpacker` directory in your `godot/modules` directory and build for the platfom of your choice.
## Example
```python
var raw_packer = RawPacker.new()
var raw_array = raw_packer.pack("?iis16fhv", [false,1,2,"fixed string",3.14,-42,"variable string"])
var array = raw_packer.unpack("?iis16fhv", raw_array)
print(array)
```**Output:**
```
False, 1, 2, fixed string, 3.14, -42, variable string
```## Format Strings
| Format | Serialized Type | Godot Type | Size (bytes) |
|:------:|--------------------|------------|:------------:|
| c | char | integer | 1 |
| b | unsigned char | integer | 1 |
| ? | unsigned char | boolean | 1 |
| h | short | integer | 2 |
| H | unsigned short | integer | 2 |
| i | int | integer | 4 |
| I | unsigned int | integer | 4 |
| q | long long | integer | 8 |
| Q | unsigned long long | integer | 8 |
| f | float | real | 4 |
| d | double | real | 8 |
| s# | char[] | string | # |
| v | char[] | string | variable |## License
Copyright (c) 2015 James McLean
Licensed under the MIT license.