Making a quest log; active quest strings always at top? [solved]

I feel like I’m thinking about this too hard, but I’m trying to make a quest log. With the quest system that I’m using, when a quest is active, its name and description (from an array of strings, an element for each quest) go into a Text object, and when it’s inactive, it goes back to empty, i.e. " ". However, I’m not sure how to go about making the active quest strings always be at the top, or how to check for and omit the empty ones from the array. I hope the solution is easier than I’m making it out to be lol.

If only the active quest has text just compare the string from the text component to the strings in your array.

Multiple quests can be active at a time!
Basically, right now, they just kinda appear in order; if you complete quest 1 before quest 2, there’s just a giant space where quest 1 used to be. Would like to make it so that quest 2 moves up, if that makes sense.

I’d have to know more about your setup, but if you’re using text objects within a scrollview content, you can just set up a layout group(grid or whatever you prefer) on the content object. All your text goes underneath. If quest aren’t active, just turn off the text and the boxes will adjust. I’d also add a content size fitter to the content object.
As far as ordering the quest, all children have an index assigned to them. So changing that index will change the order, or you can just use the setAsFirstSibling to move something to the top of the list

Use a “List<>” instead of an array, Lists can be rearranged, just have a List with the active quest and remove them when not active or completed, if you remove the first quest the next quest will move up by it self.

To use Lists you need to add

using System.Collections.Generic;

To your script, to create a string list you do as follow:

 List<string> MyQuestLog = new List<string>();

and to add or remove you do this:

MyQuestLog.Add( "you quest string goes here" );

MyQuestLog.Remove(0); // 0 its just an example.

More info:
https://msdn.microsoft.com/es-es/library/6sh2ey19(v=vs.110).aspx

please tell me a quest is being stored as it’s own class/struct… and you’re not synchronizing two string arrays to hold the quest data.

You can then either go with a pair of list for active/inactive quests (not string lists) or have a bool in that class/struct and a single list sorted by that bool(might be interested in “linq” for that).

Thank you so much. I actually didn’t know about lists before lol. I figured it out!
I’m still using the array, too, but the specific elements of the array are “added” or “removed” to the list, depending on activation, etc. :stuck_out_tongue: