Beispiel #1
0
Datei: lua.go Projekt: vron/fm
func readInput(l *lua.State) {
	bstdin := bufio.NewReader(os.Stdin)
	for {
		var line string
		// TODO: Something better for windows?
		line, e := bstdin.ReadString('\n')
		if e != nil {
			shell.Println(e)
		}
		er := l.LoadString(line)
		if er != 0 {
			// Pop of the error description
			str := l.ToString(-1)
			shell.Println("Error loading: ", str)
			continue
		}
		er = l.PCall(0, lua.LUA_MULTRET, 0)
		if er != 0 {
			str := l.ToString(-1)
			shell.Println("Error running: ", str)
			continue
		}
		sesLog.Println(line)
	}
}