Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Problem resizing an array within a struct

I'm building a grid-based inventory system, and can't seem to get this function to work. Basically, I created a 2D array by putting an array within a struct, then making an array of that struct. So we have the array ContainerInventory, which contains elements of the type struct Container Column, which in turn has an array of the inventory slots struct.

Whats happening is, when the container is initialized, I just want to resize ContainerInventory to match the pre-defined container width, then iterate through ContainerInventory and set all the empty arrays within ContainerColumn to match the pre-defined height. However, when it prints out the length of each Items array, it just says 0. Was wondering if someone could explain if I'm doing something wrong or being really dumb?

Quick edit to clarify a couple things, both the width and height are set to a value of 5. It appears to resize the ContainerInventory variable correctly, as it prints 5 of the message Column Size - 0.

alt text

Product Version: Not Selected
more ▼

asked Jan 09 '15 at 06:03 PM in Blueprint Scripting

avatar image

8 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

you can't directly set an "array inside a struct inside an array" when using blueprint. you can do it in c++ or you can make a temp array of structs that you use to create the outer array.

alt text

but if your goal is to make a grid of items, why not put them all in the same array? you could use modulus on the iterator to format a single array of objects into a 2D grid:

 MenuPositionX + (SpriteSize + MarginSize) * (i % MenuWidth) , 
 MenuPositionY + (SpriteSize + MarginSize) * FFloor( i / MenuWidth )  

that way you can separate content from presentation, allowing you to swap out the formatting style without duplicating the content. you can display the same list of objects as a circle menu, album flip book, scrolling list, skill tree, grid list, horizontal list, tabs, venn diagram, flow chart, etc... just by swapping out this logic.

more ▼

answered Jan 10 '15 at 02:15 AM

avatar image

9.6k 318 205 449

avatar image Rhinoceroscity Jan 10 '15 at 07:07 AM

Building a temp array is what I ended up going with.

I thought about doing it in one array, but certain inventory items will occupy more than one space, so my brain wanted to distill it into a form it understands, instead of having one object occupy indices 3,4,5,11,12,13, it just covers a space between 0, 3 and 1,5. Along with potentially having the container sizes vary and change. But maybe one array is still the best way to go and I just can't quite figure it out.

Thanks for the answer.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question