I found a error but cant figure out the cause

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.")
}

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.")
}

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums