скрипт-плейер визуальной новеллы с использованием инструкций из html. State machine. Do…
- User
скрипт-плейер визуальной новеллы с использованием инструкций из html. State machine. Do not parse or make lists, step when clicking. make single html, avoid useless comments, short syntax, single tab indent
const DEFAULT_STEPPED = ['SECTION','DIV']; список тегов которые сами не добавляют напрямую контент, но их дети обрабатываются. все остальные добавляют целиком своё содержимое за один шаг без проверок вложенных элементов. Поведение можно переопределить
const STOP_AFTER = ['P', 'SECTION', 'BR'];
data-mode //state machine , set current mode. '' by def data-q=""//clear data-q="bg" data-bg="https://picsum.photos/seed/1/800/200" data-q="bg" data-bg="#ccc" data-q="bg_clear"
1 clean if element with data-q="clear" element section, br
2 exec other actions from data-q
3 view innerHTML+=
4 script flow if available set mode=data-mode mode==0 //from now any element cause stop mode==1 //from now any element continue
codeif mode==0 ? consider g=0 if mode==1 ? g=1 if mode=="" ? then check: has integer data-g ? g=data-g ; goto g; return else id=data-g ; goto element by id; return p, section, br: by default same as g==0 this mean stop and wait Next call. Note this act after all internal elements so stop is after tag but not before it. other elements : by default same as g==1 this mean continue loop move pointer by g positions. Usually this mean to next elementconsole log step, tag, mode, calculated g, actions in place where they did for debug make border around content current element
typical bugs:
- не происходит переход на следующий элемент, а нужно нажимать много раз на кнопку и игнорируется что элементы должны выполнятся все до рассчитанного data-g==0
- failed jump to id data-g="a1" in the script end (хотя переход в начале работает)
- баг после перехода по id (в конце) ломается очистка. возможно криво реализовна рекурсия, я думаю тут рекурсия совсем не нужна, but need only keep current element and mode, чтобы ход выполнения всегда был прямой. State machine. so only next instructions affect but not changed parent after jumps.
code - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.