EtG Modding Guide
  • ETG Modding Guide
  • Getting started
    • Modding EtG: Installing Mods
    • Modding EtG: Creating a Mod
    • Uploading a Mod
    • Useful Tools
      • Using IlSpy
  • Making An Item
    • Creating A Passive
    • Creating An Active
    • Creating An Ammolet
    • Creating A Guon
    • Synergies
  • Making a Gun
    • Creating A Gun
      • Setting Up Gun Sprite Folders
      • Creating Gun Jsons/Jtk2ds
        • Pixel Measurement Conversions
    • Setting Up Projectiles
      • Adding Components To A Projectile
      • Projectile HitEffects (Visual Effects)
      • Adding status effects to a projectile
    • Continuous Fire Animations
    • Gun Ammo Types
  • Custom Characters
    • Creating A Standalone Custom Character
  • Making a Floor
    • Introduction
    • Setup
    • Making The Dungeon
    • Tileset
    • Rooms
    • Making the flow
    • Making the Entrance
    • All Files
  • Text, Text Boxes, Etc
    • Textboxes
    • Text Formatting
  • Sounds
    • Using Custom Sounds
    • Customising Gun Sounds
    • Basegame Sound List
    • wwise Sound Dump
  • Misc
    • Making Asset bundles
    • Assetbundles: How-To
    • How to create a hook
    • Creating A Command
    • Subscribing Methods to Actions
    • Reversing Player Controls
    • Undodgeable Projectiles
    • Creating An Enemy
  • Shaders
    • Creating Shaders
  • All things Spriting
    • Important Sprite Creation Information.
    • Importing a Sprite To Visual Studios
  • Monobehaviour Documentation
    • BounceProjModifier
    • PierceProjModifier
    • KeyProjModifier
    • CompanionFollowPlayerBehaviour
  • Various Lists of IDs, Sounds, Etc.
    • List of Item and Gun IDs
    • Enemy Guids
    • List of Base Game Synergies
    • dfSpriteList
    • All Custom Ammo Types
    • Gun .Json Dump
  • TwitchAPI and poll system guide
    • introduction and general functionality
  • The GlobalChatDelegate and GlobalToggleStatusNotification events
  • The poll system
  • Example of simple mod that uses polls
  • OFF TOPIC MEMES
    • Modders Anthem
Powered by GitBook
On this page

Was this helpful?

The poll system

Since mods that create a poll and let users vote on events are popular, a poll system exists in tapi. the idea being to queue polls in an orderly manner, and avoid instances where polls clash or cover each other.

generally speaking, there will be 3 tapi components you will be using. "MainPollController", handles poll behavior, used for submitting polls. "Poll", a class for storing poll information. Each poll class contains instances of the "VoteOption" class, which represnt things you can vote for.

The poll class:

contains your basic poll info. Can be submitted to "mainPollController" to enqueue a new poll.

has the following properties public int time; //the time, in seconds, a poll runs for. public string name; //internal name public string title; //poll title to be displayed above the options. public List options; //an array of "VoteOptions". that can be voted for. public Action callBack = null; //An action that gets called when the poll concludes. If null, skips the call. Passes Poll type as parameter, usually itself.

"public resolvePollOptions resolveSettings;" //each voteOption may have its own callback. At the end of the poll, the winning vote callback will be called if not null. This setting allows you to resolve ties, or call none of vote callbacks. public enum resolvePollOptions { mainOnly = 0, //only calls the callback of the poll. Useful for resolving edge cases. Remember each poll contains its own options randomIfTie = 1,//in case multiple options tie, choose one at random noneIfTie = 2,//if there is a tie, call only main poll callback AllIfTie = 3//call all option callback }

remember that the main poll callback is ALWAYS called, and always happens before the automatic VoteOption callbacks.

The poll class has the following constructors public Poll(int time, List options, string title, Action callBack,resolvePollOptions resolveSettings ,string name = null) makes a new poll

public Poll(Poll poll) makes a copy of a poll

VoteOption class: represents an option users can vote for. Has the following properties

public string displayText;//text displayed to the voters public int votes; //vote counter private Action callBack = null;// callback which happens if vote wins. Passes VoteOption as paramaeter, usually itself.

MainPollController.

this is how you submit polls. You can access it by MainPollController.Instance

mostly used with the "SubmitPoll(Poll)" method example

MainPollController.instance.SubmitPoll(poll);

There are a couple things to note. When submitting a poll, youre putting it into a queue. There may be another poll in progress, or it may be on a short coolDown. The poll does not instantly start.

SubmitPoll returns a boolean value. If it returns false it means it failed and did NOT enqueue your poll.

usually this happens because it tries to validate your poll. If you poll a.is null, b.has no vote options or c. vote options have no display text.

another important thing to note, is that submit poll does not enqueue your submitted poll object, but a COPY of your poll object. This copy will be sanitized in the following ways to not break ui/user exprience. a.any vote options with text more than 50 characters will be reduced to 50 characters

b.any newline charactes will be replaced with empty character

c. if your poll has more than 4 vote options, all but the first 4 will be removed.

please try to keep your polls and vote options valid as to not encounter unexpected results.

PreviousThe GlobalChatDelegate and GlobalToggleStatusNotification eventsNextExample of simple mod that uses polls

Last updated 5 days ago

Was this helpful?