ARRAYS (= LISTS) in TeaScript !

Description: You made a script? Submit it here to show your creation to the public, share, take reviews, provision of the help and support is here!
Moderators: Yoshi021, Lx Xzit, 5438A38A, TepigFan101, Moderators

JDM M
Topic author, Nice citizen
Nice citizen
Avatar
JDM M
Topic author, Nice citizen
Nice citizen
Age: 18
Reputation: 2
Posts: 10
Joined: 14 Aug 2016

Post #1by JDM » 22 Aug 2016, 22:06

I don't know if you're like me, but when I discovered Tea-Script, I was really disappointed that Arrays (= lists) don't exist in Tea-Script ... So I recreate them ! You can find the script in the attachments.

What is included ?
> Add & Remove elements from an array
> Get & Set elements with their indexes in an array
> Get length of array (can be used to make FOR loops)
> Concatenation of arrays
> Split a string in an array and vice versa
> Reverse arrays
> JSON format

What will be included in further updates ?
> Math functions (like sums, products, max, min, etc)
> Randomize order of the elements in an array
> Detection of incorrect arrays (now if you use an array that is wrong parsed, i'm not sure about the result ... in the future, it should return errors)
> Dictionnaries (indexes are keywords)
> Search & Replace options in arrays

Restrictions
> Can't use apostrophe in strings

Documentation (available in the downloadable level) :
Spoiler
'NOTE : The terme "object" means both array and dictionnary
'Objects are (in this script) only strings (powered by JSON)

'==> cAR()
'Returns "[]" which is the base of all arrays

'==> arL(array)
'Returns array length (double)
'array(string) : the array (JSONified)

'==> aAR(array, item, parsing)
'Add an item to the end of the array, then returns this array
'array(string) : the array (JSONified)
'item(string) : the item to add (if you want to add a double, you must convert it in string first)
'parsing(double) : if not 1, the item will be quoted with ' (as a string) => set 1 if item is a number, an object, or a string already quoted

'==> gtA(array, index)
'Returns the item in index specified from array (PS : even if this item is a double, it will be returned as a string ; the "true" strings are quoted with ' )
'array(string) : the array (JSONified)
'index(double) : the index of the item wanted
'PS : if index incorrect, return empty string
'PS2 : the first item is 1 and not 0 !

'==> spS(string, delimiter)
'Returns an array which is the specified string splited by the delimiter
'I.E. spS("t;es;t", ";") => "['t','es','t']" ; spS("t;;e;s;;t", ";;") => "['t', 'e;s', 't']"
'string(string) : the string to split
'delimiter(string) : the delimiter (if empty string, the returned array will contain each caracter in the string separately)

'==> rmA(array, number)
'Removes a certain number of items from the end
'I.E rmA("[1,2,3,4,5]", 2) => "[1,2,3]"
'array(string) : the array (JSONified)
'number(double) : the number of items to remove

'==> rvA(array)
'Reverses the array
'I.E. rvA("[1,2,3,4,5]") => "[5,4,3,2,1]"
'array(string) : the array (JSONified)

'==> shA(array, number)
'Removes a certain number of items from the beginning
'I.E rmA("[1,2,3,4,5]", 2) => "[3,4,5]"
'array(string) : the array (JSONified)
'number(double) : the number of items to remove

'==> ctA(arrayA, arrayB)
'Returns the concatenation of the two arrays
'I.E. ctA("[1,2,3]", "[4, 5, 6]") => "[1,2,3,4,5,6]"
'arrayA(string) : first array (JSONified)
'arrayB(string) : second array (JSONified)

'==> inA(arrayA, arrayB, index)
'Insert array B in array A at index
'I.E. ctA("[1,2,3]", "[4, 5, 6]", 2) => "[1,2,4,5,6,3]"
'arrayA(string) : first array (JSONified)
'arrayB(string) : second array (JSONified)
'index(double) : index of insertion

'==> exA(array, index, number)
'Remove number of elements from index, from array
'I.E. exA("[1,2,3,4,5,6,7,8,9]", 3, 4) => "[1,2,7,8,9]"
'array(string) : the array (JSONified)
'index(double) : where start to remove elements
'number(double) : number of elements to remove

'==> stA(array, index, item, parsing)
'Set the element in array at index to item
'array(string) : the array (JSONified)
'index(double) : the index of the item to set
'item(double) : the item to add (if you want to add a double, you must convert it in string first)
'parsing(double) : if not 1, the item will be quoted with ' (as a string) => set 1 if item is a number, an object, or a string already quoted

'==> jnS(array, junction)
'Joins every elements in array in a string
'array(string) : the array (JSONified)
'junction(string) : what will be inserted between each element

> How can you help me ?
Feedbacks are useful and encouraging (tracked bugs, wanted features, comments ...), so if you have one feedback to send to me, don't hesitate ! Also I'm not sure about my english skills in the documentation, if you want to contribute, it can be a way to help me ;-) .

I hope it will be useful for you !
Attachments
arrays.lvl
The script Version 1.0.0
(34.38 KiB) Downloaded 51 times

Yoshi021 M
Moderator
Moderator
Avatar
Yoshi021 M
Moderator
Moderator
Age: 17
Reputation: 75
Posts: 623
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #2by Yoshi021 » 22 Aug 2016, 22:36

Spoiler
Image
Arrays do exist, but you have to beat a mini-game to unlock it.
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:

JDM M
Topic author, Nice citizen
Nice citizen
Avatar
JDM M
Topic author, Nice citizen
Nice citizen
Age: 18
Reputation: 2
Posts: 10
Joined: 14 Aug 2016

Post #3by JDM » 22 Aug 2016, 22:46

You're serious ? xd
I never found anything about arrays (documentation, tutorials or whatelse) so I assumed that they didn't exist ... how do they work ? What mini-game we have to do in order to unlock it ? Are them exportable for the one who don't beat the minigame ?

Yoshi021 M
Moderator
Moderator
Avatar
Yoshi021 M
Moderator
Moderator
Age: 17
Reputation: 75
Posts: 623
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #4by Yoshi021 » 22 Aug 2016, 23:05

phpBB [youtube]

Original link: https://www.youtube.com/watch?v=6oN9WPf8HFE


Video to help you solve the minigame.
Minigames List
You need to beat the "Move the Circles" mini-game.
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:

TepigFan101 M
Moderator
Moderator
Avatar
TepigFan101 M
Moderator
Moderator
Age: 16
Reputation: 28
Posts: 109
Joined: 12 Aug 2016

Post #5by TepigFan101 » 23 Aug 2016, 9:58

Im kinda Lost. What do Array's Do? is it like a type of Variable? Script? or Event? sorry, started SMBX mainly on 1.4 so I don't Know.
Current Project : SMTFA
Coming Soon: NSMB DS Remake

I'm a nice and cheerful guy, so give me a holler if you need something! :gamer:

Discord:https://discord.gg/3HKcnFJ
Come to my discord to learn more about my stuff!


Return to “Script submission”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest