Example #1
0
File: ui.go Project: kdar/morphgen
func LonBonusChange(L *lua.State) int {
	v := luar.CopyTableToMap(L, nil, 1).(map[string]interface{})

	buffer := &bytes.Buffer{}

	generator.Bonus(bonusTextValue(v["text"].(string)))
	generator.Output(buffer)

	args := []interface{}{buffer.String(), nil}
	addCallback(L, "onBonusChange_callback", args)
	return 0
}
Example #2
0
File: ui.go Project: kdar/morphgen
// A lua function wrapper to Generate().
func Lgenerate(L *lua.State) int {
	v := luar.CopyTableToMap(L, nil, 1).(map[string]interface{})
	v["bonus"] = bonusTextValue(v["bonustext"].(string))

	go func() {
		buffer := &bytes.Buffer{}
		err := generator.Generate(v, buffer)

		args := []interface{}{buffer.String(), err}
		addCallback(L, "generate_callback", args)
	}()
	return 0
}