ID:169137
 
If I do this:

mob/verb/BLAH()
if(Blah == 1)
src << "Do this"
else if(Blah == 2)
src << "Do this."
else if(Blah == 3)
src << "Do <I>this</I>."
else
src << "Yays"


If I do that, does it make the final instance ("Yays") occur only if "Blah" is not equal to 1, 2, or 3? or does it do that any time "Blah" is not 1?

What I need is so that it will do it whenever "'Blah' is not equal to 1, 2, or 3", because I'm using it for my combat system, and I don't want a 5000 charactor if() proc for unimplemented spells; and also I want it to catch typoes if I make any. That way if I have
if(spellchoice == "Fireball")
<dm>
but the spell's name is "Firebal", it will come back with the "Not Implemented" message (or the "Yays" message in the example)
Yes, tt will say yays whenever blah ISNT 1=3. You don't have to use all those elses.
mob/verb/BLAH()
if(Blah == 1)
src << "Do this"
if(Blah == 2)
src << "Do this."
if(Blah == 3)
src << "Do <I>this</I>."
else
src << "Yays"
In response to Mecha Destroyer JD
okay. I just wanted to make sure the "else" would apply to all if's and not just the last one
In response to Cowdude
Yeh it shouldn't apply to just one...0_0
In response to Mecha Destroyer JD
else if()'s are fine there. If Blah is 1 it won't be 2 and thus running through the rest of the checks is pointless.
In response to Mecha Destroyer JD
Unfortunatally for me, it does :(

if "Blah" is equal to 1, it will do what's in the final "else" thing also. There are too many spells for me to want to make a long if() proc like that though =/ is there any way I can make it work like I want it?
In response to Cowdude
So you're doing something like a spell book? Try dividing it up or something...I don't know any other way of shortening it in that format...
In response to Mecha Destroyer JD
No, no.

If you've played any Dragon Quest game (or for that matter, almost any game with a turn-based combat system) you'd know how this works.

When in battle, you can go to Attack, Spell, Item, or Run.

If you go to Spell, it brings up either a message saying you don't know any spells, or it lists every class (like Wizard and Sage) that you learned a spell from. There is anywhere from six to fourteen spells per class though, with few repeats among differant classes (one spell is usually only learned by one class, with few exceptions).

This means that in the end, there are (between 18 classes) well over a hundered differant spells.

That's a lot.

Now, I'll have a hundered if() procs eventually for each spell.

Until I have them all though, I need a way to catch it if I typo a spell in the list (like if someone learns "Fireball" (meaning I typo'ed), when in Dragon Warrior the spell is "Firebal" for one reason or another).

but if this is how it works, I'll need a mile-long if/else chain:

if(spell == "Blaze")
src << "Effect!"
else
if(spell == "Firebal")
src << "Effect!"
else
if(spell == "Icebolt")
src << "Effect!"
else
if(spell == "Blazemore!")
src << "Effect!"
else
if(spell == "Firebane")
src << "Effect!"
else
src << "Spell not implemented at this time."
return

Note that this is five spells, not a hundered.
In response to Cowdude
Why not make the spells /datums and them to the player's list, then do something like this:
var/spell/s=pick(player.spells)
if(!s.usable)return
else
for(var/mob/m in oview(1,player))
m.hp-=s.damage

Yatayata, you know the story. =p
In response to Ol' Yeller
1) its turn-based battle--You don't use var/mob/M in oview for that =P

2) here's what I have:

            if(attack == "Spell")
var/list/spelllist = list()
if(src.batspell.len >= 1)
spelllist += "Classless"
if(src.batherospell.len >= 1)
spelllist += "Hero"
if(src.batpilgspell.len >= 1)
spelllist += "Pilgrim"
if(src.batsoldspell.len >= 1)
spelllist += "Soldier"
if(src.batwizaspell.len >= 1)
spelllist += "Wizard"
if(spelllist.len == 0)
src << "You have not learned any battle skills."
spelllist += "Cancel"
attack = input(src,"Use what class of spells or skills?")in spelllist
spelllist -= "Cancel"
if(attack == "Hero")
spelllist = src.batherospell
spelllist += "Cancel"
attack = input(src,"Use which skill?") in spelllist
if(attack == "Soldier")
spelllist = src.batsoldspell
spelllist += "Cancel"
attack = input(src,"Use which skill?") in spelllist
if(attack == "Pilgrim")
spelllist = src.batpilgspell
spelllist += "Cancel"
attack = input(src,"Use which skill?") in spelllist
if(attack == "Wizard")
spelllist = src.batwizaspell
spelllist += "Cancel"
attack = input(src,"Use which skill?") in spelllist
if(attack == "Classless")
spelllist = src.batspell
spelllist += "Cancel"
attack = input(src,"Use which skill?") in spelllist
if(attack == "Cancel")
src.battleprompt(A,B,C,D,E,F,G,H,I,J,K,L)


Each "spelllist" var like "batwizaspell" will have between 6 and 14 spells in it (probably an average of 8 though) so yeah, a good 150 spells. It follows with a series of "if(attack == "Blaze")" things.
In response to Cowdude
Don't, add /datums into the list and call their spell() proc or something, making it so you don't have to use a bajillion if()s.
In response to Ol' Yeller
I'm not sure what you mean by /datum I guess o_O

I'm not complaining about having to do a million if()'s, I just need a way to have a final "else" clause without stacking all the if()'s to catch anything that I don't use in the above if()'s.

Edit: The part at the bottom of the page with the links to all the individual posts looks a little like what my proc will look like if I don't get it working right =P
In response to Ol' Yeller
Although putting the spell effects won't minimize your total code, it can lower how much code is under the switch(?) statement. That way, you just call the procs, if something, but apparently you will still be using ifs.
In response to Cowdude
You know what? that first guy that replied to me was the one that screwed this all up. Shame on him. I DO need to use all the "else if" instead of a bunch of "if".

mob/verb/IfTester(var/num as num)
if(num == 1)
src << "1"
else if(num == 2)
src << "2"
else if(num == 3)
src << "3"
else
src << "Not 1, nor 2, nor 3."


I compiled this simple code and ran it. Then I use the verb with "num" as 1, then 2, then 3, then 4, then 6000 something. This is what it outputted:

1
2
3
Not 1, nor 2, nor 3.
Not 1, nor 2, nor 3.

So it'll work with else's. I've fixed it myself, no thanks to the evil person who told me I didn't need "else".

(Btw: I don't mean to offend whoever I'm referring to--heck, I can't even remember who it was that posted that)

EDIT: It was JD who said that. No wonder it doesn't work; he's replied to this so many times he's probably messing me up on purpose. I'm banning him from the game once it's done :'(

(Btw: Ignore everything in that last paragraph except "It was JD who said that.")
In response to Cowdude
mob/verb/IfTester(var/num as num)
if(num == 1)
src << "1"
return
if(num == 2)
src << "2"
return
if(num == 3)
src << "3"
return
else
src << "Not 1, nor 2, nor 3."

Har!
In response to Ol' Yeller
that's about what my stuff looks like when I code something just to test privately =P