Oh i still haven't figured this out yet. Array for Interactive Dialog

I know its possible to do it in the Blueprints. to get random text to pop up inside a widget when you step inside a trigger,
when you are near an NPC so they give you random responses back so you can have interactive dialog with them, but
I don’t know how to construct a Random interger Array in blueprints needed to do this.

The random interger, which I can easily setup in windows script in just a few lines of code, Its the critical nerve center
to the whole entire game. If I can’t set this up then i can’t set up my game properly. If I can’t set up the array, then I can’t have interactive A.I dialog when i step into the trigger. Without the array I can only have fixed dialog responses with no Artifical intelligence, so the game will have no depth in the dialog and without it it will just be a shell…

So I need help in setting up the array. and its just a very simple thing but I don’t know anything
about constructing a basic array with blueprints to get random text to show up in the widget, (its not the print string node), I need someone to show me the node setup.

Hi, I don’t know a lot about blueprints yet, but searching around about your problem. There seems to be a “Make Array” node which you can use to create an array. You can read about it on:

I’m not sure if I’m understanding your problem correctly though. Are you trying to make an array that hold random integer values or text?

Hi, I didn’t understand everything but this should do the trick

Its actually a bit complex my game because its an RPG game with dialog. I use Array slot values with assigned text for dialog… Or I use just flag variables if the entity exists in the same room… For things like Chests and loot drops of enemies i do use array values.

Dialog Text assigned into an Array

set /a spin=%random% %%7+1
if %spin% EQU 1 echo. Commander: I don’t have the money right now. But I can get it later. && sound play Comander1201.wav
if %spin% EQU 2 echo. Commander: Yikes, its that much? Can’t you give me a discount or something? && sound play Comander1202.wav
if %spin% EQU 3 echo. Commander: 150000 is a ridiculous price for replacing a damaged ship manifold. && sound play Comander1195.wav
if %spin% EQU 4 echo. Commander: 150000 credits Its an outrage. && sound play Comander1196.wav
if %spin% EQU 5 echo. Commander: I will complain to Central about this. && sound play Comander1197.wav
if %spin% EQU 6 echo. Commander: $150000 Credits? Your prices are ridiculous && sound play Comander259.wav && bg sound play 5000
if %spin% EQU 7 echo. Commander: For that price, its not worth it. && sound play Comander1198.wav

What this does is each time you run it, it will show up a different slot of
text and play the dialog audio. It just picks it at random from out of the array that’s been stored for the commander… That’s how I set up the array with the audio files for dialog. The same thing should beable to be done in the blueprints for unreal engine with the npc’s when you step inside the trigger.

Same Array Done using Multiple Party Members. Responses depend on the player’s number of visits to the area.

if %tsecv% EQU 0 set /a spin=%random% %%6+1
if %tsecv% EQU 0 if %spin% EQU 1 echo. Storm: This place is guarded. I doubt we will beable to get inside unless we
if %tsecv% EQU 0 if %spin% EQU 1 echo. have got a special security pass.
if %tsecv% EQU 0 if %spin% EQU 2 echo. Storm: Does any one here have a pass to get through the guards?
if %tsecv% EQU 0 if %spin% EQU 3 echo. Storm: Guards up ahead. Look busy people.
if %tsecv% EQU 0 if %spin% EQU 4 echo. Storm: We will need a pass.
if %tsecv% EQU 0 if %spin% EQU 5 echo. Storm: Without a pass we won’t beable to enter into the power station
if %tsecv% EQU 0 if %spin% EQU 6 echo. Storm: My pass has expired, Commander we need to get a new one.
if %tsecv% EQU 0 echo.
if %tsecv% EQU 2 echo. Commander: Let’s try to find ourselves one of those security passes. && echo.
if %tsecv% EQU 2 echo. Storm: Oh man, how are we going to get in that place. We don’t have a pass. && echo.
if %tsecv% EQU 2 echo. and that security guard aint budging from his post.
echo. && echo.
if %tsecv% EQU 3 echo. Commander: That rotten guard is now starting to now upset me. He still won’t budge.
if %tsecv% EQU 3 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Rex: He does his job only too well. You aint going to
if %tsecv% EQU 3 if %rex% EQU 1 echo. get in with him all hanging around if you don’t have the pass. He
if %tsecv% EQU 3 if %rex% EQU 1 echo. must beable to be distracted somehow. Just think of something
if %tsecv% EQU 3 if %rex% EQU 1 echo. commander. Entertain him or something.
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Commander: You must be joking me, entertain this securirty guard ?
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Storm: As much as I hate it. Why not do the axel in front
if %tsecv% EQU 3 if %rex% EQU 1 echo. of him that ought to move him away from his post…
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Rex: Ooooh our favourite Planetary greeting dance.
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Storm: You got to be kidding me Rex, it’s supposed to scare people away
if %tsecv% EQU 3 if %rex% EQU 1 echo. the Axel is no good for anyone. You’re not thinking right.
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Commander: Oh thanks a whole lot guys.
if %tsecv% EQU 3 if %loana% EQU 1 echo. Loana: Oh for pete’s sake just get on with it.
if %tsecv% EQU 3 if %loana% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 if %rex% EQU 1 echo. Storm: No trouble. Just do the axel and this guy will be out of our
if %tsecv% EQU 3 if %rex% EQU 1 echo. way and he will be gone.
if %tsecv% EQU 3 if %rex% EQU 1 echo.
if %tsecv% EQU 3 set axsecguard1=1

So, basically, your problem is that you have the text and want to save it in an appropriate location, but have no idea how to make the game randomly select a piece of text from that list?

If I’m understanding this correctly, you’d just need to set up an Array (Actually, I think there’s something called a DataTable that exist specifically so that you can use Excel or something to add data to the game) and then use the “get” node to select an entry from the array.
On the “get” node you have an integer input that is used to determine which element of the array you are invoking. Just pipe your random number there.

The widget itself would be a text box. You just create a variable on the widget, then select the text box and use the “bind” property to bind it to that variable. The game would then change that variable whenever the text that you want to display changes. Or maybe call an event dispatcher that also sends text with its event.

I’m pretty sure that I’m misunderstanding what you mean, though.

Yes, my problem is not being able to interpret the Windows Script Language into Blueprint Code because I don’t know how to glue all the blueprint nodes together for the array because I’m NOT a blueprint programmer that’s why I have this big problem between interpreting the script languages because blueprints is so different to windows script.

So I dont know how to construct the array to make Unreal select a piece of my text at random from the array and then just draw it up in the hud
in a text widget. I can’t use the Print String node because that its only for debugging so it won’t show up in the actual game.


As a result of this script barrier problem that I have with the blueprints, I have put on hold all development of my game for unreal engine at the moment until I can beable to set up a basic array to read in dialog text
of the NPC and then draw it up in the hud to allow my NPC’s to beable to express their own thoughts by picking what is stored inside of the array which is defined by a slot value…

Your other idea of putting all the dialog instead into a Main Data text Table file is a good idea because my game has over 30,000 lines of dialog… That would be appropirate. But I think because of my lack of knowledge with blueprints it be more easier to set up the array up within the blueprints of the NPC’s that you interact with rather than use a main data table file to call up the text from because the data table file system is alot more advanced than just storing text inside of an array so that’s why I have to rely on others who have got years of experience with the blueprints and more importantly, UNDERSTAND them. I don’t understand the blueprint system very well.

But do know what’s required in the data table.

For If you use a data table setup to read all the text in from one central file,
then you need the Speaker ID Tag and the row number the text is on, then you need the AUDIO ID Speaker tag because the game has got voice audio also in it so you have to tell the game to play the audio file for the text. And (Optional) the Player Portrait PIC ID Tag number for displaying the player portrait picture up in the HUD of the NPC along with their text. (optional)…

So you would need these things in that data table,

A) Speaker ID Tag
B) Speaker Audio ID Tag
C) The Row Number containing the dialog text itself which the game can just call up into the HUD by
reading in the row number.
D) Player Portrait Pic ID Number.
E) Any Special Game Condition Flags
F) Camera ID Flag for special camera setting conditions (used for cutscenes).

Do I know how to set up a data table in unreal engine?, no. I can glue things together only in windows script. So I know my limits, I cannot glue things very well up in unreal engine because I’ve not had YEARS of experience with these blueprints to know how to glue them…

So storing text in arrays within the NPC Actor blueprints might be more easier. As I’ve already got fixed dialog text already working in the
blueprints. but not reading text in from arrays.

