String Counting

BlackNerubia

New Member
Reaction score
12
Ok, i was wondering if there was a easy way to make a trigger count the Characters in a string and check for spaces?
 
S

Sunny_D

Guest
well, there is an integer preset "string length" to check the length of a string. but as that includes spaces as well you could do:

Code:
Display String Length
    Events
        Player - Player 1 (Red) types a chat message containing Empty String as A substring  
        [COLOR="red"]//* to detect if the player types [U]anything[/U] in chat[/COLOR]
    Conditions
    Actions
        [COLOR="red"]//* this would be the normal length of the string[/COLOR]
        Game - Display to (All players) the text: (Entered String Length:   + (String((Length of (Entered chat string))))) 
        [COLOR="Red"]//* ---- this part to count string length without spaces[/COLOR]
        Set i = 0
        For each (Integer A) from 1 to (Length of (Entered chat string)), do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), (Integer A), (Integer A))) Not equal to   [COLOR="Red"]//*enter a space here[/COLOR]
                    Then - Actions
                        Set i = (i + 1)
                    Else - Actions
        Game - Display to (All players) the text: (Entered String Length without spaces:   + (String(i)))
        [COLOR="Red"]//* the integer variable "i" would have now stored the string length without spaces[/COLOR]
 
M

Mythic Fr0st

Guest
In what context are you wanting, like, what are you trying to use this for, gime example
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top