If.. Else..

by Nepthysia

Back to Mechanic's Corner.

Nepthysia2006-11-12 22:43:56
So I decided to get off my butt and work on some systemish stuff and decided to tackle astrology to make it well.. easier for me to use I suppose. Right now I have it pretty well laid out where if I bring up the targets nativity it sets two sets of variables according to the signs that person was born under. Buuut theres a problem cause it sets everything to cardinal signs..

CODE

#if (%1 = Volcano or Dolphin or Burning or Skull) {
  #var moon cardinal
  #var moonstar hallucinations
  } {
  #if (%1 = Antlers or Lion or Spider or Bumblebee) {
    #var moon fixed
    #var moonstar dizziness
    } {
    #if (%1 = Twin or Crocodile or Dragon or Glacier) {
      #var moon mutable
      #var moonstar dementia
      }
    }
  }


I went looking for an if else type thing but couldn't find anything - I *know* theres something to use for it but just can't recall what the heck it is. right now its set up as if (this) {then} {else if (this) {then} {else if (this) {then}}} and not working cause it doesn't filter down, it just goes, ah screw it, theyre all true! sleep.gif

Feel free to dis my coding abilities all you like. Theres a reason why I stopped being a comp sci major tongue.gif
Laysus2006-11-12 22:49:14
what I'd do for that is #if (%ismember(%1,"Volcano|Dolphin|Burning|Skull") rather than the long set of ors.

If you want, I'll also see if I can dig up my old astrology stuff.
Nepthysia2006-11-12 22:55:39
or and | are exactly the same but I used the ors for now simply cause its 'lamen terms' when Im staring at a huge list of this stuff tongue.gif

Would love that heh


Edit:
QUOTE

zMUD does not have any equivalent to the elseif construct in C. Instead, nesting #IF commands is done like this:

#IF (expression1) {true-command} {#IF (expression2) {true2-command} {false-command}}


well crud... -sway-
Nepthysia2006-11-12 23:26:42
Okay tried to %ismember thing! Thaaaank you Laysus *gives freshly baked brownie* wub.gif

CODE

ex-Initializing nativity evaluation...
==============================================================
Nativity Evaluation for: eruttu
==============================================================
Sun was at Dolphin and will cause cold damage
Moon was under a cardinal sign and will cast hallucinations
Eroee was under a mutable sign and will cast love
Sidiak was under a mutable sign and will cast confusion
Aapek was under a cardinal sign and will cast aeon
Papaxi was under a cardinal sign and will cast ego
Tarox was under a fixed sign and will cast asthma
==============================================================

Drathys2006-11-13 01:23:35
If you wanted to use your original format, you would have to explicitly state each condition.

CODE
#if (%1 = a or %1 = b or %1 = c) {dothis} {elsedothat}

This is because what it is really doing is:
CODE
if ( = true) or ( = true) or ( = true)

In other words, it evaluates each term separately, and checks if they are true.

Since you did not specify what to compare the second and third terms with, it was doing this:
CODE
if ( = true) or ( = true) or ( = true)

Since most constants evaluate as true, the second and third terms will always be true. As you are using OR, this makes the entire statement true.
Nepthysia2006-11-13 01:39:16
*nod nod* All fixed now however and workin beautifully biggrin.gif