[RESOLVED] Problem with *if and *elseif

Read the section “Fake bugs in Quicktest” for the reason CoG will often make you use *else in your choices. The short version is, it keeps the game from crashing if you’ve overlooked something – for example,

*if strength > 50
  *goto strong
*if strength < 50
  *goto wimpy

runs into problems if strength = 50 (and plenty of people who come asking for coding help have overlooked something along these lines).

As you clearly know from your example, you could tweak the code to fix that one without using *else:

*if strength > 50
  *goto strong
*if strength <= 50
  *goto wimpy

But that wouldn’t (I think?) pass Quicktest, which would insist on:

*if strength > 50
  *goto strong
*else
  *goto wimpy

And CoG won’t accept a game that doesn’t pass Quicktest.

Edit: and note that in your example, using elseif allows you to drop a whole lot of conditions and parentheses:

*choice
  #Do a basic attack
    *goto attack
  #Power attack
    *if str<3
      *goto gruesome_death_scene
    *elseif str<=10
      Ha that tickles!!!!
      *goto round2
    *elseif str<=20
      Ow! That hurt!!!
      *goto round2_1
    *else
      Fatality!!!!!
      *set ogredead true
      *goto final_scene
1 Like