I don’t know much about windows script but it looks like your script is using if statements and not really arrays in my opinion. Usually, when you use arrays there’s really no need to use if statements. I think the general idea using blueprints and a text array would look like this though:


I’m just using the general “Print String” node, but you can change that to how you want to display your dialogues. I hope that helps you make some progress in your game. Actually, I don’t have a lot of experience with blueprints either, but I have years of experience using different programming languages and certain things are done in a similar way.

Thanks for helping me out, this looks to be on the right track according to the pic, so This might be a start. But the print string node I think only works in the editor. So to get this to work in the game, This might have to be set up using a text widget node that draws random text to the screen. Can you see if you can get it working with a text draw widget node, I don’t know how to do it with Designer Text Blocks widgets, but you might beable to draw the text instead to the widget (that’s if the text draw node supports adding in elements for the array.) I find with this print string debugging node, it dosen’t allow you to position the text anywhere you want up on the screen. Besides if the text only shows up in the editor and not in the game, its not gonna work in the game. But at least the print string node will show you in the editor that the array is working. That’s great, now we got to get
it working in the game. not just in the editor.

So now we just need to find the right text node.

Just a quick note with the pic above, LENGTH returns the number of array elements, but the index starts at 0, be sure to -1 from the length in order to have your max random number the max index of the array

You surely do not want to copy dialogue strings one by one into who knows how many arrays!
Wouldn’t it be easier to use DataTables, they’re a breeze to set up.

  • your dialogue lines could have identifiers
  • editable in a spreadsheet or in the editor
  • the dialogue lines can be associated with images/sounds
  • you can still load a chunk of the DataTable into an array for use in any particular conversation, if needed
  • can be updated quickly
  • easier to localise

More info here: Ignore the c++ parts, this can be done in blueprints.

You’d need to plan ahead a little more and design a struct to hold the data (in the editor):

  • identifier/line number, or both, or more
  • actor speaking
  • the string itself
  • next branching line/conversation chunk
  • visual asset
  • sound asset
  • more, depending on the complexity of you game

The basic workflow:

  • have the text in the spreadsheet rows with columns reflecting the above-mentioned data struct (any spreadsheet that can export to *.csv.)
  • export it to csv format
  • create a DataTable in the editor
  • import the csv

You will need to blueprint a manager that handles what is displayed when, ofc.

Oh, and yeah, you’ll need widgets for that.


yeah, noticed it as well, use *LastIndex *instead, good practice.

Also, noticed that someone mentioned the DataTables already… not enough sleep, oh well.

Data Tables work in blueprints?!

They do, why not?

Sounds a bit Advanced but that sounds like a better way of doing things especially when you have alot of dialog… Advanced to me really means people who have a good grasp of all the basics which you combine in all the basic elements in together. But because I don’t yet know all of the basics elements yet of these Blueprints, is why I’m not advanced and struggling to understand the stuff you are mentioning… Everynone, I would need someone to show me how to set up a datatable up. You might know how to set up a manager with a datatable with the widget to make the dialog become all data-driven, but I don’t have the knowledge to set this up. But it sounds like a good idea.

I didn’t think having lots of arrays would cause issues through as it seems to run ok in windows script. My windows script code is over 168 thousand lines long containing all the dialog in arrays, there’s over two thousand of these arrays in the script…

All those arrays allowed me to run my script file like a storyboard text adventure game. That is what I needed to debug and test out first all the storylines to the game before putting them into an environment of 3d worlds in a 3d game engine.

As with everything, you’ll need to break it up into smaller pieces. There are examples on youtube.
I’m assuming you have the text in Excel already, start with creating a struct based on the columns.

Thanks, I didn’t know about LastIndex. :smiley:

I didn’t use Excel, I wrote my game batch script out in just simple notepad but this batch script runs like a text graphic storyboard adventure game playing also all of my audio files. So it don’t matter if the ideas script is 168 thousand lines long, or it grows to a million or more lines. The reason for creating the text script and embedding in all the thousands of little audio files of the game into it was simple.

In a 3d game engine you gotta condense down all those tens of thousands of audio files
That’s why I put all the audio files into my script so i could then just run the script
then play all the audio files for that scene and just record it as one single Audio stream file.

