Git Product home page Git Product logo

coin-toss-se-widget's Introduction

Coin Toss

This StreamElements custom widget visualizes the outcome of a random distribution (e.g. a coin toss).

Special thanks to Benno and Reboot0.

Description of operation:

The widget comes with multiple video pools (one per possible outcome).
When the associated command has been detected in chat, a random pool is picked and from that a random video is played.

The number of videos in a pool does not affect the probability.

See also this demonstration video.

Adding additional outcomes:

Let's say we need 6 outcomes for the visualization of a dice.

Here are the steps needed:

  • Enter the Overlay Editor on the StreamElements website
  • Select the widget
  • Open the "Settings" segment in the navigation (on the left)
  • Click on "Open Editor"
  • Add UI segments to the structure in the "Fields" tab / JSON file (see below)
  • Add the new prefixes to the list in the "JS" tab / JavaScript file (see below)
  • Populate the new video pools via the UI

JSON

By default, there are two outcome segments, which you can use as a template.

An outcome segment consists of

  • a video-input field ending with the suffix _url.
  • a number selection field ending with the suffix _volume.
  ...
  
  "outcome2_url": {
    "type": "video-input", 
    "label": "Videos:", 
    "multiple": true, 
    "group": "Outcome #2"
  }, 
  "outcome2_volume": {
    "type": "slider", 
    "label": "Volume:", 
    "min": 0, 
    "max": 100, 
    "value": 55, 
    "group": "Outcome #2"
  }, 
  
  "outcome3_url": {
    "type": "video-input", 
    "label": "Videos:", 
    "multiple": true, 
    "group": "Outcome #3"
  }, 
  "outcome3_volume": {
    "type": "slider", 
    "label": "Volume:", 
    "min": 0, 
    "max": 100, 
    "value": 55, 
    "group": "Outcome #3"
  }, 
  
  ...
  
  "outcome6_url": {
    "type": "video-input", 
    "label": "Videos:", 
    "multiple": true, 
    "group": "Outcome #6"
  }, 
  "outcome6_volume": {
    "type": "slider", 
    "label": "Volume:", 
    "min": 0, 
    "max": 100, 
    "value": 55, 
    "group": "Outcome #6"
  }, 
  
  ...

JavaScript (JS)

...

const outcomePrefixes = [
  "outcome1", 
  "outcome2",
  "outcome3",
  "outcome4",
  "outcome5",
  "outcome6"
];

...

Used libraries:

coin-toss-se-widget's People

Contributors

afoeee avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.