1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Errors with ascii conversion?

Discussion in 'Skript' started by ceruleanReverie, May 26, 2018.

Thread Status:
Not open for further replies.
  1. ceruleanReverie

    ceruleanReverie Active Member

    Joined:
    Jan 31, 2017
    Messages:
    25
    Likes Received:
    0
    Hi, I'm trying to make a simple function to convert text to rot13. I'm using skutilities' ascii expressions to accomplish this, however I get errors in console whenever I try to convert from ascii back to text.

    Skript Version (do not put latest): Skript 2.2 (dev35b)
    Skript Author: Bensku
    Minecraft Version: 1.12.2
    ---
    Full Code:
    Code (Skript):
    1. function rot13(input: text) :: text:
    2.     set {_output} to ""
    3.     set {_string::*} to {_input} split at ""
    4.    
    5.     set {_size} to size of {_string::*}
    6.     delete {_string::%{_size}%}
    7.    
    8.     loop {_string::*}:
    9.         set {_ascii} to convert text "%loop-value%" to ascii
    10.         set {_ascii} to {_ascii} parsed as an integer
    11.         if {_ascii} is between 65 and 90:
    12.             set {_caps} to true
    13.         else if {_ascii} is between 97 and 122:
    14.             set {_caps} to false
    15.         else:
    16.             set {_output} to "%{_output}%%loop-value%"
    17.        
    18.         if {_caps} is set:
    19.             set {_new} to {_ascii} + 13
    20.             if {_caps} is true:
    21.                 if {_new} > 90:
    22.                     set {_new} to {_new} - 26
    23.             else:
    24.                 if {_new} > 122:
    25.                     set {_new} to {_new} - 26
    26.            
    27.             set {_new} to {_new} parsed as an integer
    28.             set {_replace} to convert ascii {_new} to string
    29.             set {_output} to "%{_output}%%{_replace}%"
    30.        
    31.         delete {_caps}
    32.    
    33.     return {_output}

    Console Errors:

    pastebin

    Addons:
    SkUtilities (0.9.2), skquery, skrayfall, advancementsaddon, facsk, mundosk, tuske, vixio, wolvsk (the others really shouldn't be relevant)

    Have you tried searching the docs? Yes
    Have you tried searching the forums? Yes

    ---

    The function gets called by a simple command, like so:
    Code (Skript):
    1. command /rot13 <text>:
    2.     description: Returns a rot13 cipher of any text you provide.
    3.     executable by: players and console
    4.     trigger:
    5.         set {_result} to rot13(arguments)
    6.         message "&3Result: <tooltip:§dClick to copy text.><suggest command:%{_result}%>&f%{_result}%"
     
Thread Status:
Not open for further replies.
Loading...