Beginner programming question

For questions about using Classic.

Post » Tue Jun 16, 2009 7:18 pm

Hey guys,

I'm just learning Construct and I've started a little project with some clear goals to hone my skills. Basically it's a top-down RPG, like The Legend of Zelda. I've done pretty well with event-sheet based programming so far, but I've reached sort of a dead end and I have what one might call a "stupid question."

There's only one character in the game, the player. To convey the isolation the player feels, the PC is going to talk to himself, so I have dialogue popping up at the bottom like in old NES games. Now I'm perfectly fine with creating transitions and writing text--I've got that down. But what I want to do is have it read which line of Dialogue to write from a global variable.

So basically, I have the thing which triggers the dialogue set the number of the dialogue into a global variable "Dialogue". For my test object, the number is "d001". Now, how can I have the text object write the contents of the "d001" global variable? My goal is to make it "modular", that is, to be able to seamlessly make it read from "d005" at another time, and "d002" at another, because it's picking up the index from the "Dialogue" variable.

I tried "nesting" global reads, but that was probably a pretty dumb idea. "Write text global(global('Dialogue'))" was never something I thought would work :P

I realize that I could use hash tables or arrays, but I ridiculously don't want to, because of the fact that I can't edit them easily. Plus I don't plan to have too many lines.

Well I hope I explained my problem clearly enough. If not, I can clarify--I've been banging my head on the keyboard for the past half-hour trying to figure this out.

Thanks!

EDIT: On second thought, it might be easier to use Hash Tables. Any solution you guys can suggest to my concept is welcome. :) I'm going to try Hash Tables.

EDIT2: I've decided to go with Hash Tables. It works perfectly. If someone wants to suggest an alternate solution, though, I'm all ears.
B
4
G
3
Posts: 25
Reputation: 975

Post » Tue Jun 16, 2009 7:39 pm

If it's just for something small and you don't need any dynamic loading of long conversations or anything, then I suggest you try a simpler method.

I'm guessing that most of the dialogue triggers at certain locations? If so, you can have an invisible trigger object that holds a line of dialogue in a PV. Step on the object, it pops up the dialogue window and yadda yadda. You can use instances of the same object and edit the individual PV's accordingly.

If there is dialogue that is dependent on time, you could use the timeline object to pop up the dialogue box.

Of course, you could use hash tables too, but I don't know anything about them :P. Maybe someone else can give you a hand with that if that's the route you want to take.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Jun 16, 2009 7:40 pm

You can't do that with global variables - you can only retrieve a pre-determined global variable. You could also try an INI - you can conveniently edit the file in an external editor like Notepad, and have the game read lines from that.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Jun 16, 2009 7:49 pm

deadeye's idea is suitable and simple. make an object called text trigger and have it hold the text in a private variable. have it disable or destroy when the character walks over it if you don't want him repeating things like a broken record (ie. only say the line once).
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jun 16, 2009 7:52 pm

Yeah, thanks all, those are good ideas--but I went with Hash Tables. With a little hackery, it seems to work exactly like I want. :)

Thanks!
B
4
G
3
Posts: 25
Reputation: 975


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests