Jump to content

Multiple if statements?


ooblikai

Recommended Posts

Is there a way to set multiple if statements? Because I cannot figure out how to do it. I'm trying to do multiple if ref.GetDead == 1 's to set a quest stage. It works with one, but I cant get any more than that. thanks.
Link to comment
Share on other sites

Is there a way to set multiple if statements? Because I cannot figure out how to do it. I'm trying to do multiple if ref.GetDead == 1 's to set a quest stage. It works with one, but I cant get any more than that. thanks.

 

If

if var1 == x && var2 == y

nor

if var1 == x AND var2 == y

work, try this:

if var1 == x 
   if var2 == y
       do stuff here
   endif
endif

 

Hope this helps.

 

Edit:

While this post is in its simplicity quite embarrassing, I'm going to leave it here nevertheless. The post below explains everything much better.

Link to comment
Share on other sites

Depends on what you are trying to do. Inclusivel or exclusively

 

If you want to check to see if all refs are dead then

 

if ref1.GetDead == 1 && ref2.GetDead == 1 && ref3.GetDead == 1 ; etc

do something here

endif

 

If you want to do something is any ref is dead then

 

if ref1.GetDead == 1 || ref2.GetDead ==1 || ref3.GetDead ==1 ; etc

do something here

endif

 

If you want to check the next ref if the first ref is not dead for example then you can else it

 

if ref1.GetDead == 1

do something here

elseif ref2.GetDead == 1

do something here

elseif ref3.GetDead == 1

do something here

else ; if you want a default action when no refs are dead, the else is optional

do default action here

endif

 

As highlighted above, you can nest ifs

 

ultimately if you have a bunch of checks and you want them all to run then

if ref1.GetDead == 1

do something here

endif

 

if ref2.GetDead == 1

do something here

endif

 

etc.

 

Regards

Ric36

Link to comment
Share on other sites

One point: It is unnecessary to write ==1 in these cases. It is redundant in getdead because it is an either/or situation, not an item count. So If you want your quest to advance a stage after 3 NPCs are dead, for instance, then you could write:

 

Begin Gamemode
    if Tom.GetDead && Richard.GetDead && Harry.GetDead
         SetStage MyQuest 30
    endif
End

 

It would have the same effect as writing GetDead == 1 each time. The 1 is implied.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...