Documentation
¶
Overview ¶
The rbxattr package implements the serialized format of Roblox's instance attributes.
Index ¶
- type Entry
- type Model
- type Type
- type Value
- type ValueBool
- type ValueBrickColor
- type ValueCFrame
- type ValueColor3
- type ValueColorSequence
- type ValueColorSequenceKeypoint
- type ValueDictionary
- type ValueDouble
- type ValueFloat
- type ValueNumberRange
- type ValueNumberSequence
- type ValueNumberSequenceKeypoint
- type ValueRect
- type ValueString
- type ValueUDim
- type ValueUDim2
- type ValueVector2
- type ValueVector3
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
Value ValueDictionary
}
Model is a low-level model of Roblox's instance attribute format.
func (*Model) ReadFrom ¶
ReadFrom decodes bytes from r, setting Value on success.
Example ¶
package main import ( "encoding/base64" "fmt" "strings" "github.com/robloxapi/rbxattr" ) func main() { var data = `AgAAAAQAAABTaXplCgAAAD9kAAAAAAAAP2QAAAAIAAAAUG9zaXRpb24KAACAPs7///8AAIA+zv///w==` r := base64.NewDecoder(base64.StdEncoding, strings.NewReader(data)) var model rbxattr.Model n, _ := model.ReadFrom(r) fmt.Printf("Read %d bytes\n", n) var dict = make(map[string]rbxattr.Value, len(model.Value)) for _, entry := range model.Value { if _, ok := dict[entry.Key]; !ok { dict[entry.Key] = entry.Value } } fmt.Println("Size.X.Scale:", dict["Size"].(*rbxattr.ValueUDim2).X.Scale) fmt.Println("Size.X.Offset:", dict["Size"].(*rbxattr.ValueUDim2).X.Offset) fmt.Println("Size.Y.Scale:", dict["Size"].(*rbxattr.ValueUDim2).Y.Scale) fmt.Println("Size.Y.Offset:", dict["Size"].(*rbxattr.ValueUDim2).Y.Offset) fmt.Println("Position.X.Scale:", dict["Position"].(*rbxattr.ValueUDim2).X.Scale) fmt.Println("Position.X.Offset:", dict["Position"].(*rbxattr.ValueUDim2).X.Offset) fmt.Println("Position.Y.Scale:", dict["Position"].(*rbxattr.ValueUDim2).Y.Scale) fmt.Println("Position.Y.Offset:", dict["Position"].(*rbxattr.ValueUDim2).Y.Offset) }
Output: Read 58 bytes Size.X.Scale: 0.5 Size.X.Offset: 100 Size.Y.Scale: 0.5 Size.Y.Offset: 100 Position.X.Scale: 0.25 Position.X.Offset: -50 Position.Y.Scale: 0.25 Position.Y.Offset: -50
func (*Model) WriteTo ¶
WriteTo encodes Value into bytes written to w.
Example ¶
package main import ( "bytes" "encoding/base64" "fmt" "github.com/robloxapi/rbxattr" ) func main() { model := rbxattr.Model{ Value: rbxattr.ValueDictionary{ {Key: "Size", Value: &rbxattr.ValueUDim2{ X: rbxattr.ValueUDim{Scale: 0.5, Offset: 100}, Y: rbxattr.ValueUDim{Scale: 0.5, Offset: 100}, }}, {Key: "Position", Value: &rbxattr.ValueUDim2{ X: rbxattr.ValueUDim{Scale: 0.25, Offset: -50}, Y: rbxattr.ValueUDim{Scale: 0.25, Offset: -50}, }}, }, } var w bytes.Buffer bw := base64.NewEncoder(base64.StdEncoding, &w) n, _ := model.WriteTo(bw) fmt.Printf("Wrote %d bytes\n", n) bw.Close() fmt.Println(w.String()) }
Output: Wrote 58 bytes AgAAAAQAAABTaXplCgAAAD9kAAAAAAAAP2QAAAAIAAAAUG9zaXRpb24KAACAPs7///8AAIA+zv///w==
type Type ¶
type Type byte
Type identifies an attribute type within an encoding.
const ( TypeString Type = 0x02 TypeBool Type = 0x03 TypeFloat Type = 0x05 TypeDouble Type = 0x06 TypeUDim Type = 0x09 TypeUDim2 Type = 0x0A TypeBrickColor Type = 0x0E TypeColor3 Type = 0x0F TypeVector2 Type = 0x10 TypeVector3 Type = 0x11 TypeCFrame Type = 0x14 TypeNumberSequence Type = 0x17 TypeColorSequence Type = 0x19 TypeNumberRange Type = 0x1B TypeRect Type = 0x1C )
type Value ¶
type Value interface { Type() Type ReadFrom(r io.Reader) (n int64, err error) WriteTo(w io.Writer) (n int64, err error) }
Value is an attribute value that can be decoded from and encoded to bytes, with an identifying type.
type ValueBrickColor ¶
type ValueBrickColor uint32
func (*ValueBrickColor) ReadFrom ¶
func (v *ValueBrickColor) ReadFrom(r io.Reader) (n int64, err error)
func (ValueBrickColor) Type ¶
func (ValueBrickColor) Type() Type
type ValueCFrame ¶ added in v0.2.0
type ValueCFrame struct { Position ValueVector3 Rotation [9]float32 }
func (*ValueCFrame) ReadFrom ¶ added in v0.2.0
func (v *ValueCFrame) ReadFrom(r io.Reader) (n int64, err error)
func (ValueCFrame) Type ¶ added in v0.2.0
func (ValueCFrame) Type() Type
type ValueColor3 ¶
func (ValueColor3) Type ¶
func (ValueColor3) Type() Type
type ValueColorSequence ¶
type ValueColorSequence []ValueColorSequenceKeypoint
func (*ValueColorSequence) ReadFrom ¶
func (v *ValueColorSequence) ReadFrom(r io.Reader) (n int64, err error)
func (ValueColorSequence) Type ¶
func (ValueColorSequence) Type() Type
type ValueColorSequenceKeypoint ¶
type ValueColorSequenceKeypoint struct { Envelope float32 Time float32 Value ValueColor3 }
type ValueDictionary ¶
type ValueDictionary []Entry
type ValueDouble ¶
type ValueDouble float64
func (ValueDouble) Type ¶
func (ValueDouble) Type() Type
type ValueNumberRange ¶
func (*ValueNumberRange) ReadFrom ¶
func (v *ValueNumberRange) ReadFrom(r io.Reader) (n int64, err error)
func (ValueNumberRange) Type ¶
func (ValueNumberRange) Type() Type
type ValueNumberSequence ¶
type ValueNumberSequence []ValueNumberSequenceKeypoint
func (*ValueNumberSequence) ReadFrom ¶
func (v *ValueNumberSequence) ReadFrom(r io.Reader) (n int64, err error)
func (ValueNumberSequence) Type ¶
func (ValueNumberSequence) Type() Type
type ValueNumberSequenceKeypoint ¶
type ValueRect ¶
type ValueRect struct { Min ValueVector2 Max ValueVector2 }
type ValueUDim2 ¶
func (ValueUDim2) Type ¶
func (ValueUDim2) Type() Type
type ValueVector2 ¶
func (ValueVector2) Type ¶
func (ValueVector2) Type() Type
type ValueVector3 ¶
func (ValueVector3) Type ¶
func (ValueVector3) Type() Type
Click to show internal directories.
Click to hide internal directories.