Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
SethRizzen
Beginner


Joined: 07 Apr 2003
Posts: 15
Location: USA

PostPosted: Thu Jul 22, 2004 6:54 pm   

Spellup Database?? Or easier way to to a script.
 
Hiya all,

I'm working on a spellup script for my new favorite mud. It has all kinds of class spells, racial spells, skills, etc. I'm trying to make it as simple as possible (leads to less errors) and make it more readable.

My problem really lies in nest if's. I've got about 10 classes and 10 races, each with thier own spells. My script is starting to look pretty ugly. All I wish I could do was just say:

Code:

switch (@race)
{
 "Human": @spells = NULL;break;
 "Dragon": @spells = @dragonspells;break;
 (etc)
}
switch (@class)
{
 "Class1" : @spells = @class1;break;
 "Class2" : @spells = @class2;break;
  (etc)
}


Although not everything is easily switch to C/C++ Evil or Very Mad. Right now I'm stuck using the nasty, ugly, and horrible:
Code:

#if (@race = "Human") {#var spells {"Blah"|"Blah2"|"Blah3"}} {
  #if (@race = "Dragon") {#var spells {"Blah"|"Blah2"|"Blah3"}} {
    #if (etc) {etc} {
      etc
      }}}


With the amount of races and classes, it gets pretty big, pretty quick. My question is, can I just make a DB with each race (and subraces) and class for the spells? Or is there a better function/command for this? The link to my script so far is: http://forums.zuggsoft.com/phpbb/viewtopic.php?t=17026

I only have once race listed, but there are 3 "ages" per race, each age having a different name. For example: Human = Teen, Human, Elder. Or Dragon = Hatchling, Dragon, Wyrm.

My modified script has a nested if for each race by age. I'm gonna end up with 3 megs of script by the time i'm done!

Anyways, any help would be appreciated.

-Seth
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jul 22, 2004 8:58 pm   
 
It's only complicated if you complicate it. No character will be more than one race, so there's no need to nest IFs.
#IF (@race = human) {#NOOP You don't even need to check if humans don't have any spells}
#IF (@race = dragon) {#FORALL @dragonspells {#ADDI spells {%i}}}
#IF (@race = elf) (#FORALL @elfspells {#ADDI spells {%i}}}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net