gutil

package
v0.0.0-...-fec722e Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2013 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

This file describes general interfaces that game objects should try to take advantage of.

provides some handy lua functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LuaAtPanic

func LuaAtPanic(L *lua.State) int

function that lua will call before aborting. we override this because normally lua longjmps, but that breaks go's defer/panic. so we just panic.

func LuaInit

func LuaInit() *lua.State

TODO: better error handling

func StrToTermboxAttr

func StrToTermboxAttr(str string) termbox.Attribute

Types

type LuaConfig

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

LuaConfig conveniently wraps a lua file as a go map, and config elements can be accesses through Get().

func NewLuaConfig

func NewLuaConfig(lua *lua.State, file string) (*LuaConfig, error)

Construct a new LuaConfig given the lua state and file name. Returns *LuaConfig, nil on success and nil, error on error. Expects that the file provided is a lua script that will return a table of strings to values, for example:

config = {
  key = "value",
  boolean = false,
}

return config

func (*LuaConfig) Chan

func (lc *LuaConfig) Chan() <-chan LuaConfigElement

Gives a channel which will contain top-level config elements

func (*LuaConfig) Get

func (lc *LuaConfig) Get(key string, expected reflect.Kind) (res interface{}, err error)

Get will walk the config for key, and assert that its value is of Kind expected. Returns value, nil on success and nil, error on error. Get will accept keys like "table.subtable.key", and will walk tables until it finds the last element in the key, or abort on error.

type LuaConfigElement

type LuaConfigElement struct {
	Key   string
	Value interface{}
}

type Updater

type Updater interface {
	Update(delta time.Duration)
}

Jump to

Keyboard shortcuts

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