Rotating List Library

Liam315
On the suggestion of george in another thread (viewtopic.php?f=10&t=4205#p27995) I've created a library which through the GUI allows authors to create an easily editable list of responses and print an item from it according to the settings they select.

What you can do with it:

- Print a random response from the list (completely random, allows repetition)
- Print a random response without repeating anything until all responses have been used.
- Print a set of responses in a predefined order without needing to nest "first time" scripts or create "if" scripts with a count.
- You can both allow the cycle to start again or print a default message when all responses have been used.
- Up to 20 responses can be defined.

Much of what this library does can be achieved already with things like dynamic templates and scripts, however this condenses all of that into one easy to manage tab in the GUI. The textbox based input system also makes it easier to edit the order of the list if that is important to your game.

Unlike regular string lists that exist as an attribute of another object, these lists exist as objects by themselves and should therefore be created outside of the rooms that the player uses in the game. If you do prefer to create it as a child of the object that will use it however, it is set to be an invisible object and should have no impact on your gameplay with the exception of containers with a maximum child limit, which would have to be adjusted accordingly.


How to use it:

Creating a list and printing selections

1. Add the library to your game, save and reload.
2. A new tab will now appear on the GUI labelled "List"
3. Create a new object and name it accordingly. This will be your list and you should create it either without a parent, or in a new category to hold all of your lists.
4. Go to the "List" tab and select Yes from the dropdown box.
5. Select the number of items you want in the list and fill in the text fields.
6. Select your options to control how items should be printed.
7. To add the printing of an item into a script, click "add script" and select "Print an item from a rotating list" (one of the last options in the Output section) and select your list.

The code view function is RotateList(listname).

Adding list items during the game:

Click "add script" and select "Add an item to a rotating list" from the Variables section. Select the list you want to add to and enter your desired text. This will add your string to the end of the list.

The code view format is: RotatingListAdd(listname , string).

Removing list items during the game:

Items can be removed from a list using one of two methods.

1. By attribute.
If you know the number of the value you want to you remove, you can do so via the script "Remove an item from a rotating list (by attribute)", found in the variables section of the add script dialogue. Select the list you want to remove from and enter the attribute name using the format listitem#.

The code view format is: RotatingListRemoveByAttribute(listname , attributename).

2. By string value.
If you won't be able to predict what the attribute number will be, you can remove an item by using the actual text. Add script, select "Remove an item from a rotating list (by string)" from the variables section, select the list to remove from and enter the text. Be aware that you have to enter the text exactly as it is in the list or it will not work.

The code view format is: RotatingListRemoveByString(listname , string).

Tips for advanced use:

You can have another event trigger the default message to be displayed instead of the list options by using
[list].listexhausted = True

Each list item is its own separate string attribute; the actual string list is created fresh by the function every time it is run, so the handling of individual items on the list can be used by the format [listname].listitem#
e.g.
mylist.listitem3 = "This response is different now."

will replace the third list item.


Current limitations & Future Updates:

The library currently only manages strings and the printing of them as a response. I may expand this in the future if it seems like there is a demand for it to handle scripts and/or objects.


I've attached the library itself and a basic demo of some different option combinations. Any feedback or suggestions for updates are appreciated.

george
nice work!

HegemonKhan
awesome work, thank you, Liam. Now, to study it, hehe :D

Liam315
Updated to version 1.1, now supports the addition and removal of list items via a script.

Top8media
This is very nice!

Liam315
Thanks :) Once I'm finished with my Spring Thing entry I'll work on expanding it to handle scripts.

This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums