I'm working on a stupid simple RPG. I've just polished off grid-based movement and a zelda-esque scrolling project. Now I'm working on the dialog system. So far, I've created a new level that has a picture object, a character image object, and a getline extension. The getline extension pulls a script from a text file which I've formatted like this:
0001 <img>bin/ava/cold.bmp
0002 McFatmo: This is a sample script.
0003 McFatmo: The real script has a storyline, but this isn't it.
0004 McFatmo: Instead, you're reading this. This is nothing.
0005 <break>
0006 <img>bin/ava/circy.bmp
0007 Circy: Lame.
0008 <break>
0009 Do you like fish sticks?
0010 <break>
The GetLine extension pulls each line, removes the first five characters, then passes the line to the character image object. Then the first five characters in the character image object are checked. If the first five characters are <img>, it removes the five characters and treats the rest like a file path it passes to the picture object, it skips to the next line and if it's first five characters aren't recognized it passes the remaining text line to the character image object. In other words:
Start of Frame:
Character Image -> Word wrap on.
getLine -> Open File apppath$ +"bin\txt\script001.txt"
Character Image -> Set text Right$(CurLine$("getLine")), Len(CurrLine$("getLine"))-5)
Left$(Text$("Character Image"), 5) = "<img>":
Picture Object -> New Picture : Apppath$ + Right$(Text$("Character Image"), Len(Text$("Character Image"))-5)
GetLine -> Next Line.
Character Image -> Set text Right$(CurLine$("getLine")), Len(CurrLine$("getLine"))-5)
Text$("Character Image") = "<break>":
Character Image -> Set Text = ""
Upon pressing Space Bar OR(logical) Upon Pressing Page Down:
GetLine -> Next Line
Character Image -> Set text Right$(CurLine$("getLine")), Len(CurrLine$("getLine"))-5)
Upon pressing Page Up:
GetLine -> Previous Line
Character Image -> Set text Right$(CurLine$("getLine")), Len(CurrLine$("getLine"))-5)
The problem I'm having is when I hit the <break> lines. I need some way of passing a signal from the subapp to the first frame to hide the subapp. I don't want the player to be able to hide the subapp in the middle of a game text; so I was thinking about using a global value, but GlobalValue1 = 0 then hide? 1 then show? Isn't there a better way to do it?
I was thinking about figuring out a specific key that advances the text. Test for subapp visibility, figure out what line the script is supposed to start on and end on. In the sub app, make the space advance the text. In frame1, make space bar increase counter +1. If the script is only supposed to show 5 lines, when counter =6 hide subapp? There's gotta be a better way to do that.
Any help?
Edited by The_Antisony
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
I've made stuff like this plenty of times, I would suggest ideally not using a subapp at all for dialogue because it makes things easier in the long run (but harder to update across frames). If you're dead set on it, the best way is probably a global value named EndText or something that just gets set to 1 at a break, which triggers the subapp to be hidden and text advancing to stop.
Eventually I want to turn this into a game, but if I get bored with it and give up, I'd like to at least package it as an engine example and upload it as a tutorial. I'm really trying to keep the game size to a minimum, and including a character image and picture object on every frame isn't really an option. I'm also trying to trigger the least amount of events per loop as possible, so I've been nesting most of my events in deactivated groups, then activating them when needed. The reason I'm being so scrutinous about this is because I am dealing with a subapp here; essentially two groups of events on separate frames that both run at 50 frames a second. That's no good if both frames are constantly passing and testing global values and global strings or if they have to run through more than 100 events in one frame and another 35 in the subapp frame. It's a detriment to available resources, which goes against the point of playing an RPG on a PC. I'd rather play a game that looks like crap but runs really well if only so I can do other things on my computer in the background; or at least know the game isn't going to bog my old, old computer into the ground because of a simple update.
I'm really just looking for other opinions, so thanks. It's not like I can't get this done, but it's good to take input from other people because they may approach the problem a way I haven't thought of. Where the hell is Circy when you need him? That dude is a pro with event scripting minimalism.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
^That's a link to the project. I got most of it working correctly, but for some reason even though I set the global DialogStartLine value before creating the CharacterImage object in the subapp, the very first time the dialog is called per frame, it displays both the line I set AND the first line of the script overlayed over each other in a big, garbled mess. The subapp preforms correctly otherwise. I've read through the event scripting over and over figuring it's some kind of fairly common ordering issue, but nothing I can figure out fixes the problem. If it's just not feasible, I need to know. I can't have the dialog screwing up the first triggered line in each frame.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
I finally figured it out. There was absolutely nothing wrong with my event scripting. The characterimage object has a default text set which was combining with the text I wanted to set and created a garbled and unreadable mess. I slapped myself in the forehead, and now everything works accordingly.
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?