How to do 100 If and one Else?

I am facing the following problem. I need to make a very large number of test conditions (100). But after 20-30 additions in the block, it is extremely problematic to do it. There just isn’t enough screen size. Then I just split these conditions into several blocks. But the problem is that then the block does something with errors. In particular, if I do Else after each If block, then this leads to incorrect calculations. And if I leave only one Else at the end of this If group, then the If rules are correctly executed only for this block, and those If blocks that go above are not executed as intended.

So how can I make one huge If block with one Else? Or how can I split it into several small ones so that they all correctly perceive the one Else coming at the end?

Thanks in advance for your reply.

post your blocks I will try to help you!

I was only able to insert a part, since the forum does not allow that huge piece to be uploaded here. But there are several such parts.

What’s the text.text and global text?
Looks like you are showing different dialoag according to different choose.

here is what I did:

  1. orgnize the data like this

  2. change the data to csv table

  3. make the blocks like this:



Text.csv are character phrases formatted as:
“Text2”, and so on.

There are 1961 lines of text. This is all transferred to the global variable text. Then the characters start talking. When we come to a phrase with the desired index (for example, 1788 and so on), the player is asked to make a choice. A notification pops up. If he/she chooses one variant of the event, then we jump to 1800, and if another, then 1820 (for example).

The problem is I need to add many If’s in one block with Else. Then everything works right. And if these are 3 If blocks and 1 If block with Else, then the first 3 blocks work, that is, there are some problems with notifications. And if we do Else for each of the blocks, then we get wrong phrases.

From your text.csv, we don’t know where to jump to

All of these “jumps” are organized in a different way (I am attaching a screenshot). And the problem isn’t jumping. The problem is precisely that I want to add a large number of similar conditions, but I simply do not have enough space on the screen.

this is wrong. Reorganize your data as i said.

That is, is there no way to add more than 20-30 if in one block?

I think its possible, BUT, you app will get more and more slow every time you do this, remember that the device will have to process ALL of these If and else If.


Oh, I see. At the moment, I have quite a few if blocks following each other. During testing, I don’t see that my application is slowing down. But thanks for paying attention to this.

If someone knows how you can add a lot if in one block, then feel free to write.

1 Like

it is not recommended to do this…
DRY - Don’t repeat yourself…

and follow the suggestion from @Kevinkun


Thank you all very much for your answers. I ended up just moving those long conditional blocks into multiple procedures and creating the following conditions:

Since I am satisfied with the speed of the application, I did not change the structure of this application. But in the future, I will definitely make it easier and more effective. I will use @Kevinkun 's advice and if I have any questions related to his advice, I will create a separate topic.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.