Legacy GM Commands during dialogue

R

Ryuuhei

Guest
Hello, I come with another question regarding GML coding. I'm sorry for my possibly bad English, I tried my best to describe the problem I face.

I'm currently working on RPG-driven visual novel game, using of course dialogues and choices as a base for the rest game elements.

For the method of dialogue displaying, I used simple array with whole dialogue written beforehand. When triggering some dialogue, the initialization code looks like this:

Code:
global.line[1] = "First line text."
global.line[2] = "Second line text."
global.line[3] = ...
When reading and drawing the dialogue, it simply steps over every letter until it reaches the end of array (set by "END", but I'll talk about this later). If is the current dialogue displayed, player is able to press a key to advance to the next line. Simple, but working code.

Then there comes a problem when it's needed to trigger an action. It doesn't depend, if it's calling of a script, or just some variable's value change. If I declare the command in line array, it immediatelly triggers it. Of course, I know, there's no way to do this like that.

For this, I implemented my own method, how to trigger commands. I made the code read every line, until it stops at specific in-line command. For example, below line will add one progression point to the NPC (the "x" index doesn't mean x as a coordinate, it's just random line with command):

Code:
global.line[x] = "NPCPROGR 00,01"
It reads this line's first 8 letters to declare, which command to trigger and then it cuts out the numbers before and after comma to select, in this case, NPC index and what number of it's progress. Then it skips the line and goes to the next one without displaying the current line's content.

The same method is used when making a choice. When reading a word "QUESTION", it simply makes new array, where every choice binds to another line index. It becomes a part of a current dialogue array. For example:

Code:
global.choice[1] = "First choice."
global.choice[2] = "Second choice."
global.choice_startline[1] = 3
global.choice_startline[2] = 5

global.line[3] = "Selected choice 1."
global.line[4] = "END" //By the way, this means dialogue ends, also read as a command

global.line[5] = "Selected choice 2."
global.line[6] = "END"
The thing with questions is just an addition I also don't like too much, but I'm able to accept it.

As it is, it works good enough, but I'm not satisfied how the triggering of various events looks and how it makes code look a little stupid and amateurish. As I'm really not too experienced programmer (I started learning working with arrays not too long ago), I didn't come with better method how to achieve easy, but functional way to trigger events while being still in the middle of the dialogue. All the code just my improvisation I can't get over, because it's not standard, not nice and I don't like it. Even if it works in most cases.

Then there comes my question. Do you know about some nice and understandable method to achieve this? Maybe I was very close to solution, I don't know.
 
Top