So the game script was created with several purposes in mind.

  1. I needed to have a game concept in text form.

  2. I needed to test and debug all the storylines and make any changes
    and tweaks in text form first before putting it into a 3d game engine.

  3. I needed a runnable script to create a single audio stream for
    the dialog for the scene. That’s why I had to embed all the audio
    sample files and them combine them together into one single audio stream.

No one will deny that’s a lot of work, especially if you do not have it in a spreadsheet already. You will also need proofreading.

Just to give you an idea, here’s a simplified example of the struct:


You can organise it in many different ways:

  • SpeakerID - either an *int *or a *text *var, or an enumerator, even
  • PortaitID - can be an *int *if you’re planning to keep the images in a separate array or a direct path to a file, both could work
  • AudioFileID - same as above
  • AudioStartTime - if the file contains more than one dialogue line and you only want to play from a specific point
  • ConditionFlags - enums of your choice

And the *DataTable *in the editor:


That’s the general, quite unrefined idea rather than a game-ready solution, you will need to adjust it to your needs. Since every game is pretty unique with handling the data, it’s highly unlikely you will find a ready solution, you will need to script it yourself. But that’s all the fun, right?

Building on Everynone’s example, some things to consider:

  • 1 main data table or a data table for each individual?
  • Text display time variable, since I bet the time it takes to say some sentences varies. Unless you base it on the audio file length/is playing or something.
  • Use enums. Instead of Ints to identify something which may sound simple and comfortable, can get confusing. If you are not yet comfortable with enums, then play around with them until you are and then use them.
  • Use class variables. Instead of having an identifier in the data table, getting the identifier, using the identifier to get the item that you want… directly use the item. In the portrait case - use the portrait image, audio file - use the audio file. Etc. Wherever possible of course.

You might be interested to know that I did spot quite a few spelling errors in games like Kotor, Mass Effect, and other games that had thousands of lines of dialog in them.

Where do we get this dialog struct that you are showing me?, do we have to create this data table ourselves? I might look more into it. As I’m seeing some of my
stuff already entered into the table. Because what you want is a main data table that keeps track of all the game variables as you move from level to level to each system module you visit.

This is going off the topic a bit but I think its important to mention.

I believe the game would have to be set up with system modules for each of
the different worlds that you visit, and those worlds unfortunately would have
to be fairly medium in size, because i can’t have full ground planet simulators
that stretch on for miles and miles with procedural made worlds because it
probably wouldn’t work on a machine with only 16 gigs of ram.

Unreal chews up alot of ram with its resources when loading things into the
editor. Ok so maybe you can create your universe or planet with Procedural bp code
for it all sounds great to have a Million worlds you can travel to from
but Apparently making procedural 3d universes makes the game code crash after a while so you get the procedural but get an unstable game as well.

You could be flying to one planet, and then to the next then suddenly without warning, you get the crash screen popping up and have to start the game again. Crash, an hour later, Crash blue screen again, half an hour later, Crash, crash and crash and crash. Each time the game tries to calculate a number the cpu can’t handle, crash goes that game.

So i figured I would be better off manually making my 3d worlds instead than having the computer generate them all procedurally then it might be more stable.

  • Text display time variable, since I bet the time it takes to say some sentences varies. Unless you base it on the audio file length/is playing or something.

Yes you’re right, the audio length does vary, that’s probably why they use facial rigs in the cutscenes or use text windows with a player portrait if they don’t want to do the facial rigging animations and just play only the audio and have the player press a key to flick through the dialog text… Or they use a skip cutscene option if you don’t want to play that scene, or allow you to turn off the text subtitles if you just want to watch only just the cutscenes in cinema wide film view like a movie with just the audio playing which I think is also a nice feature to have in your game.

I don’t have facial animations yet in my game but I do have access to a professional 3d modeler who can do facial rigs. But you still need to create the facial animations for the audio and the cutscenes. You need special software for matching up the
text with the audio along with the facial animations of your npc speaker. That I don’t know how to do myself.

I want to know how I can load my model meshes into the editor then switch the meshes of the party members if I select a party member from the widget, so it will then switch the game camera to show their mesh and have the party members
also follow me around with track player whenever I move around the screen and can also swap party members in and out of the group or have a solo mode.