handle no script being passed

This commit is contained in:
filifa 2024-09-02 22:49:29 -05:00
parent 87394e7263
commit ee984f7d72
1 changed files with 6 additions and 7 deletions

View File

@ -50,10 +50,6 @@ type script struct {
}
func (m *milkDropWindow) loadScript(scriptPath string) error {
if scriptPath == "" {
return errors.New("no script given")
}
f, err := os.Open(scriptPath)
if err != nil {
return err
@ -92,11 +88,14 @@ func (m *milkDropWindow) prevPreset() {
func newMilkDropWindow(width, height int32, scriptPath string) (*milkDropWindow, error) {
var m milkDropWindow
var err error
err := m.loadScript(scriptPath)
if scriptPath != "" {
err = m.loadScript(scriptPath)
if err != nil {
return nil, err
}
}
m.window, err = sdl.CreateWindow("milkbucket", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, width, height, sdl.WINDOW_OPENGL|sdl.WINDOW_RESIZABLE)
if err != nil {