IfEx command help

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Locked
DantesGame
Posts: 31
Joined: Sun Jun 08, 2008 1:15 pm

IfEx command help

Post by DantesGame »

Hi, all.

I was trying to write a simple set of statements using IfEx to set some variables but I'm having really inconsistent results. Sometimes the statements work, other times they don't. I'll attach the sample code below but the basic situation is I want to click a single button to randomly generate 8 numbers (that works just fine now) and based on what some of those numbers are, assign values to other text fields. Here's the code:

Code: Select all

IfEx "[NPC_Details.NPCs.STR] <= 14"
  SetVar "[NPC_Details.NPCs.DmgBns1]" "0"
  SetVar "[NPC_Details.NPCs.DmgBns2]" "0"
  SetVar "[NPC_Details.NPCs.DmgBns3]" "0"
Else
IfEx "[NPC_Details.NPCs.STR] = 15 OR [NPC_Details.NPCs.STR] = 16"
  SetVar "[NPC_Details.NPCs.DmgBns1]" "1"
  SetVar "[NPC_Details.NPCs.DmgBns2]" "1"
  SetVar "[NPC_Details.NPCs.DmgBns3]" "1"
Else
IfEx "[NPC_Details.NPCs.STR] = 17"
  SetVar "[NPC_Details.NPCs.DmgBns1]" "2"
  SetVar "[NPC_Details.NPCs.DmgBns2]" "2"
  SetVar "[NPC_Details.NPCs.DmgBns3]" "2"
Else
IfEx "[NPC_Details.NPCs.STR] = 18"
  SetVar "[NPC_Details.NPCs.DmgBns1]" "3"
  SetVar "[NPC_Details.NPCs.DmgBns2]" "3"
  SetVar "[NPC_Details.NPCs.DmgBns3]" "3"
EndIf

IfEx "[NPC_Details.NPCs.DEX] <= 14"
  SetVar "[NPC_Details.NPCs.ToHit1]" "0"
  SetVar "[NPC_Details.NPCs.ToHit2]" "0"
  SetVar "[NPC_Details.NPCs.ToHit3]" "0"
Else
IfEx "[NPC_Details.NPCs.DEX] = 15 OR [NPC_Details.NPCs.DEX] = 16"
  SetVar "[NPC_Details.NPCs.ToHit1]" "5"
  SetVar "[NPC_Details.NPCs.ToHit2]" "5"
  SetVar "[NPC_Details.NPCs.ToHit3]" "5"
Else
IfEx "[NPC_Details.NPCs.DEX] = 17"
  SetVar "[NPC_Details.NPCs.ToHit1]" "10"
  SetVar "[NPC_Details.NPCs.ToHit2]" "10"
  SetVar "[NPC_Details.NPCs.ToHit3]" "10"
Else
IfEx "[NPC_Details.NPCs.DEX] = 18"
  SetVar "[NPC_Details.NPCs.ToHit1]" "15"
  SetVar "[NPC_Details.NPCs.ToHit2]" "15"
  SetVar "[NPC_Details.NPCs.ToHit3]" "15"
EndIf
I get the feeling it has to do with clearing or not clearing the SetVar each time I click the Stats button but I'm not sure and need to step away from this as I've been repeating the same steps now trying to resolve it with no progress. Any advice would be appreciated.
JnCon
Posts: 7
Joined: Tue Sep 20, 2016 8:38 am

Re: IfEx command help

Post by JnCon »

Try to close each "IfEx" condition with "EndIf":

Code: Select all

IfEx "[NPC_Details.NPCs.STR] <= 14"
  SetVar "[NPC_Details.NPCs.DmgBns1]" "0"
  SetVar "[NPC_Details.NPCs.DmgBns2]" "0"
  SetVar "[NPC_Details.NPCs.DmgBns3]" "0"
   Else
    IfEx "[NPC_Details.NPCs.STR] = 15 OR [NPC_Details.NPCs.STR] = 16"
     SetVar "[NPC_Details.NPCs.DmgBns1]" "1"
     SetVar "[NPC_Details.NPCs.DmgBns2]" "1"
     SetVar "[NPC_Details.NPCs.DmgBns3]" "1"
      Else
       IfEx "[NPC_Details.NPCs.STR] = 17"
        SetVar "[NPC_Details.NPCs.DmgBns1]" "2"
        SetVar "[NPC_Details.NPCs.DmgBns2]" "2"
        SetVar "[NPC_Details.NPCs.DmgBns3]" "2"
          Else
            IfEx "[NPC_Details.NPCs.STR] = 18"
             SetVar "[NPC_Details.NPCs.DmgBns1]" "3"
             SetVar "[NPC_Details.NPCs.DmgBns2]" "3"
             SetVar "[NPC_Details.NPCs.DmgBns3]" "3"
            EndIf
       EndIf
   EndIf
EndIf

IfEx "[NPC_Details.NPCs.DEX] <= 14"
  SetVar "[NPC_Details.NPCs.ToHit1]" "0"
  SetVar "[NPC_Details.NPCs.ToHit2]" "0"
  SetVar "[NPC_Details.NPCs.ToHit3]" "0"
   Else
    IfEx "[NPC_Details.NPCs.DEX] = 15 OR [NPC_Details.NPCs.DEX] = 16"
     SetVar "[NPC_Details.NPCs.ToHit1]" "5"
     SetVar "[NPC_Details.NPCs.ToHit2]" "5"
     SetVar "[NPC_Details.NPCs.ToHit3]" "5"
      Else
       IfEx "[NPC_Details.NPCs.DEX] = 17"
        SetVar "[NPC_Details.NPCs.ToHit1]" "10"
        SetVar "[NPC_Details.NPCs.ToHit2]" "10"
        SetVar "[NPC_Details.NPCs.ToHit3]" "10"
         Else
          IfEx "[NPC_Details.NPCs.DEX] = 18"
           SetVar "[NPC_Details.NPCs.ToHit1]" "15"
           SetVar "[NPC_Details.NPCs.ToHit2]" "15"
           SetVar "[NPC_Details.NPCs.ToHit3]" "15"
          EndIf
       EndIf
   EndIf
EndIf
DantesGame
Posts: 31
Joined: Sun Jun 08, 2008 1:15 pm

Re: IfEx command help

Post by DantesGame »

That's beautiful. That totally did the trick and in retrospect makes so much sense. Thank you for offering your eyes to have a look. It's much appreciated.

-Efrem
Locked