codely.js documentation

this page is really basic and unfinished like the library itself
but you can still read about functions and stuff here
also, this page has codely.js linked! so you can test a few functions in the console right here by using the shortcut and then clicking "console"



1. installing the library


the library is only in web form right now but MIGHTTT be released as a downloadable... its still best to use the web form for the latest changes and stuff without having to download and download and download

  1. type this in your html

    preferably at the bottom of the (or the if an error happens)
  2. uhh thats it, simple as that

2. learning simple stuff

in this part, youll learn a few simple things like settings and memory

  1. settings (cly.manage)
    1. youll need to enable a few settings before using some functions
      1. write to enable cly.event.broadcast functions, false by default
      2. write to disable cly.console functions, true by default
    2. warnings are great to warn devs about errors, but if you for some reason dont like it
      1. use to disable warnings, true by default
    3. theres also a setting for the cool ticking system
      1. write to set a limit for scheduled actions using cly.tick
    4. you could also use and , pretty self-explanatory
  2. memory (cly.memory)
    1. codely.js has a nice memory feature with 8 slots A-H if youre too lazy to write your own variables
    2. to reference a variable, you can use and enter a letter A-H as the argument
    3. you can reset the memory with
    4. you can dump all memory with , youre also able to get a slot this way too with
  3. references (cly.references)
    1. other scripts can use cly.references to get runtime information
      1. to get the last error (if there was any)
      2. to get the last function used
      3. to get the last arguments used for a function, gives an array if there are multiple
    2. you can reset the references with
  4. you can get basic information with
    1. for classes, formatted as
    2. for how many lines the library has
    3. for how many functions the library has
    4. for the version of your codely.js
    5. for where the library is loaded
    6. for a small guide on how to use codely.js
    7. for the types of errors, formatted as
  5. aliases
    1. codely.js uses aliases for faster writing
      1. im just gonna paste part of the code because im too lazy to type it all
        this is just a barebones version of the documentation so yeah

3. best part!!! functions

this took a while
you can check the actual library code for a more up-to-date list

path function what for
cly.test checkFunction(path) checking if a function exists before using it
cly.test confirm(condition, value, strict = false) confirming something, optionally with a strict () mode
not to be confused with the browser's confirmation dialog
cly.math add(a, b) addition with a and b
cly.math subtract(a, b) subtraction with a and b
cly.math multiply(a, b) multiplication with a and b
cly.math divide(a, b, fixed) division with a and b, optionally with a fixed mode to return a instead of a warning when dividing by zero
cly.math random(min, max) getting a random decimal between min and max
cly.math round(number) rounding a decimal, good for cly.math.random(min, max)
cly.math pi(digits) getting 2-15 digits of pi
15 because thats the limit for javascript and 2 because 3.1 or just 3 isnt cool for pi
cly.string capitalize(str) capitalizing strings
cly.string reverse(str) reversing strings
cly.string count(str, char) counting how many times a character shows in a string
cly.string recase(str, type) changing the casing of a string
supports Capital case, camelCase, PascalCase, snake_case, kebab-case, Title Case, UPPER CASE, lower case, flatcase, dot.case, Arrow > Case, path/case/, Keyboard+Case and codely[case], use the first word of one as the type argument
cly.event.broadcast transmit(id, value, key) transmitting a broadcast with id, value and key
cly.event.broadcast update(id, newValue, key, newKey) updating a broadcast with a new value and optionally a new key
cly.event.broadcast receive(id, key, expected, whenYes, whenNot) receiving a broadcast, doing something when the value is expected and something else when not
cly.event.broadcast offAir(id, key) taking a broadcast off-air
cly.event.broadcast list() listing all the broadcasts on-air with a nice structure
cly.event.broadcast ping(id) pinging a broadcast to make sure its on-air
cly.logic pauseFor(ms) pausing the script for milliseconds
requires
cly.logic repeat(times, orUntil, action) repeating an action for times or until orUntil is true
cly.logic forEachIn(collection, action) repeating an action for each item in a collection
cly.logic run(func) running a function
cly.logic.gate not(a) returning the opposite of a
cly.logic.gate and(a, b) returning true when both a and b is true
cly.logic.gate or(a, b) returning true when a or b is true
cly.logic.gate most(a, b, c, d, e) returning true when 3/5 inputs are true
cly.console title(text) ==== [ writing a nicely formatted title to console ] ====
cly.console list(root, ...branches) writing a nicely formatted list to the console
cly.console write(text, style) simply writing text to console, optionally with styling
cly.console clear() clearing the console
cly.tick run(speed) starting the ticking with speed (as ticks per second)
cly.tick pause() pausing the ticking
cly.tick get() getting the current tick the moment the function was called
cly.tick every(ticks, action) scheduling an action every amount of ticks
cly.tick after(ticks, action) doing something after amount of ticks since the function was called
cly.tick skip(ticks) skipping amount of ticks
cly.tick convert(tick) converting the given tick into seconds
cly.tick reset() resetting the ticking and clearing all scheduled actions