Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-07-2010, 06:37 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Cubical View Post
Is it possible to do something like
PHP Code:
  switch(blah){
    case 
"blah" "blah"//if either are true then proceed
      
doStuff();
      break;
    default case 
"blah"//if either are true then proceed
      
doStuff();
      break;
  } 
You can do that like this..

PHP Code:
  switch(blah){
    case 
"blah": case "blah2":
      
doStuff();
      break;
    case 
"blah3": default:
      
doStuff();
      break;
  } 
Drops read-ability quite a bit imo though.
__________________
Quote:
  #2  
Old 10-07-2010, 06:45 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by fowlplay4 View Post
You can do that like this..

PHP Code:
  switch(blah){
    case 
"blah": case "blah2":
      
doStuff();
      break;
    case 
"blah3": default:
      
doStuff();
      break;
  } 
Drops read-ability quite a bit imo though.
It was mainly just for my curiosity because I don't even have Graal installed right now. I was wondering for something along the lines of this.
PHP Code:
switch(cmd){
  case 
"command1":
    break;
  case 
"command2":
    break;
  case 
"help": default:  // if help or no params are given then continue
    
sendtorc("commandlist");
    break;

  #3  
Old 10-07-2010, 08:02 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Cubical View Post
It was mainly just for my curiosity because I don't even have Graal installed right now. I was wondering for something along the lines of this.
PHP Code:
switch(cmd){
  case 
"command1":
    break;
  case 
"command2":
    break;
  case 
"help": default:  // if help or no params are given then continue
    
sendtorc("commandlist");
    break;

Best way is to do it like this, as suggested in original post:

PHP Code:
switch (cmd) {
  case 
"command1":
  case 
"command2":
    
dostuff;
  break;
  
  default:
    
domorestuff;

either command1 or command2 will activate "dostuff;" and doesn't really hurt readability.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.