func (s *StringCodeGenerator) ToolChange(t int) {
	if s.Tool == t {
		if s.Lines[len(s.Lines)-1] == fmt.Sprintf("T%d", t) {
			s.Lines[len(s.Lines)-1] = fmt.Sprintf("M6 T%d", t)
		} else {
			s.put("M6")
		}
	} else {
		s.put(fmt.Sprintf("M6 T%d", t))
		s.Tool = t
	}
	s.ForceModeWrite = true
}
Adds a toolchange operation (M6 Tn).
package export
import "github.com/kennylevinsen/gocnc/vm"
import "fmt"
import "strings"
type StringCodeGenerator struct {
	BaseGenerator
	Precision      int
	Lines          []string
	Tool           int
	ForceModeWrite bool
}
func (s *StringCodeGenerator) Init() {
	s.Position = vm.Position{State: vm.NewState()}
	s.Lines = []string{"(Exported by gocnc)", "G21G90\n"}
}
func (s *StringCodeGenerator) put(x string) {
	s.Lines = append(s.Lines, x)
}
func (s *StringCodeGenerator) Retrieve() string {
	return strings.Join(s.Lines, "\n")
}