• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

The Braille Script

1,748
Posts
14
Years
  • Well recently I decided I wanted to use braille, but I was too lazy to create an image for each and every braille tablet, so I came up with the idea to input a string and convert that into a displayable braille tablet!

    To use call (with a script command): Braille.show("Text Here")

    Code:
    ################################################################################
    # Braille Script
    # By Rei
    # Credits Required
    ################################################################################
    # Turns a normal string into a Braille string and displays it.
    #
    # NOTICE: Yes, I know the braille graphics aren't the best, but they work.
    #
    # How to use:
    #   - Insert the graphics provided to: YourGameFolder/Graphics/Pictures OR add
    #       your own graphics (to the same folder)
    #   - Customize the settings to make sure everything works the way it should
    #   - Test it out
    #   - Report any problems
    #
    #
    # Call with: Braille.show("Text Here")
    ################################################################################
    
    
    class Braille
      BackgroundFile = "BrailleBackground" # Background of the Braille (EG a stone tablet)
      FilePrefix = "Braille" # The prefix of the Braille characters (EG if the prefix
      #                         is "Braille_" then it will look for "Braille_A",
      #                         "Braille_B", "Braille_C", ect.)
      
      # THESE OPTIONS ARE MEASURED IN PIXELS!
      BrailleStartX = 32 # The Starting X (per line) on which a Braille character is shown
      BrailleStartY = 32 # The Starting Y point on which Braille is shown
      BrailleNewLineAt = Graphics.width - BrailleStartX # The maximum X before we go to
                                                    # a new line
      
      # THESE OPTIONS ARE MEASURED IN PIXELS!
      BraillePaddingX = 10 # Padding between each Braille character (Left to Right)
      BraillePaddingY = 10 # Padding between each Braille character (Top to Bottom)
      
      def self.show(text)
        scene = Braille.new(text)
        scene.main
      end
      
      def initialize(text)
        @text = brailAlphabetString(text)
        @exit = false
      end
      
      # Converts a normal string into an braille alphabetical string
      # Removes all uneeded characters, converts numbers into the correct format
      # ect.
      def brailAlphabetString(input)
        input[/([A-Za-z0-9# ]*)/]
        input = $1
        output = ""
        char = "A"
        for i in 0...input.length
          prev_char = char
          charI = input[i]
          char = " "
          char[0] = charI
          
          # Check to see if we are at the start of an integer
          if (char == "0" || char.to_i != 0) &&
            (prev_char != "0" && prev_char.to_i == 0 && prev_char != "#")
            output += "#" # Add a number sign to the start of numbers
          end
          
          # Convert each integer into a letter, because this is how it is in braille
          if char == "1"
            output += "A"
          elsif char == "2"
            output += "B"
          elsif char == "3"
            output += "C"
          elsif char == "4"
            output += "D"
          elsif char == "5"
            output += "E"
          elsif char == "6"
            output += "F"
          elsif char == "7"
            output += "G"
          elsif char == "8"
            output += "H"
          elsif char == "9"
            output += "I"
          elsif char == "0"
            output += "J"
          else # If it's not a letter, just add the character.
            output += char
          end
        end
        return output
      end
      
      def create_spriteset
        @sprites = {}
        @sprites["background"] = IconSprite.new
        @sprites["background"].setBitmap("Graphics/Pictures/" + BackgroundFile)
        x = BrailleStartX + BraillePaddingX
        y = BrailleStartY + BraillePaddingY
        for i in [email protected]
          file = "Graphics/Pictures/" + FilePrefix + "A"
          t = @text[i]
          if t == "#"[0]
            t = "NS"
          elsif t == " "[0]
            t = "Space"
          end
          file[file.length - 1] = t
          if FileTest.image_exist?(file)
            @sprites["letter#{i}"] = IconSprite.new(x, y)
            @sprites["letter#{i}"].setBitmap(file)
            x += @sprites["letter#{i}"].bitmap.width + BraillePaddingX
            if x >= BrailleNewLineAt - BraillePaddingX
              x = BrailleStartX + BraillePaddingX
              y += @sprites["letter#{i}"].bitmap.height + BraillePaddingX
            end
          else
            c = "A"
            c[0] = @text[i]
            c = c.upcase
            t = "Could not find the file Braille file for the character: #{c}!"
            raise t
          end
        end
      end
      
      def main
        create_spriteset
        loop do
          Graphics.update
          Input.update
          update
          break if @exit
        end
        pbDisposeSpriteHash(@sprites)
      end
      
      
      def update
        pbUpdateSpriteHash(@sprites)
        if Input.trigger?(Input::C) || Input.trigger?(Input::B)
          @exit = true
        end
      end
    end


    Also, you'll need these too if you want the script to work: View attachment 70825
     
    Last edited:
    220
    Posts
    9
    Years
  • Hello! I'm using your nice script and it works fine but, after i compressed the game when i play an event with this script, i got this odd error and game crash. My graphics as your original names.

    braill10.png
     
    824
    Posts
    8
    Years
  • Excuse me for my acknowledge but what is braille? @@ sorry, i'm dumb

    I was about to be dumbfounded that someone doesn't know what Braille is, but then I remembered that English isn't your primary language. You may not have braille or something similar, and if you do it might be called something else.

    Braille is a coding system composed of raised dots, where each 2x3 group of dots corresponds to a letter or number. It is intended to allow the blind to read without the need for someone reading to them. It's most easily found in elevators next to the "normal" numbers.

    The Hoenn games use images based on Braille in the Regi puzzles.
     

    Aljen

    The Lost Boy...
    125
    Posts
    10
    Years
  • True, xD, Braille isnt very popular in my country, thats why i have trouble when solving the Regi puzzles in pokemon Emerald xD
     

    FL

    Pokémon Island Creator
    2,450
    Posts
    13
    Years
    • Seen today
    Hello! I'm using your nice script and it works fine but, after i compressed the game when i play an event with this script, i got this odd error and game crash. My graphics as your original names.

    braill10.png
    The Braille script use the method 'FileTest.image_exist?' that I guess that won't work in compressed games. Try to change it into 'pbResolveBitmap'.
     
    220
    Posts
    9
    Years
  • Ok, i will test it with that way. Thx.

    I tested it with your piece of code but i've got the same error, this is odd.
     
    Last edited by a moderator:

    TheKenny

    The only real Kenny!
    41
    Posts
    12
    Years
  • Would it possible to reupload / reattach the needed files for the braille script? Thanks in advance! :)
     

    Vxpor

    Vxpor
    77
    Posts
    5
    Years
    • Seen May 2, 2024
    Anyone have the Graphics.zip for this script or know if it still works?
     
    Back
    Top