I found a error but cant figure out the cause

Atokrad
28 Feb 2021, 00:21

The error is Error running script: Error compiling expression '': SyntaxError: Unexpected end of fileLine: 1, Column: 1

if (ListCount (weapons) > 0) {
ShowMenu ("Pick a weapon to upgrade…", weapons, true) {
    switch () {
      case (Dagger) {
        dagger = Split("Yes;No", ";")
        ShowMenu ("Are you sure?", dagger, true) {
          switch (result) {
            case ("Yes") {
              Dagger.attackbonus = Dagger.attackbonus + (2)
              player.upgradepoints = player.upgradepoints - (1)
            }
            case ("No") {
            }
            default {
              msg ("That was not even an option!")
            }
          }
        }
      }
    }
  }
}
else {
  msg ("You don't have anything you can upgrade.")
}

mrangel
28 Feb 2021, 01:27

I think the error might be in the line switch ().

You need to tell it which variable you are comparing the options to.
In this case, you probably want that to be result, which contains the result from ShowMenu. So you'd want to change the line switch () { to switch (result) {.

Hope that helps.

Also… if you're asking a yes or no question, it may be more efficient to use Ask; making your code look a little simpler. so this example would look like:

if (ListCount (weapons) > 0) {
  ShowMenu ("Pick a weapon to upgrade…", weapons, true) {
    switch (result) {
      case (Dagger) {
        Ask ("Are you sure?") {
          if (result) {
            Dagger.attackbonus = Dagger.attackbonus + 2
            player.upgradepoints = player.upgradepoints - 1
          }
        }
      }
      default {
        msg ("That was not even an option!")
      }
    }
  }
}
else {
  msg ("You don't have anything you can upgrade.")
}