The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Unown Text Tablet

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old November 28th, 2014 (12:52 PM). Edited October 25th, 2015 by Richard PT.
Richard PT's Avatar
Richard PT Richard PT is offline
     
    Join Date: Aug 2014
    Location: Portugal
    Gender: Male
    Nature: Calm
    Posts: 120
    Hello everyone!

    Here is my first and simple script made by me and i don't want credits for this, i only want to help to improve pokemon essentials by expanding it with other features.

    How to install:

    Put this script above MAIN;
    Put the required graphics in GRAPHICS/PICTURES folder.

    Call with: Unown.show("your text here").

    Note: The download contains the required graphics and this script.

    Download: https://www.mediafire.com/?y33v9701fyrh8ue



    Script:

    Spoiler:
    ################################################################################
    # Unown Script
    # By Richard PT
    # Credits Required
    ################################################################################
    # Turns a normal string into a Unown string and displays it.
    #
    # NOTICE: Yes, I know the unown 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: Unown.show("Text")
    ################################################################################


    class Unown
    BackgroundFile = "UnownBackground" # Background of the Unown (EG a stone tablet)
    FilePrefix = "Unown" # The prefix of the Unown characters (EG if the prefix
    # is "Unown_" then it will look for "Unown_A",
    # "Unown_B", "Unown_C", ect.)

    # THESE OPTIONS ARE MEASURED IN PIXELS!
    UnownStartX = 32 # The Starting X (per line) on which a Unown character is shown
    UnownStartY = 32 # The Starting Y point on which Unown is shown
    UnownNewLineAt = Graphics.width - UnownStartX # The maximum X before we go to
    # a new line

    # THESE OPTIONS ARE MEASURED IN PIXELS!
    UnownPaddingX = 10 # Padding between each Unown character (Left to Right)
    UnownPaddingY = 10 # Padding between each Unown character (Top to Bottom)

    def self.show(text)
    scene = Unown.new(text)
    scene.main
    end

    def initialize(text)
    @text = unownAlphabetString(text)
    @exit = false
    end

    # Converts a normal string into an unown alphabetical string
    # Removes all uneeded characters, converts numbers into the correct format
    # ect.
    def unownAlphabetString(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 Unown
    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 == "10"
    output += "J"
    elsif char == "11"
    output += "K"
    elsif char == "12"
    output += "L"
    elsif char == "13"
    output += "M"
    elsif char == "14"
    output += "N"
    elsif char == "15"
    output += "O"
    elsif char == "16"
    output += "P"
    elsif char == "17"
    output += "Q"
    elsif char == "18"
    output += "R"
    elsif char == "19"
    output += "S"
    elsif char == "20"
    output += "T"
    elsif char == "21"
    output += "U"
    elsif char == "22"
    output += "V"
    elsif char == "23"
    output += "W"
    elsif char == "24"
    output += "X"
    elsif char == "25"
    output += "Y"
    elsif char == "0"
    output += "Z"
    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 = UnownStartX + UnownPaddingX
    y = UnownStartY + UnownPaddingY
    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 + UnownPaddingX
    if x >= UnownNewLineAt - UnownPaddingX
    x = UnownStartX + UnownPaddingX
    y += @sprites["letter#{i}"].bitmap.height + UnownPaddingX
    end
    else
    c = "A"
    c[0] = @text[i]
    c = c.upcase
    t = "Could not find the file Unown 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
    __________________
    Reply With Quote
      #2    
    Old November 28th, 2014 (1:39 PM).
    Nickalooose Nickalooose is offline
    --------------------
       
      Join Date: Mar 2008
      Gender: Female
      Posts: 1,309
      Hey, this is a pretty good script... I like it, well done! Question, which is bugging me... What have you written on the tablet? I don't have a clue, my mind has gone blank lol.

      Hoooooooever... The way you've put the script is useless on many parts... I would hate to edit that script in the fact it's untidy, unreadable and most parts will be broken on here too, so probably will have to use the printable version, please note that for those that don't know... Also, use the CODE tags with all codes... It's much better.

      Hey, this is a pretty good script... I like it, well done! Question, which is bugging me... What have you written on the tablet? I don't have a clue, my mind has gone blank lol.

      Hoooooooever... The way you've put the script is useless on many parts... I would hate to edit that script in the fact it's untidy, unreadable and most parts will be broken on here too, so probably will have to use the printable version, please note that for those that don't know... Also, use the CODE tags with all codes... It's much better.
      Reply With Quote
        #3    
      Old November 28th, 2014 (2:29 PM).
      Richard PT's Avatar
      Richard PT Richard PT is offline
         
        Join Date: Aug 2014
        Location: Portugal
        Gender: Male
        Nature: Calm
        Posts: 120
        Thanks, I'm new here and I still learning how to make scripts like this, you can modify it yourself if you want. I don't need credits for this. Other thing, i tested it in my game and it works perfectly. The tablet says: tanoby key.
        __________________
        Reply With Quote
          #4    
        Old November 28th, 2014 (10:41 PM).
        mej71's Avatar
        mej71 mej71 is offline
           
          Join Date: Mar 2014
          Location: Omnipresence
          Gender: Male
          Posts: 1,222
          Quote:
          Originally Posted by Richard PT View Post
          Thanks, I'm new here and I still learning how to make scripts like this, you can modify it yourself if you want. I don't need credits for this. Other thing, i tested it in my game and it works perfectly. The tablet says: tanoby key.
          Here, I made it much easier to read. Also, a suggestion: the background file, padding, etc should be defined in the initialization of the class, and able to be user defined through the script call. It can have a default, but people may want to display this on different backgrounds throughout their game, and as is this only allows for 1.
          Reply With Quote
            #5    
          Old November 29th, 2014 (3:20 AM).
          FL's Avatar
          FL FL is offline
          Pokémon Island Creator
             
            Join Date: Sep 2010
            Gender: Male
            Posts: 1,765
            Interesting script! Some tips:

            Rather that your big elsif, I suggest you to use the code

            Code:
            manufacturer << case char
               when "1" then "A"
               when "2" then "B"
               when "3" then "C"
               when "4" then "D"
               when "5" then "E"
               when "6" then "F"
               when "7" then "G"
               when "8" then "H"
               when "9" then "I"
               when "0" then "J"
               else char
            end
            And using constants with full caps is a pattern at several languages like Ruby ("FILEPREFIX" over "FilePrefix").
            __________________
            Reply With Quote
              #6    
            Old November 29th, 2014 (4:54 AM).
            Luka S.J.'s Avatar
            Luka S.J. Luka S.J. is offline
            Jealous Croatian
               
              Join Date: Dec 2008
              Location: Croatia
              Age: 25
              Gender: Male
              Nature: Adamant
              Posts: 1,114
              Not a bad script man, it looks nice. My suggestion though, instead of having the full sprites appear, you could colour them into full black, and them reduce their transparency to like 50%. That way you wouldn't need any additional graphics (you can use the sprites present in the Battlers folder), but it'd look more like letter. Unless you prefer this look. Was just an idea.

              Also, what I'd recommend, instead of making multiple new sprites, you can use the bitmap.blt function to draw the Unown letters directly onto the background bitmap. That way when manipulating and disposing the objects, you only have one to worry about.
              Reply With Quote
                #7    
              Old November 29th, 2014 (5:31 AM).
              Richard PT's Avatar
              Richard PT Richard PT is offline
                 
                Join Date: Aug 2014
                Location: Portugal
                Gender: Male
                Nature: Calm
                Posts: 120
                Thanks for your opinions.
                __________________
                Reply With Quote
                  #8    
                Old October 24th, 2015 (11:36 PM).
                TheKenny's Avatar
                TheKenny TheKenny is offline
                The only real Kenny!
                   
                  Join Date: Feb 2012
                  Location: Germany
                  Age: 22
                  Gender: Male
                  Nature: Careful
                  Posts: 41
                  Is there any way to reupload the files on Mediafire? Thanks in advance! :)
                  __________________
                  The only real Kenny.
                  Pokémon <3 | The Legend of Zelda <3
                  Reply With Quote
                    #9    
                  Old October 25th, 2015 (1:11 AM).
                  Richard PT's Avatar
                  Richard PT Richard PT is offline
                     
                    Join Date: Aug 2014
                    Location: Portugal
                    Gender: Male
                    Nature: Calm
                    Posts: 120
                    I will reupload this files, sorry for that. XD
                    __________________
                    Reply With Quote
                      #10    
                    Old October 25th, 2015 (1:24 AM).
                    Richard PT's Avatar
                    Richard PT Richard PT is offline
                       
                      Join Date: Aug 2014
                      Location: Portugal
                      Gender: Male
                      Nature: Calm
                      Posts: 120
                      I reuploaded the files and thread.
                      __________________
                      Reply With Quote
                        #11    
                      Old December 21st, 2017 (8:54 AM). Edited December 21st, 2017 by Kazooo.
                      Kazooo Kazooo is offline
                         
                        Join Date: Nov 2016
                        Posts: 12
                        One small change I would suggest is make all the unown graphics have there own subfolder in pictures, to keep the pictures folder cleaner.
                        How to accomplish this:
                        Spoiler:

                        Start by replacing this:
                        Code:
                         def create_spriteset
                            @sprites = {}
                            @sprites["background"] = IconSprite.new
                            @sprites["background"].setBitmap("Graphics/Pictures/" + BackgroundFile)
                            x = UnownStartX + UnownPaddingX
                            y = UnownStartY + UnownPaddingY
                            for i in [email protected]
                              file = "Graphics/Pictures/" + FilePrefix + "A"
                              t = @text[i]
                              if t == "#"[0]
                                t = "NS"
                              elsif t == " "[0]
                                t = "Space"
                              end
                        With this:
                        Code:
                         def create_spriteset
                            @sprites = {}
                            @sprites["background"] = IconSprite.new
                            @sprites["background"].setBitmap("Graphics/Pictures/UnownTablet/" + BackgroundFile)
                            x = UnownStartX + UnownPaddingX
                            y = UnownStartY + UnownPaddingY
                            for i in [email protected]
                              file = "Graphics/Pictures/UnownTablet/" + FilePrefix + "A"
                              t = @text[i]
                              if t == "#"[0]
                                t = "NS"
                              elsif t == " "[0]
                                t = "Space"
                              end
                        All you have to do now is rename the downloaded pictures folder to UnownTablet and put it in your pictures folder.


                        Btw this my first time posting code bits to pokecomuntity, so I hope I did it right :)
                        Reply With Quote
                          #12    
                        Old December 21st, 2017 (10:55 AM).
                        Richard PT's Avatar
                        Richard PT Richard PT is offline
                           
                          Join Date: Aug 2014
                          Location: Portugal
                          Gender: Male
                          Nature: Calm
                          Posts: 120
                          Quote:
                          Originally Posted by Kazooo View Post
                          One small change I would suggest is make all the unown graphics have there own subfolder in pictures, to keep the pictures folder cleaner.
                          How to accomplish this:
                          Spoiler:

                          Start by replacing this:
                          Code:
                           def create_spriteset
                              @sprites = {}
                              @sprites["background"] = IconSprite.new
                              @sprites["background"].setBitmap("Graphics/Pictures/" + BackgroundFile)
                              x = UnownStartX + UnownPaddingX
                              y = UnownStartY + UnownPaddingY
                              for i in [email protected]
                                file = "Graphics/Pictures/" + FilePrefix + "A"
                                t = @text[i]
                                if t == "#"[0]
                                  t = "NS"
                                elsif t == " "[0]
                                  t = "Space"
                                end
                          With this:
                          Code:
                           def create_spriteset
                              @sprites = {}
                              @sprites["background"] = IconSprite.new
                              @sprites["background"].setBitmap("Graphics/Pictures/UnownTablet/" + BackgroundFile)
                              x = UnownStartX + UnownPaddingX
                              y = UnownStartY + UnownPaddingY
                              for i in [email protected]
                                file = "Graphics/Pictures/UnownTablet/" + FilePrefix + "A"
                                t = @text[i]
                                if t == "#"[0]
                                  t = "NS"
                                elsif t == " "[0]
                                  t = "Space"
                                end
                          All you have to do now is rename the downloaded pictures folder to UnownTablet and put it in your pictures folder.


                          Btw this my first time posting code bits to pokecomuntity, so I hope I did it right :)
                          Thanks for your advice. I'm not an expert in terms of programing. I only do small changes in scripts or in this case, i "imitate" an existing script like - Braille tablet script.
                          __________________
                          Reply With Quote
                          Reply

                          Quick Reply

                          Join the conversation!

                          Create an account to post a reply in this thread, participate in other discussions, and more!

                          Create a PokéCommunity Account
                          Thread Tools

                          Posting Rules
                          You may not post new threads
                          You may not post replies
                          You may not post attachments
                          You may not edit your posts

                          BB code is On
                          Smilies are On
                          [IMG] code is On
                          HTML code is Off

                          Forum Jump


                          All times are GMT -8. The time now is 8:53 PM.