Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: switch() problem  (Read 3809 times)

0 Members and 1 Guest are viewing this topic.

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
switch() problem
« on: July 06, 2003, 11:32:16 AM »

Hi again,

it seems there is some little problem with the quite new "switch()" command when using it nested... the game interpreter freezes!  :-\
Example:

Code: [Select]
switch(Command.Verb)
{
  case "Use":
    ran = Random(0,3);
    switch(ran)
    {
      case 0: actor.Talk("That doesn't work!"); break;
      case 1: actor.Talk("That makes no sense at all!"); break;
      case 2: actor.Talk("What ?!"); break;
      case 3: actor.Talk("No! Get serious!"); break;
    }
    break;
}

In that example, the actor talks his sentence and then the game freezes. When using if/else in the case block, it works as expected.

Oh, and another little one: I can't set the default value somewhere else than at the top. I guess this is just "as it is" and correct, but I want to mention it in case this is NOT wanted.

For example:

Code: [Select]
switch(number)
{
  case 1:
    actor.Talk("Number ONE!");
    break;
  case 2:
  default :
    actor.Talk("Oh, TWO again. Seems to be the default value!");
    break;
  case 3:
    actor.Talk("AH! THREE!");
    break;
}

This throws a syntax error on the "case 3:" line. It works without problem by moving the "case 2:/default:" block to the bottom.

Thanks for helping. :)
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:switch() problem
« Reply #1 on: July 06, 2003, 03:28:10 PM »

Whooops! Another well hidden script compiler bug :o Fixed now (hopefully).

As for the default branch, it should be always the last one, it's meant to be that way (although I know it's a different behavior than in JavaScript...).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re:switch() problem
« Reply #2 on: July 06, 2003, 06:23:12 PM »

Whooops! Another well hidden script compiler bug :o Fixed now (hopefully).

That was fast. Again. Thanks. Again. :)

As for the default branch, it should be always the last one, it's meant to be that way (although I know it's a different behavior than in JavaScript...).

Oh yes, that's possible. Actually everything is possible in JavaScript. I was not sure about the "normal" syntax, so at least it's nice to hear, there is NO bug! ;)
Logged
Mooh!
 

Page created in 0.04 seconds with 19 queries.