need help with drop x {_variable} and aliases?

  • 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.
Dec 3, 2017
2
0
0
Behind You!
Hello, English is not my native lang so sorry for my bad english

Im new in skript scripting, ... and this forum.
well, im stuck at this part.
here is the code :
code_language.skript:
aliases:
   type of stone = 1, 4, 2, 3 #test block
   t4 = diamond pickaxe
   t3 = t4, iron pickaxe, golden pickaxe
   t2 = t3, stone pickaxe
   t1 = t2, wooden pickaxe

on mine of type of stone:
    set {_pool::*} to yaml nodes with keys "luckypool" from "yml.itemdb"
    loop {_pool::*}:
        set {_chance} to yaml value "luckypool.%loop-value%.chance" from "yml.itemdb"
        set {_drop} to loop-value
        set {_req} to yaml value "luckypool.%loop-value%.tool" from "yml.itemdb"
        chance of {_chance}:
            tool is {_req}
            drop 1 {_drop}

and here is the item list:
code_language.skript:
luckypool:
  diamond:
    chance: 1 #test 100% chance
    break: 0
    tool: "t4"
  bone_item:
    chance: 1
    break: 0
    tool: "t1"

Here is the problem:
i expect this part
code_language.skript:
tool is {_req}
drop 1 {_drop}

to be :
code_language.skript:
tool is t4 #and t4 refer to alias t4
drop 1 diamond

but, i cant make it to work.
i think skript parse {_req} and {_drop} as text?
or is it because of me lack of understanding and write it the wrong way?
googling return null (i dont know what keywords to use for my problem).

have any solution? or advice?
 
Hello, English is not my native lang so sorry for my bad english

Im new in skript scripting, ... and this forum.
well, im stuck at this part.
here is the code :
code_language.skript:
aliases:
   type of stone = 1, 4, 2, 3 #test block
   t4 = diamond pickaxe
   t3 = t4, iron pickaxe, golden pickaxe
   t2 = t3, stone pickaxe
   t1 = t2, wooden pickaxe

on mine of type of stone:
    set {_pool::*} to yaml nodes with keys "luckypool" from "yml.itemdb"
    loop {_pool::*}:
        set {_chance} to yaml value "luckypool.%loop-value%.chance" from "yml.itemdb"
        set {_drop} to loop-value
        set {_req} to yaml value "luckypool.%loop-value%.tool" from "yml.itemdb"
        chance of {_chance}:
            tool is {_req}
            drop 1 {_drop}

and here is the item list:
code_language.skript:
luckypool:
  diamond:
    chance: 1 #test 100% chance
    break: 0
    tool: "t4"
  bone_item:
    chance: 1
    break: 0
    tool: "t1"

Here is the problem:
i expect this part
code_language.skript:
tool is {_req}
drop 1 {_drop}

to be :
code_language.skript:
tool is t4 #and t4 refer to alias t4
drop 1 diamond

but, i cant make it to work.
i think skript parse {_req} and {_drop} as text?
or is it because of me lack of understanding and write it the wrong way?
googling return null (i dont know what keywords to use for my problem).

have any solution? or advice?
drop 1 of {_drop}
 
yeah, i missed that, thanks! that was my bad.

actually i have figured it using roundabout way (parsing "1 %loop-value%" as item types, lol im so stupid).
about aliases, because i still don't know how to make {_tool} to be parsed as aliases (tool is {_tool}, {_tool} = "t4"), im now relying on loop :

code_language.skript:
set {_dropname} to loop-value
set {_req::*} to yaml list "luckypool.%block%.tool" from "yml.itemdb"

                loop {_req::*}:
                    set {_hand} to "%loop-value-2%" parsed as item types
                    # send "%{_chance}%, %{_drop}%, %{_hand}%" to player
                    if tool is {_hand}:
                        if enchant level of fortune of player's tool is set:
                            set {_chance} to ((((enchant level of fortune of player's tool * 15) + 100) / 100) * {_chance})
                            set {_displaychance} to {_chance} * 100

                        chance of {_chance}:
                            drop 1 of {_drop}
                            yaml path "itemname.%{_dropname}%" from "yml.itemdb" has value:
                                set {_dropname} to yaml value "itemname.%{_dropname}%" from "yml.itemdb"

                            send "&3&l[&bSystem&3&l] &7Got %{_dropname}% &7with chance of %{_displaychance}%%%" to player
                            set block to air

i dont know how much this will impact the server.
 
Status
Not open for further replies.