Beginner programming question

This forum is currently in read-only mode.
From the Asset Store
Latency independent responsive controls. Beginner friendly documented.
  • 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

    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.

  • 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 . Maybe someone else can give you a hand with that if that's the route you want to take.

  • 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.

  • 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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)