add new play preset

This commit is contained in:
syuilo 2023-01-17 17:10:33 +09:00
parent 8f0c598772
commit d75225e23b
1 changed files with 84 additions and 0 deletions

View File

@ -95,6 +95,85 @@ Ui:render([
])
`;
const PRESET_SHUFFLE = `/// @ 0.12.2
//
let string = "ペペロンチーノ"
let length = string.len
//
var results = []
//
var cursor = 0
@do() {
if (cursor != 0) {
results = results.slice(0 (cursor + 1))
cursor = 0
}
let chars = []
for (let i, length) {
let r = Math:rnd(0 (length - 1))
chars.push(string.pick(r))
}
let result = chars.join("")
results.push(result)
// UI
render(result)
}
@back() {
cursor = cursor + 1
let result = results[results.len - (cursor + 1)]
render(result)
}
@forward() {
cursor = cursor - 1
let result = results[results.len - (cursor + 1)]
render(result)
}
@render(result) {
Ui:render([
Ui:C:container({
align: 'center'
children: [
Ui:C:mfm({ text: result })
Ui:C:buttons({
buttons: [{
text: "←"
disabled: !(results.len > 1 && (results.len - cursor) > 1)
onClick: back
} {
text: "→"
disabled: !(results.len > 1 && cursor > 0)
onClick: forward
} {
text: "引き直す"
onClick: do
}]
})
Ui:C:postFormButton({
text: "投稿する"
rounded: true
primary: true
form: {
text: \`{result}{Str:lf}{THIS_URL}\`
}
})
]
})
])
}
do()
`;
const PRESET_TIMELINE = `/// @ 0.12.2
// API
@ -175,6 +254,11 @@ function selectPreset(ev: MouseEvent) {
action: () => {
script = PRESET_OMIKUJI;
},
}, {
text: 'Shuffle',
action: () => {
script = PRESET_SHUFFLE;
},
}, {
text: 'Timeline viewer',
action: () => {