Can you store/access data from a table or database via blueprints?

Is there a way of using/interacting with a database, or even a flat table via blueprints? Let’s say I want to store AI stats or other things that we’d want to access globally, how would this be accomplished blueprints?

They are implementing structs in 4.2 which should provide global variables, however there are other uses for databases that I feel would be very useful such as for user modding.

On that note, it would be cool if there was an official tutorial about how to go about opening your project to allow for modding! :slight_smile:

i miss multi-dimensional arrays

Weeeeeeell…

I mean you could just implement your own with a few functions.

Implement a single dimension array and just access the appropriate slot using some simple math/access functions.

It depends on what you even want to do with them, i’ve rarely if ever had actual uses for multi dimensional arrays personally.

I could really do with them in my game right now, and for some others I have planned, which tend to involve grids, game boards. It would be so much easier to code(BP) if I just had ready-made 2 dimensional arrays. Functions you say…, > > > goes to read about how to use BP functions(again).

You can look at my vector field generator for an example of how to store a 2d grid in a single array.

Vector Field Generator - First Loop runs X. Second Loop runs Even Offset Y. Third Loop runs Odd Offset Y.

The Vector Field is Indexed as such:

*Each index is placed on that spreadsheet according to its vector in the map.

You might notice that the difference between my Vector Field and a 2D array is that I have to do a small bit of math to get the Absolute X or Y of each Row/Column. If I want X, I strip the Y out. If I want Y, I strip the X out. So if it is index 105, and column height is 10, then I divide by 10 and get the remainder of 5 which is my Y. If I want X, I do the same thing but take the whole which is 10.

My columns go in steps of 10 though, so the math may be a little cleaner with that limiting factor.

I was trying to think of a way to fill a struct with arrays and then put that struct itself into an array, but I am not sure how much more efficient that would be. You can’t dynamically add elements to a struct in BP, but maybe if you are running a setup where that axis is fixed you could make use of it.

Cheers Zeustiak.

I can’t make out the detail in the Vector Field Generator.

I’m currently finding random positions on a chessboard, numbering the squares (array indexes) 1 to 64, and then doing some math to transform that to an (x,y) pair because I need to do a lot of logic around these (x,y)s. But that logic is hard coded where I currently need it. I’ll now be wanting that logic in a huge number of places and need to create a callable bit of code.

Do I use a function where I pass in a number from 1 to 64 and it returns an x and a y, or are they macros, not quite used to UE terminology and abilities yet(I am a programmer, learning UE). The one attempt at a function (I think) allowed me to add an input, but I couldn’t see an ability to add an output, and abandoned it at the time until I knew more.

Ideally I’d like a multidimensional array of structs.

Helpful to just see that the Division (Whole and Remainder) box (assuming it is a standard UE box?)

You should be able to zoom in on the vector field enough to make out what each node is. The numbers themselves are irrelevant. Of course this is for a hex grid so a square grid can probably be generated without the third ForLoop as you don’t need to offset anything.

For your chess board, have 1 ForLoop run 8 times, and it runs to a ForLoop that also runs 8 times. Each time the second ForLoop runs, multiply it’s index output by your X(width of your square), and each time the first ForLoop runs, multiply it’s index output by your Y(height of your square).

At the very end you make a vector with that X and Y and drop it into a Vector Array. Your array should be indexed similar to the spreadsheet I posted. First column 0-7, second 8-15, and so on to 63.

I just had a go at it.

I just did 2 simple functions that convert from a number in the range 1 to 64 to (x,y) (1-8,1-8)
and then a reverse function, of x,y to a number in range 1 - 64.

Worked nicely first go. Thankyou :smiley:

I’ll incorporate getting or setting the arrays as well, but confident I can do that now.

Cheers,
Max

I indexed my chessboard array as such:

57 58 59 60 61 62 63 64
49 50 51 52 53 54 55 56
41 42 43 44 45 46 47 48
33 34 35 36 37 38 39 40
25 26 27 28 29 30 31 32
17 18 19 20 21 22 23 24
09 10 11 12 13 14 15 16
01 02 03 04 05 06 07 08

8
.
.

  1. . . 8

so my formulae are quite different, but I already knew them, I just didn’t understand use of UE BP functions.

I am too looking at making my own little 2d array, it’d be nice if the devs would consider adding this but AFAIK it’s been a limitation with UE for a while. It’s not a huge deal but would be nice. :slight_smile: Nice to see this discussion though!