-//add this to a function to add the ability to use linked lists
-//this is probably riddled with bugs that I haven't fixed yet
-//There is more functionality here than you probably need
-//so feel free to take only the bits you want
-//note that some functions have dependancies
-//create a list based on an array
-#define list_create_from(vals)
-var len = array_length_1d(vals);
-for (var i = len-1;i>=0;i--) {
- var n = {next:prev, value:vals[i]};
-//get an array based on a list
-//dependant on list_length
-#define list_get_all(list)
-var len = list_length(list);
-var a = array_create(len);
-//number of elements in a list
-//add something to a list
-#define list_add(list, val)
-last.next = {next:-1, value:val};
-//adds something to a list at a specific position
-#define list_add_pos(list, val, pos)
-for (var i = 0;i<pos && next>=0;i++) {
-last.next = {next:n, value:val};
-//gets the position of an item in a list
-#define list_find(list, item)
- if (last.value == item) {
-//removes an element from a list
-#define list_remove(list, val)
-while(last.next>=0 && go) {
- if (last.value == val) go = 0;
-//removes the element at a specific position from a list
-#define list_remove_pos(list, pos)
-while(last.next>=0 && go) {
-//gets the the value of a list at a certain position
-#define list_get(list, pos)
-while(last.next>=0 && p<pos) {
-//preforms an event for each element
-//event is a script_ref that will get called with the value as an argument
-#define list_do_all(list, event)
- script_ref_call(event, last.value);
-//removes each element from the list if a certain condition is met
-#define list_remove_if(list, check)
- if (script_ref_call(check, last.value)) {
-//Appends a list to the end of another list
-#define list_append(list, newList)
-last.next = newList.next;
-//sorts a list with mergesort
-//takes a script ref that should check whether the second argument is greater
-//the array will be sorted so that the "largest" values are last in the array, etc.
-//dependant on list_length and list_append
-#define list_sort(list, check)
-var length = list_length(list);
-while(last.next>=0 && p<length/2) {
-var list2 = list_append(list_create(), last.next);
-list_sort(list2, check);
-while(list1on.next>=0 || list2on.next>=0) {
- var add = list2on.next;
- if (list1on.next>=0 && (list2on.next<0 || script_ref_call(check, list2on.next.value, list1on.next.value))) {
- list1on = list1on.next;
- list2on = list2on.next;
-//sorts a list of numbers, taking no script reference as an argument
-//dependant on list_sort and num_check
-#define list_numbers_sort(list)
-return list_sort(list, script_ref_create(num_check));
-//checks if a is greater than b