https://github.com/mystpi/scratchstatus
Dynamic status systems for Scratch and the web.
https://github.com/mystpi/scratchstatus
Last synced: about 1 year ago
JSON representation
Dynamic status systems for Scratch and the web.
- Host: GitHub
- URL: https://github.com/mystpi/scratchstatus
- Owner: MystPi
- License: mit
- Created: 2023-10-18T14:09:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-19T22:03:19.000Z (over 2 years ago)
- Last Synced: 2024-04-20T10:04:15.004Z (about 2 years ago)
- Language: TypeScript
- Homepage:
- Size: 75.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scratch Status
Dynamic status systems for Scratch and the web.
## Using the pre-made [Scratch status system](/src/scratchstatus/)
This system was made for use in [ocular](https://ocular.jeffalo.net).
```ts
import { scratchstatus } from 'scratchstatus';
const status = `I have {followers} followers.`;
scratchstatus.run(status, 'NFlex23').then(console.log);
```
## Creating a custom status system
```ts
import { createConfig, createSystem } from 'scratchstatus';
const config = createConfig({
initState: (username) => ({
username,
count: 1,
}),
});
const system = createSystem(config, {
username: {
args: [],
description: 'Returns your username',
do: (_, { username }) => username,
},
join: {
args: ['a', 'b'],
description: 'Joins a and b together',
do: ([a, b]) => `${a}${b}`,
},
count: {
args: [],
description: 'Count by 1',
do: (_, state) => {
return state.count++;
},
},
});
const status = `I am {username}. {join "Hello, " "World!"}. Counting 1-3: {count}, {count}, {count}`;
system.run(status, 'MystPi').then(console.log);
```