Okay, I'm going to call this feature in Beta now. Although I'm likely to add features, what is already there probably isn't going to change much so FREDDERS can feel pretty confident that I'm not going to pull the rug out from under them.What is this?
For those who didn't read the previous thread, what you've got here is an implementation of two standard C++ features (deques and hash maps). Think of these as variables on steroids in terms of what they can do and how much power they have.
A deque is a double ended queue. That means you basically can make a list of ships, messages, subsystems or any other string or number you wish and then tell FRED "Give me the first / last thing from the list." Basically it's similar to the argument lists you can use with when-argument except that they exist independently of the event and thus can be used in several events at the same time (With an argument list you'd have to copy it to every single event).
A map allows you to specify pairs of variables. The key and the value. That means if you specify Alpha 1 as the key you can simply ask the game to retrieve whatever value you've associated with it (a message, another ship, whatever you want). You could then add Beta 1, 2, 3 etc and have them have different values.
Both containers support multidimentionality, that means you can have a map or deque with each entry being another container.
Although there is still quite a lot to do I'm basically I'm putting this up so that FREDders can play with it and help me find bugs / ask for features. As always, these are more likely to get attention while I still remember code than weeks or months later when I'll have to relearn how it all works. I'll be writing a tutorial on how to do cool stuff with this feature at some point but I wanted to make this available to play with as it's almost certain to still have some bugs due to the way it required quite a large edit of sexp_tree.cpp (It should be a lot more stable in FS2_Open than FRED though).
Since the feature is still in beta the modify container dialogue hasn't been implemented yet (I plan to work on it next!). You can add containers with the Add Container option but if you want to edit them you'll have to do it via notepad (or use the add-to-list / add-to-map SEXPs). Pretty much everything else should work though. I've tried to implement everything so that it looks similar to the way FRED handles variables so that it feels familiar. There are a couple of things that might need some explanation though.
If you have this SEXP
--- Get First
The game will go into the Ship_List container, get the first ship in the queue and give that to the self-destruct SEXP. If you have this though
--- Get First
--- Get Last
The game will assume that the first entry in Ship_List is another list and the last entry in that second list is the actual name of the ship. So in order to use multidimentionality you must use Add Data from the menu to add an extra Get First and you must have an entry in the Ship_List which is the name of a list with '&' before and after the name of the container (e.g &Another_Ship_List&).
The other issue people might encounter is when using the new SEXPs that expect the name of a container.
If you have this event and you right click on Ship_List you will notice that both the Replace Container and Replace Data options are available. They are not the same! Replace Data is the one you probably want. If you use the Replace Container option the game will assume you mean the contents of the container (i.e you don't want to check if Ship_List is empty, but rather that Ship_List is a multidimentional container and that it contains the name of a second container you want to check). You can tell what the game is thinking because if you use Replace Container it will add a modifier and will instead look like this.
--- Get First
Anyway, here's the build
for you FREDders to play with. I can't post the code in here as it actually breaks the forum limit. I'll add it as an attachment though.
If you have any questions, please ask. I really want this feature to get some heavy testing now. Report any bugs you find on this thread or on IRC (if I'm online).
Future features :-
I want to be able to output containers to messages the same way you can use $variable_name in a message to output the value of the variable. Of course, this is likely to be more complicated than with a variable since I'll need to code to pick which entry in the container to output.
Containers need to be tied into the event log. At the moment they don't output anything.
I plan to add persistence to containers in the same way that you can have persistent variables.
I'll be adding more SEXPs to allow you to interact with containers.
For instance one SEXP I'll add soon is the ability to output all the keys from a map into a list.
I'll also be adding multiplayer support at some point.
[attachment kidnapped by pirates]
[attachment deleted by nobody]