Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultParamSpecificationCallback ¶
func DefaultParamSpecificationCallback(specs []*ParamSpecification) map[string]string
DefaultParamSpecificationCallback is a convenience function that simply returns the default values in the provided map. This permits users of this lib from providing support for paramaterization of lua scripts at the cost of always having those scripts that do require params to always use their defaul value
Types ¶
type ParamSpecification ¶
type ParamSpecification struct { Name string `json:"name"` Default string `json:"default"` Options []string `json:"options"` }
ParamSpecification specifies a parameter a lua script requires
func NewParamSpecification ¶
func NewParamSpecification() *ParamSpecification
NewParamSpecification does what it says on the tin
type ParamSpecificationRequestCallback ¶
type ParamSpecificationRequestCallback func([]*ParamSpecification) map[string]string
ParamSpecificationRequestCallback is a function that will be called by tablib to allow the main program to supply params needed for a lua function
type SearchResult ¶
SearchResult holds information about each object discovered during a search
type TableRepository ¶
type TableRepository interface { //AddLuaScript stores the given lua script in the repository. //The script name and the script string itself are mandatory. AddLuaScript(scriptName string, luaScript string) error //AddTable stores the given yaml representation of a table in the repository. // //If the presented yaml is not parsable or has other structural issues, an error is raised. //Errors and warnings related to the semantics of the table (e.g. internal consistency //issues or table syntax errors) are captured in the returned ValidationResult AddTable(yamlBytes []byte) (*validate.ValidationResult, error) //Execute executes the named Lua script and returns a map of named output keys and their values. // //The nature of the output is arbitrary and is defined by the Lua script, but typically //the returned map contains name/value pairs where the name represents some meaningful //table roll and the value is the results from that table roll. The map may contain any other //information the script wishes to communicate to the client, like a synthesized or concatenated //result of several tables rolls that have been assembled in the script to produce an overall //meaningful result. If an error occurs in script execution, error information will be returned //in the map in place of the intended result(s). // //The callback function is optional. If used, it will be called if the Lua script requests //parameters from the caller. If set to nil, the Lua script will be returned the default //value of each parameter. For more information on the format of Lua scripts and the //use of the callback, see the README documentation. Execute(scriptName string, callback ParamSpecificationRequestCallback) map[string]string //EvaluateDiceExpression revaluates a dice expression and returns the result or //an an error f the expression is not valid. EvaluateDiceExpression(diceExpr string) (int, error) //List provides the raw string listing of the named table or script. // //An error is returned if the named item does not exist or if itemType is anything //other than "table" or "script" List(name string, itemType string) (string, error) //The table type must be flat; providing the name of a ranged table will generate //an error Pick(tableName string, count int) *tableresult.TableResult //Roll 'rolls' on the named table count times, generating a single result with each roll Roll(tableName string, count int) *tableresult.TableResult //To obtain the entire contents of the repository, call Search("", nil). //To filter by tags only, call Search ("", []string{"tag1", "tag2"}). This will //return all items in the repo that have at least one of these tags defined. //To filter by name only, call Search("myregex", nil). This will return all items //that match the given regex. Provide both parameters for a narrow search. Note //that in this case, the results are filtered first by tag and then by name. Search(namePredicate string, tags []string) ([]*SearchResult, error) //Tags returns an alphabetized list of all tags used by any table or script Tags() []string }
TableRepository holds the various tables and Lua scripts and manages their execution
func NewTableRepository ¶
func NewTableRepository() TableRepository
NewTableRepository does what it says on the tin