vmf

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: Unlicense Imports: 3 Imported by: 13

README

GoDoc Go report card Build Status

vmf

Golang library for manipulating hammer Editor .vmf map files

This library constructs a simple node tree that you can query any structure(s) and any property(s) of.

Usage
package main

import (
    "fmt"
    "github.com/galaco/vmf"
)

func main() {
	file,_ := os.Open("de_dust2.vmf")

	reader := vmf.NewReader(file)
	f,_ := reader.Read()

	fmt.Println(f.Entities.GetChildrenByKey("entity")[0].GetProperty("classname"))
	fmt.Println(f.Entities.GetChildrenByKey("entity")[0].GetChildrenByKey("solid"))
}

Documentation

Index

Constants

View Source
const CHAR_DISCARD_CUTSET = "{} \r\n"
View Source
const CHAR_ENTER_SCOPE = "{"
View Source
const CHAR_ESCAPE = "\""
View Source
const CHAR_EXIT_SCOPE = "}"
View Source
const NODE_KEY_ROOT = "$root"
View Source
const NODE_TYPE_CAMERAS = "cameras"
View Source
const NODE_TYPE_CORDON = "cordon"
View Source
const NODE_TYPE_CORDONS = "cordons"
View Source
const NODE_TYPE_ENTITY = "entity"
View Source
const NODE_TYPE_VERSIONINFO = "versioninfo"
View Source
const NODE_TYPE_VIEWSETTINGS = "viewsettings"
View Source
const NODE_TYPE_VISGROUPS = "visgroups"
View Source
const NODE_TYPE_WORLD = "world"

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

A KeyValue object, that may hold multiple Values

func (*Node) GetAllValues

func (node *Node) GetAllValues() *[]interface{}

Get all node values

func (*Node) GetChildrenByKey

func (node *Node) GetChildrenByKey(name string) (children []Node)

Return all children of a given type for a node. This is different from properties, as a property is a string:string

func (*Node) GetKey

func (node *Node) GetKey() *string

Get node key

func (*Node) GetProperty

func (node *Node) GetProperty(name string) string

Return the value of a property from its name Note: A property is a string:string, not a string:[]Node

func (*Node) HasProperty

func (node *Node) HasProperty(name string) bool

Check if Node has a property defined

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(file io.Reader) Reader

Return a new Vmf Reader

func (*Reader) Read

func (reader *Reader) Read() (vmf Vmf, err error)

Read buffer file into our defined structures Returns a fully mapped Vmf structure

type Vmf

type Vmf struct {
	VersionInfo  Node
	ViewSettings Node
	VisGroup     Node
	World        Node
	Entities     Node
	Cameras      Node
	Cordon       Node // Pre-L4D only
	Cordons      Node // Post-L4D only
	Unclassified Node
}

Jump to

Keyboard shortcuts

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