You could add further complexity to produce lists of nouns/adjectives etc, but you’d still have that “list” of configured values. There’s no way around that in raw choicescript.
*return should only be used after using *gosub, which has the same effect as *goto, only it allows you to (and expects you to) *return
Return will return you to the line AFTER the gosub was called, so in my above situation there’s no need for it?
But you could most definitely create a system of sorts that allows you to generate a random word, return the value and then be recalled as many times as you need words.
I use rand often so have found that it is best to place the order highest to lowest or you may run into a problem with it not running correctly so in the above example I would.
*if (breakfast=3)
a bowl of porridge
*return
*elseif (breakfast=2)
smoked mackerel
*return
*else (breakfast=1)
toast and marmalade
*return
I am not a programmer but have found I have a lot less issues with the order in this manner.
I haven’t come across any issues with having the order ascending. The only issues I could potentially see are where you are increasing a variable by +1 each time (not random) and forget to *finish or *return at the end. You’d have results for (example) breakfast = 3 and breakfast = 4 both appearing in your game.
By the way, instead of using *elseifs and *elses, you could just write *if conditions (which don’t have to end in a *goto if there’s no *elseif or *else after them) and just write a *return at the end of the whole subroutine; that’d save some lines.
Very true @AlexCosarca - in ‘The Race’ I used many *elseifs and *elses before discovering that *ifs could be used alone to speed up the coding process. That’s one of the great things about coding - you’re always learning new tricks and shortcuts!
A good example of this that I am using for ‘Blackraven’ is adding conversation parts based on your past choices.
For example, you might make a scene and cry over spilt milk in the canteen early in the game (*set cry_scene true), instead of just shrugging and cleaning it up (*set cry_scene false).
Later, when talking to someone, you could have the code:
You meet Bob, a tall man with dark hair.
*if cry_scene true
__He laughs at you and tells you he remembers when you spilt the milk in the canteen.
__You shake his hand and ask him if he has any cigarettes for sale.
You can add other optional text parts in a similar way that will only become active if you chose that path earlier in the game.
When i would program it descending from 1 to whatever number it would hang and seem to be stuck on one number. It has happen several times in different codes. Once I started counting down highest to lowest never again hit that bug.