datapack

package
v0.0.0-...-382259f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2021 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Overview

Package datapack allows users to extend Gophercraft with ease. It describes a simple format for loading data into Gophercraft and compatible clients Planned formats include:

Lua scripts
3d objects/textures
Map geometry
Sound files
files for patching the server and client databases

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound = fmt.Errorf("datapack: file not found")
)

Functions

func RegisterDriver

func RegisterDriver(key string, value func() Driver)

func Timestamp

func Timestamp() string

Types

type Driver

type Driver interface {
	Init(at string) (Opts, error)
	ReadFile(at string) (File, error)
	WriteFile(at string) (WriteFile, error)
	List() []string
	Close() error
}

Driver describes a mechanism for loading a datapack.

type File

type File io.ReadCloser

type Loader

type Loader struct {
	Volumes []*Pack
}

func Open

func Open(directory string) (*Loader, error)

func (*Loader) Close

func (ld *Loader) Close()

func (*Loader) Exists

func (ld *Loader) Exists(path string) bool

func (*Loader) List

func (ld *Loader) List() []string

func (*Loader) ReadAll

func (ld *Loader) ReadAll(path string, slicePtr interface{}) int

func (*Loader) ReadFile

func (ld *Loader) ReadFile(path string) (io.ReadCloser, error)

type Opts

type Opts uint64
const (
	Read Opts = 1 << iota
	Write
)
const None Opts = 0

type Pack

type Pack struct {
	PackConfig
	Opts
	Driver
}

func Author

func Author(cfg PackConfig) (*Pack, error)

func OpenPack

func OpenPack(path string) (*Pack, error)

func (*Pack) Delete

func (p *Pack) Delete() error

func (*Pack) Exists

func (p *Pack) Exists(path string) bool

func (*Pack) ReadBytes

func (p *Pack) ReadBytes(path string) ([]byte, error)

func (*Pack) WriteBytes

func (p *Pack) WriteBytes(path string, data []byte) error

func (*Pack) ZipToFile

func (p *Pack) ZipToFile(filename string) error

type PackConfig

type PackConfig struct {
	Name          string
	Description   string
	Author        string
	Version       string
	Depends       []string
	ServerScripts []string
	ClientScripts []string
}

type WriteFile

type WriteFile io.WriteCloser

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL