Data Packs Other

CC - ADMF

  • Functions
  • 2,397 views • 1 today
  • 89 downloads • 0 today
  • 0
  • 0
Typocat
Level 10 : Journeyman Miner
0

Computer Craft - Additional Data Manipulation Functions



This datapack for 1.16.5 will add additional small amount functions in table and string APIs for little bit easier data manipulations.
Requires CC: Tweaked for 1.16.X!
(Functions code can be found in rom/autorun/autorun.lua)


Table API additions:
Table table.sub(table, from, to)Returns table fragment starting and ending by a specific value
Similar to string.sub()
table -- table to manipulate with. <Table>
from -- start of fragment <Number>
to -- end of fragment <Number>

Number table.find(table, sample, ?from, ?to)
Returns position of sample in table. Returns 0 if cant find
Similar to string.find()


table -- table to manipulate with. <Table>
sample -- sample of value that you want to find <Any>
from -- start of searching <Number> (Optional)
to -- end of searching <Number> (Optional)

Table table.mfind(table, sample, ?max, ?from, ?to)Returns table with positions of sample. If it cannot find more than one, it returns an empty table. Use when need to find many of sample.
table -- table to manipulate with. <Table>
sample -- sample of value that you want to find <Any>
max -- max count of found samples <Number> (Optional)


from -- start of searching <Number> (Optional)
to -- end of searching <Number> (Optional)


String API additions:
Table string.split(string, delimiter)Returns table with splitted by delimiter string. Big thanks to this answer on Stack overflow
string -- string to manipulate with. <String>
delimiter -- delimiter to split string <String>

Table string.onechar(string)Returns table with all characters in string.
string -- string to manipulate with <String>

String string.joinchar(table)Returns string with joined characters what are being in table.
table -- table to manipulate with. <Table>


Feedback
Please, if you see error or if function works invalid, make consider leave a comment below with message of error or description of problem. I really need feedback for fixing this.
Also you can suggest an idea for new function!
CompatibilityMinecraft 1.16
Tags

  Have something to say?

Welcome