CCI

Navigation

  • Home
  • Getting Started
    • First Launch and Setup
    • Sockets: Which One To Pick
    • Finding Your Socket Key
      • Streamlabs
      • StreamElements
      • DonationAlerts
      • Twitch PubSub
      • Twitch Chat
      • YouTube Chat
    • The CCI Editor
    • Dissecting an Event
    • The Anatomy of an Event Configuration
    • Processing an Event
    • The Client Mod Config File
    • CCI on Servers
  • Intermediate Guides
    • Intermediate Difficulty, the old Advanced Difficulty
    • Getting the Most Out of Your Event Configuration
    • Constants, the Solution to Insanity
    • I'm Making A Note Here, Huge Success!
    • Debugging the PEBKAC Issue
    • Configuring a Socket Remotely with Online Configs
  • Advanced Guides
    • Advanced Difficulty, the new Advanced Difficulty
    • Libraries: Not The Book Kind
    • Debugging When Debugging Fails
    • When Variable Insertion Goes Wrong
    • Defaults: Setting Variables on Load
    • Strings: Untying the Knot
    • Arrays: The Black Sheep of Variables
  • Expert Guides
    • Expert Difficulty, for Advanced Advanced Users
    • Game Event Hooks: The Config Maker's Nightmare
  • How To's
    • How To's, a How To
    • Commonly Asked How To's
    • Capturing Twitch's Channel Point Rewards
    • Converting a Twitch Name to Minecraft Name
      • How it works, a summary
      • How it works, the long version
  • Libraries
    • Still Not The Book Kind
  • Components
    • Event Configuration
      • Event Configuration
      • Configuration
      • Event
      • Condition
        • Condition
        • Array
          • ArrayAppendCondition
          • ArrayCombineCondition
          • ArrayCondition
          • ArrayDeleteCondition
          • ArrayExplodeCondition
          • ArrayLengthCondition
        • String
          • Unconditional
            • Base64DecodeCondition
            • Base64EncodeCondition
            • StringCompareToCondition
            • StringConcatCondition
            • StringIndexOfCondition
            • StringLengthCondition
            • StringLowerCaseCondition
            • StringReplaceCondition
            • StringSplitCondition
            • StringTrimCondition
            • StringUpperCaseCondition
          • StringContainsCondition
          • StringEndsWithCondition
          • StringEqualsCondition
          • StringStartsWithCondition
          • StringSubStringCondition
        • Variable
          • Unconditional
            • VariableInsertCondition
            • VariableRemoveCondition
          • VariableCondition
          • VariableExistsCondition
          • VariableIsArrayCondition
          • VariableIsNumberCondition
        • Unconditional
          • ArithmeticCondition
          • LocalisedStringCondition
          • LogArgsCondition
          • NullCondition
          • RandomNumberCondition
          • RandomStringCondition
          • RepeatCondition
          • RequestStatisticsCondition
        • ConditionalCondition
        • ConstantCondition
        • GameSettingsCondition
        • InventoryCondition
        • JsonSafeCondition
        • MessageCondition
        • ModExistsCondition
        • MultipleConditionCondition
        • NoteCondition
        • NotesListCondition
        • PlayerStateCondition
        • RandomCondition
        • RangedAmountCondition
        • ReadFileCondition
        • ServerCondition
        • SpecificAmountCondition
        • SpecificUserCondition
        • StatisticsCondition
        • TargetCondition
        • TargetExistsCondition
        • TwoHighSpaceCondition
      • Outcome
        • Outcome
        • CCI
          • CCIChangeProfileOutcome
          • CCIClearQueueOutcome
          • CCIFromJsonOutcome
          • CCISendEventToSocket
          • CCISendToPlayerOutcome
        • ChatMessageOutcome
        • CommandOutcome
        • ConditionalOutcome
        • ConstantOutcome
        • EventOutcome
        • FakeCrashOutcome
        • FoodOutcome
        • GameCrashOutcome
        • GameSettingsOutcome
        • HealthOutcome
        • IMCOutcome
        • InputOutcome
        • InventoryOutcome
        • KeyPressOutcome
        • MotionOutcome
        • MountOutcome
        • MultipleOutcomeOutcome
        • NarratorOutcome
        • NoteDeletionOutcome
        • NoteOutcome
        • NullOutcome
        • ObjectAccessorOutcome
        • PopupOutcome
        • PromptOutcome
        • ReadFromUrlOutcome
        • RepeatOutcome
        • SoundOutcome
        • ToastOutcome
        • WriteToFileOutcome
      • Constants
    • Game Event Config
      • Game Event Config
      • Listener
      • Object Accessor
      • Param Injector

How to: Converting a Twitch Name to Minecraft Name

One of the commonly asked questions is getting users to convert their twitch name to MC name. Unfortunately, there is no online service for people to reference, so all of this has to be done by hand.

Before we begin, I expect you to already have a basic understanding of CCI, and a basic understand of how Notes work.

How it works, a summary

If a user had defined their Minecraft name in the past, it gets saved to a note. When using their username, we look up to see if the note exists. If it exists, we use the name saved, otherwise we fall back to their username.

How it works, the long version

Capturing a chat message

We’ll be using Twitch Chat for this example. First off, we want to capture a message if the user says something with a specific prefix. We will be using the !setmcname prefix here. Make a new Config Event and bring it up above the other Events, we want this to trigger before the other events trigger as we will be short circuiting the event flow.

In your conditions, make a new StringStartsWithCondition, set the source to $message and the target to !setmcname. That space in the target is not accidental, most of the time when users trigger the command, there will be a space between the command and the argument, eg: !setmcname iChun.

Next, you want a substring of the message, to clip out the argument. Use a StringSubStringCondition here, and set the source to $message the beginIndex to 11. That removes the first 11 characters in the message variable. Put the result in nameArg.

Now, we want to trim any whitespace the user may have left at the end of the argument, so we use a StringTrimCondition. Set the source to $nameArg and result to nameArg, we’re just going to reuse the variable here.

And that’s it, we now have the chat message argument.

(Alternatively, you could also do a Channel Point Reward for this, but I’m also using this tutorial to teach String manipulation.)

Next up:

Saving the MC name into a Note

For sanity sake, we should lowercase the name of the user. Make a StringLowerCaseCondition and put source as $user and result as userLC.

We have our MC name for the user in nameArg. Now we want to save it into a Note. Use a NoteOutcome. We don’t need anything special here, just set noteName to mcName_$userLC and noteContent to $nameArg. When this Outcome triggers it’ll make a new note with their MC name as the content.

If you want, for debugging, make a ChatMessageOutcome or something to confirm the note was created. After the note was created, you can also check the Event Viewer to see your notes.

Loading up the Note

So, wherever before you want to use the MC name, you need to lowercase the user’s name again, for consistency sake, put it in $userLC. Now for the NoteCondition. For noteName, put mcName_$userLC, and for variableName, put mcnameuser. That loads up the note and puts the value into the $mcnameuser variable.

Now, what if the user has never defined their MC name. Set meetConditionIfNoteDoesNotExist to true, and defaultVariableValue to $user. This ensures that the $mcnameuser always has a value in it, be it the note content, or the user’s name. When you want to spawn a mob with the user’s MC name, just use $mcnameuser instead of $user.

Built with MkDocs using a custom theme. Hosted by Read the Docs. ReadTheDocs project base taken from Minecraft Forge with permission.
Enable Dark Theme