@@ -6,41 +6,51 @@ Version 2.0.1
66
77gdash is a functional utility library for GML, inspired by [ lodash] ( https://lodash.com/ ) . It aims to add useful, broad-purposed functions to help aid in game development. If you are doing any kind of data manipulation in your game, gdash can help out.
88
9+ ## Table of Contents
10+
11+ <!-- toc -->
12+
13+ - [ Install] ( #install )
14+ - [ API] ( #api )
15+ * [ ` _and(valueA, valueB) ` ] ( #_andvaluea-valueb )
16+ * [ ` _arrayOf(value1, value2 ... value14) ` ] ( #_arrayofvalue1-value2--value14 )
17+ * [ ` _cloneArray(array) ` ] ( #_clonearrayarray )
18+ * [ ` _collect(objectType) ` ] ( #_collectobjecttype )
19+ * [ ` _concat(arrayA, arrayB) ` ] ( #_concatarraya-arrayb )
20+ * [ ` _contains(collection, target, fromIndex = 0) ` ] ( #_containscollection-target-fromindex--0 )
21+ * [ ` _destroy(instance) ` ] ( #_destroyinstance )
22+ * [ ` _filter(array, filterScript) ` ] ( #_filterarray-filterscript )
23+ * [ ` _find(array, findScript) ` ] ( #_findarray-findscript )
24+ * [ ` _free(resourceId [, dsType]) ` ] ( #_freeresourceid--dstype )
25+ * [ ` _get(mapId, locationString [, default]) ` ] ( #_getmapid-locationstring--default )
26+ * [ ` _indexOf(collection, value) ` ] ( #_indexofcollection-value )
27+ * [ ` _isEqual(valueA, valueB) ` ] ( #_isequalvaluea-valueb )
28+ * [ ` _join(array, joiner) ` ] ( #_joinarray-joiner )
29+ * [ ` _keys(dsMapId) ` ] ( #_keysdsmapid )
30+ * [ ` _length(collection) ` ] ( #_lengthcollection )
31+ * [ ` _log(anything) ` ] ( #_loganything )
32+ * [ ` _map(colletion, mapScript) ` ] ( #_mapcolletion-mapscript )
33+ * [ ` _nth(collection, n) ` ] ( #_nthcollection-n )
34+ * [ ` _or(valueA, valueB) ` ] ( #_orvaluea-valueb )
35+ * [ ` _partial(script, arg0, arg1 ... arg13) ` ] ( #_partialscript-arg0-arg1--arg13 )
36+ * [ ` _push(array, value) ` ] ( #_pusharray-value )
37+ * [ ` _reduce(collection, reducerScript) ` ] ( #_reducecollection-reducerscript )
38+ * [ ` _run(script, arg0, arg1 ... arg13) ` ] ( #_runscript-arg0-arg1--arg13 )
39+ * [ ` _set(mapId, locationString, value) ` ] ( #_setmapid-locationstring-value )
40+ * [ ` _split(string, splitter) ` ] ( #_splitstring-splitter )
41+ * [ ` _spread(script, argArray) ` ] ( #_spreadscript-argarray )
42+ * [ ` _times(script) ` ] ( #_timesscript )
43+ * [ ` _typeOf(value) ` ] ( #_typeofvalue )
44+ * [ ` _uniq(array) ` ] ( #_uniqarray )
45+
46+ <!-- tocstop -->
47+
948## Install
1049
1150Download [ the latest release] ( https://github.com/twisterghost/gdash/releases ) and import the gml files into your project's scripts. For GameMaker: Studio 2, you can just drag and drop the files into the editor.
1251
1352## API
1453
15- * [ _ and] ( #_andvaluea-valueb )
16- * [ _ arrayOf] ( #_arrayofvalue1-value2--value14 )
17- * [ _ cloneArray] ( #_clonearrayarray )
18- * [ _ collect] ( #_collectobjecttype )
19- * [ _ concat] ( #_concatarraya-arrayb )
20- * [ _ contains] ( #_containscollection-target-fromindex--0 )
21- * [ _ destroy] ( #_destroyinstance )
22- * [ _ filter] ( #_filterarray-filterscript )
23- * [ _ find] ( #_findarray-findscript )
24- * [ _ free] ( #_freeresourceid--dstype )
25- * [ _ get] ( #_getmapid-locationstring--default )
26- * [ _ indexOf] ( #_indexofcollection-value )
27- * [ _ isEqual] ( #_isequalvaluea-valueb )
28- * [ _ join] ( #_joinarray-joiner )
29- * [ _ keys] ( #_keysdsmapid )
30- * [ _ length] ( #_lengthcollection )
31- * [ _ log] ( #_loganything )
32- * [ _ map] ( #_mapcolletion-mapscript )
33- * [ _ partial] ( #_partialscript-arg0-arg1--arg13 )
34- * [ _ push] ( #_pusharray-value )
35- * [ _ reduce] ( #_reducecollection-reducerscript )
36- * [ _ run] ( #_runscript-arg0-arg1--arg13 )
37- * [ _ set] ( #_setmapid-locationstring-value )
38- * [ _ split] ( #_splitstring-splitter )
39- * [ _ spread] ( #_spreadscript-argarray )
40- * [ _ times] ( #_timesscript )
41- * [ _ typeOf] ( #_typeofvalue )
42- * [ _ uniq] ( #_uniqarray )
43-
4454### ` _and(valueA, valueB) `
4555
4656Returns the value of the provided arguments after a boolean ` and `
@@ -193,7 +203,7 @@ __something(2);
193203_free(__something);
194204```
195205
196- ### ` _get(mapId, locationString [, default) `
206+ ### ` _get(mapId, locationString [, default] ) `
197207
198208Gets a nested value following a dot notation
199209
@@ -349,6 +359,45 @@ _map(map, divideByTwo, ds_type_map);
349359// => [3, 5]
350360```
351361
362+ ### ` _nth(collection, n) `
363+
364+ Returns the nth index of the given array or ds_list. If n is negative, the nth element from the end is returned.
365+
366+ ```
367+ @param collection
368+ @param n
369+
370+ @example
371+ var list = ds_list_create();
372+ list[| 0] = "hello"
373+ list[| 1] = "world";
374+ _nth(list, 0);
375+ // => "hello";
376+
377+ _nth(list, -1);
378+ // => "world";
379+ ```
380+
381+ ### ` _or(valueA, valueB) `
382+
383+ Returns the value of the provided arguments after a boolean ` or `
384+
385+ ```
386+ @param {*} Some first input
387+ @param {*} A value to || the first input with
388+ @returns {Boolean} The value of the provided arguments after an ||
389+
390+ @example
391+ _or(true, true);
392+ // => true
393+
394+ _or(false, true);
395+ // => true
396+
397+ _or(false, false);
398+ // => false
399+ ```
400+
352401### ` _partial(script, arg0, arg1 ... arg13) `
353402
354403Creates a partial function identifier for use in place of raw scripts in gdash functions, or with the use of _ run.
0 commit comments