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!

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

[Challenge] Convert Denizen to Skript

Discussion in 'General' started by Rezz, Mar 26, 2018.

  1. Rezz

    Addon Developer

    Joined:
    Jan 24, 2017
    Messages:
    80
    Likes Received:
    37
    Medals:
    [​IMG]

    Some people are reluctant to try Skript because they don't believe it's as capable as Denizen.
    Let's help them out by converting Denizen scripts to Skript!


    The goal:
    • Rewrite Denizen scripts in Skript, mirroring functionality as best as possible.
    It'll be tricky since Denizen's terse syntax is fairly arbitrary and confusing, but anyone well-versed in reading code should be able to decipher it... in theory.​
    • Use as few addons as possible (preferably none!)
    A lot can be achieved in vanilla Skript (especially Bensku's fork). If you decide on requiring an addon, make it count!
    How to:

    A public Denizen Script Repository exists and several Denizen scripts are released on Spigot (you just have to search for them).
    Pick one, implement it in Skript, and post it here!

    Example:

    Here is a Skript implementation of 'Marriage Script' by Gershon12.

    Code (Skript):
    1. #
    2. #   -----------------
    3. #   Denizen to Skript
    4. #   -----------------
    5. #
    6. #   A Skript implementation of 'Marriage Script' by Gershon12
    7. #   https://one.denizenscript.com/denizen/repo/entry/127
    8. #
    9. #   -----------------
    10. #   Requires no addons.
    11. #
    12.  
    13. command /marry <text="?"> [<player>]:
    14.     executable by: players
    15.     description: Marriage
    16.     trigger:
    17.  
    18.         set {_uuid} to player's uuid
    19.      
    20.         if arg-1 is "help" or "?":
    21.      
    22.             #
    23.             #   Display help.
    24.             #
    25.          
    26.             send "&a&l------------- Marriage Help -------------"
    27.             send "&a/marry (player) &r- &7 Request a player to marry you"
    28.             send "&a/marry divorce &r- &7 Divorce the person you are married to"
    29.             send "&a/marry tp &r- &7 Teleport to your partner"
    30.             send "&a/marry info &r- &7 Information about your marriage"
    31.             send "&a/marry info (player) &r- &7 Marriage information about another player"
    32.             send "&a&l-----------------------------------------"
    33.          
    34.         else if arg-1 is "accept":
    35.      
    36.             #
    37.             #   Accept marriage request.
    38.             #
    39.          
    40.             if {marriage::%{_uuid}%::request} is not set:
    41.              
    42.                 send "&cYou do not have any marriage requests!"
    43.                 stop
    44.              
    45.             set {_target} to {marriage::%{_uuid}%::request} parsed as player
    46.          
    47.             if {_target} is not set:
    48.              
    49.                 send "&cThat person is not online!"
    50.                 stop
    51.              
    52.             set {_target-uuid} to {_target}'s uuid
    53.          
    54.             if {marriage::%{_target-uuid}%::partner} is set:
    55.              
    56.                 send "&cThat person is already married!"
    57.                 stop
    58.              
    59.             set {marriage::%{_uuid}%::partner} to {_target-uuid}
    60.             set {marriage::%{_uuid}%::partner::date} to now
    61.             set {marriage::%{_uuid}%::partner::points} to 0
    62.          
    63.             send "&aYou are now married to %{_target}%."
    64.          
    65.             set {marriage::%{_target-uuid}%::partner} to {_uuid}
    66.             set {marriage::%{_target-uuid}%::partner::date} to now
    67.             set {marriage::%{_target-uuid}%::partner::points} to 0
    68.          
    69.             send "&aYou are now married to %player%" to {_target}
    70.          
    71.             broadcast "&a&l%{_target}% and %player% are now married!"
    72.          
    73.         else if arg-1 is "deny":
    74.          
    75.             #
    76.             #   Deny marriage request
    77.             #
    78.          
    79.             if {marriage::%{_uuid}%::request} is not set:
    80.              
    81.                 send "&cYou do not have any marriage requests!"
    82.                 stop
    83.              
    84.             set {_target} to {marriage::%{_uuid}%::request} parsed as offline player
    85.             delete {marriage::%{_uuid}%::request}
    86.          
    87.             send "&aYou have declined the marriage request from %{_target}%."
    88.          
    89.             if {_target} is online:
    90.              
    91.                 send "&a%player% has declined your marriage request." to {_target}
    92.              
    93.         else if arg-1 is "divorce":
    94.      
    95.             #
    96.             #   Divorce an existing marriage.
    97.             #
    98.          
    99.             if {marriage::%{_uuid}%::partner} is not set:
    100.          
    101.                 send "&cYou are not married!"
    102.                 stop
    103.              
    104.             set {_partner-uuid} to {marriage::%{_uuid}%::partner}
    105.             set {_partner} to {_partner-uuid} parsed as offline player
    106.          
    107.             clear {marriage::%{_uuid}%::partner::*}
    108.             delete {marriage::%{_uuid}%::partner}
    109.          
    110.             send "&aYou have divorced from %{_partner}%."
    111.          
    112.             clear {marriage::%{_partner-uuid}%::partner::*}
    113.             delete {marriage::%{_partner-uuid}%::partner}
    114.          
    115.             if {_partner} is online:
    116.          
    117.                 send "&a%player% has divorced from you!" to {_partner}
    118.              
    119.         else if arg-1 is "info":
    120.          
    121.             #
    122.             #   Display marriage info.
    123.             #
    124.          
    125.             send "&a&l------------- Marriage Info -------------"
    126.          
    127.             if arg-2 is set:
    128.              
    129.                 set {_target-name} to arg-2's name
    130.                 set {_target-state} to "is"
    131.                 set {_target-uuid} to arg-2's uuid
    132.              
    133.             else:
    134.              
    135.                 set {_target-name} to "You"
    136.                 set {_target-state} to "are"
    137.                 set {_target-uuid} to {_uuid}
    138.              
    139.             set {_partner} to {marriage::%{_target-uuid}%::partner} parsed as offline player
    140.          
    141.             if {_partner} is set:
    142.              
    143.                 send "&a%{_target-name}% %{_target-state}% married to: &e%{_partner}%"
    144.                 send "&aDate married: &e%{marriage::%{_target-uuid}%::partner::date}%"
    145.                 send "&aMarriage points: &e%{marriage::%{_target-uuid}%::partner::points}%"
    146.              
    147.             else:
    148.              
    149.                 send "&a%{_target-name}% %{_target-state}% married to: &eno one :("
    150.          
    151.             send "&a&l------------- Marriage Info -------------"
    152.      
    153.         else if arg-1 is "tp" or "teleport":
    154.          
    155.             #
    156.             #   Teleport to partner.
    157.             #
    158.          
    159.             if {marriage::%{_uuid}%::partner} is not set:
    160.          
    161.                 send "&cYou are not married!"
    162.                 stop
    163.              
    164.             set {_partner} to {marriage::%{_uuid}%::partner} parsed as offline player
    165.          
    166.             if {_partner} is online:
    167.              
    168.                 teleport player to {_partner}
    169.              
    170.                 send "&aYou have teleported to %{_partner}%"
    171.                 send "&a%player% has teleported to you!" to {_partner}
    172.              
    173.             else:
    174.              
    175.                 send "&c%{_partner}% is not online!"
    176.          
    177.         else:
    178.          
    179.             #
    180.             #   Send a request to an online player.
    181.             #
    182.          
    183.             if {marriage::%{_uuid}%::partner} is set:
    184.              
    185.                 send "&cYou are already married!"
    186.                 stop
    187.              
    188.             set {_target} to arg-1 parsed as player
    189.          
    190.             if {_target} is not set:
    191.              
    192.                 send "&cThat player is not online!"
    193.                 stop
    194.              
    195.             set {_target-uuid} to {_target}'s uuid
    196.          
    197.             if {marriage::%{_target-uuid}%::partner} is set:
    198.              
    199.                 send "&cThat person is already married!"
    200.                 stop
    201.              
    202.             set {marriage::%{_target-uuid}%::request} to {_uuid}
    203.             send "&aYou have requested %{_target}% to marry you!"
    204.          
    205.             send "&a%player% has requested to marry you!" to {_target}
    206.             send "&aUse &e/marry accept &aor &c/marry deny" to {_target}
    207.  
     
    • Like Like x 2
    • Funny Funny x 1

Share This Page

Loading...