Parsing as item

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

SzymoonDev

Member
Sep 30, 2017
12
0
0
Hi everyone,
i have a problem. I'm creating skript for kits, like essentials kits. My problem is how i can parse item with name? Look:
code_language.skript:
function reloadKit(kit: text):
    set {kity::%{_kit}%::id} to yml value "kity.%{_kit}%.id" from file "plugins/Skript/scripts/kity/config.yml"
    set {kity::%{_kit}%::id} to parseInt("%{kity::%{_kit}%::id}%")
    set {kity::%{_kit}%::delay} to yml value "kity.%{_kit}%.delay" from file "plugins/Skript/scripts/kity/config.yml"
    set {kity::%{_kit}%::delay} to parseInt("%{kity::%{_kit}%::delay}%")
    set {kity::%{_kit}%::gui::item} to yml value "kity.%{_kit}%.gui.item" from file "plugins/Skript/scripts/kity/config.yml"
    set {kity::%{_kit}%::gui::item} to parseItem("%{kity::%{_kit}%::gui::item}%")
    set {kity::%{_kit}%::gui::slot} to yml value "kity.%{_kit}%.gui.slot" from file "plugins/Skript/scripts/kity/config.yml"
    set {kity::%{_kit}%::gui::slot} to parseInt("%{kity::%{_kit}%::gui::slot}%") - 1
    set {kity::%{_kit}%::items::*} to yml list "kity.%{_kit}%.items" from file "plugins/Skript/scripts/kity/config.yml"
    send "&f[&a&nKity&f] Zaladowano zestaw &a%{_kit}% &f(&a##%{kity::%{_kit}%::id}%&f)." to console


Here is parsing code:
code_language.skript:
function parseInt(int: text) :: number:
    set {_x} to {_int} parsed as number
    return {_x}

function parseItem(item: text) :: item:
    set {_x} to {_item} parsed as itemtype
    if parse error is set:
        broadcast "%parse error%"
    return {_x}

0 erros. First, i load item to {kity::%{_kit}%::gui::item} (in yml file: item: stone pickaxe named "&6» &7Zestaw Startowy &6«"). I parse this to item, but it's return <none>. Do you understand?


When i load this kit to gui:
code_language.skript:
command /kit [<text>]:
    aliases: zestaw
    executable by: players
    trigger:
        set {_p} to player
        open chest with 1 row named "&6»        &cDostepne zestawy       &6«" to {_p}
        wait 2 tick
        if inventory name of {_p}'s current inventory is "&6»        &cDostepne zestawy       &6«":
            loop {kity::kits::*}:
                set {_kit} to loop-value
                format slot {kity::%{_kit}%::gui::slot} of {_p} with {kity::%{_kit}%::gui::item} to be unstealable

Gui is empty, becouse {kity::%{_kit}%::gui::item} is not a itemtype. When i type in config id or name of item inself, all works correctly. The problem arises when I want to name this item.
Thanks for help and happy New Year :emoji_slight_smile:
 
Nope, split isn't best solution... Someone else will help? :<
[doublepost=1514555004,1514554726][/doublepost]
code_language.skript:
command /test [<text>]:
    trigger:
        loop {kity::%arg 1%::items::*}:
            add (loop-value parsed as itemtype) to player

This code it also doesn't work...

code_language.skript:
    items:
      - 1 diamond helmet of protection 3 and unbreaking 2 named "&6» &eZestaw KOX &6«"
      - 1 diamond chestplate of protection 3 and unbreaking 2 named "&6» &eZestaw KOX &6«"
      - 1 diamond leggings of protection 3 and unbreaking 2 named "&6» &eZestaw KOX &6«"
      - 1 diamond boots of protection 3 and unbreaking 2 named "&6» &eZestaw KOX &6«"
      - 1 diamond sword of sharpness 5 and unbreaking 3 named "&6» &eZestaw KOX &6«"
      - 1 diamond pickaxe of digspeed 5 and unbreaking 3 named "&6» &eZestaw KOX &6«"
      - 10 golden apple:1
      - 15 golden apple:0
      - 8 enderpearl
      - 3 enderchest
 
Status
Not open for further replies.