Swiftpack.co - mui-z/EffectiveNovelCore as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by mui-z.
mui-z/EffectiveNovelCore 1.1.2
This is novel text parse and stream provide swift package.
⭐️ 3
🕓 4 weeks ago
iOS macOS
.package(url: "https://github.com/mui-z/EffectiveNovelCore.git", from: "1.1.2")

workflow status License Swift Twitter

Effective Novel Core

This is novel text parse and provide display event stream package.

About

This is novel engine.

This effectively helps to display the characters of the novel.  

This lib doesn't include UI layer. This only provides parse and output stream display event. (Example of use: EffectiveNovelReader)

Also, this lib is not optimized novel game.
Because this doesn't have if functioned, macro, subroutine.

If you use it for such a purpose, please parse it each time on the application side to use it.

Syntax

Use tags to control how they are displayed.

This syntax is based on Tyranoscript.

Syntax Tags

Tags must be enclosed in [].    

When commenting out, put # at the beginning.
If you want to use #, write \\#

tag DisplayEvent description
n .newline newline
tw .tapWait tap wait
twn .tapWaitAndNewline tap wait and newline
cl .clear clear
sleep duration=xxxx .sleep(duration: Double) sleep for the specified time. duration unit is milliseconds.
delay speed=xxxx .delay(speed: Double) change delay character displayed speed. speed unit is milliseconds.
setDefaultDelay speed=xxxx .setDefaultDelay(speed: Double) change default delay character displayed speed. speed unit is milliseconds.
resetDelay .resetDelay reset delay speed
e .end stop script novel end point

Example Novel Script

# Sample Script
tap waiting and newline[twn]

[cl] cleared text.

very fast stream after this text[delay speed=2][n]

displaying!!!!!!

[resetDelay]reset delay speed.[n]

end. [e]

Usage


// 1. get `NovelController` instance
let controller = NovelController()


// 2. load raw novel text
let result: ValidateResult<EFNovelScript, [ValidationError]> = controller.load(rawText: rawText)

let novelScript: EFNovelScript

switch result {
case .valid(let script):
    novelScript = script
case .invalid(let errors):
    print(errors)
    // handle error.
}

// 3. start() and listening stream
controller.start(script: novelScript)
          .sink { event in
              switch event {
              case .character(let char):
                  displayCharacter(char)
              // and any command handling
              }
          }
          .store(in: &cancellables)

// (4.) show text until wait tag
controller.showTextUntilWaitTag()

// (5.) pause stream.
controller.pause()

// (6.) resume from pause
// If you want to start from any index number, you can use `controller.resume(at: 100)`
controller.resume() 

// (7.) interrupt
controller.interrupt()


Examples

Todo

  • ☐ value input
  • ☑ novel text validator
  • ☑ rearchitecture
  • ☐ Swift-DocC
  • ☑ comment out syntax

LICENSE

EffectiveNovelCore is licensed under the MIT License

GitHub

link
Stars: 3
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.1.2
4 weeks ago

What's Changed

Full Changelog: https://github.com/mui-z/EffectiveNovelCore/compare/1.1.1...1.1.2

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics