A compass for the maze.
Hi all! @cjw, @choicehacker, and I would like to introduce to you CSLIB v0.1!
CSLIB is a high-quality collection of helpful routines/functions (known collectively as a ālibraryā) for ChoiceScript.
CSLIB aims to add a whole host of new functionality to ChoiceScript via *gosub_scene
calls, for e.g.:
*gosub_scene cslib_string reverse āHello World!ā
${cslib_ret} = !dlroW olleH
āØ Features
CSLIB provides handy ready-made routines that allow you to do things like:
- Manipulate strings (concatenate them, force them to lowercase, grab a substring)
- Present simple choices/menus in just a couple of lines of code
- Perform mathematical and numerical functions (min, mean, max, sin, cos, pi)
- Better support working with ChoiceScript āarraysā (grow/shrink, loop over, filter, clone)
And best of all? The library itself is written in 100% vanilla ChoiceScript (thereās no *script usage here!), so you are absolutely free to use it in any games you plan to publish. And for added confidence, weāve given CSLIB its own test suite, with over 100 individual unit tests to help maintain and assure users of its quality.
š Installation Instructions
ā
- Copy the module files (the ones that start with
cslib_
) to your game folder, together with your scene files. - Create a global variable called
cslib_ret
to hold return values. - Create/set
implicit_control_flow
to true.
__startup.txt__
*create implicit_control_flow true
*create cslib_ret 0
- Thatās it!
For more details on how to use, contribute or what you can do, visit the projectās page.
š List of Functions (not necessarily up-to-date)
cslib_util:
- repeat
cslib_number:
- is_number
- are_numbers
- mean
- max
- min
- max_stat
- min_stat
cslib_menu:
- build_array
- build_array_filter
- build_simple
- build_simple_cancel
cslib_string:
- concat
- lowercase
- substring
- find
- replace
- index
- reverse
- contains
- consists_of
- extract_tokens
cslib_array:
- filter_by_routine
- clone
- clean
- set_all
- set_from
- set
- unshift
- push
- insert
- shift
- pop
- remove
- join
- reverse
- for_each
- test_any
- test_some
cslib_math:
- pi
- sin
- cos
- sinh
- cosh
ā
json
{
"cslib_util": [
"repeat"
],
"cslib_number": [
"is_number",
"are_numbers",
"mean",
"max",
"min",
"max_stat",
"min_stat"
],
"cslib_menu": [
"build_array",
"build_array_filter",
"build_simple",
"build_simple_cancel"
],
"cslib_string": [
"concat",
"lowercase",
"substring",
"find",
"replace",
"index",
"reverse",
"contains",
"consists_of",
"extract_tokens"
],
"cslib_array": [
"filter_by_routine",
"clone",
"clean",
"set_all",
"set_from",
"set",
"unshift",
"push",
"insert",
"shift",
"pop",
"remove",
"join",
"reverse",
"for_each",
"test_any",
"test_some"
],
"cslib_math": [
"pi",
"sin",
"cos",
"sinh",
"cosh"
]
}
We hope CSLIB can provide the community with an accessible and fully supported way of extending the functionality of the ChoiceScript language, without relying on hacks, mods, or untested snippets of code. We wanted to encourage the creation of something that could be built for and by all users of ChoiceScript. We hope it will help people learn and grow, together as a community. What weāre showing you here is really just the beginning, a framework or base architecture. We hope you will all help us extend and improve on it over time. For example, have you ever wondered how you would implement a substring function in ChoiceScript? Go take a look! Did you spot a bug, or think you can optimize a routine? Submit a patch!
You can download it, here:
Play around with it in a CSIDE-based playground, here:
See a small example of a game (with comments) using it, here:
And find information about usage and installation, here:
Please do let us know what you think. As mentioned above, weāre in the very early stages here, and very keen to hear all kinds of feedback.
Special thanks to @sargent and @twiger_fluff for their suggestions.