Is there anyway better to do this?

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

  • 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.

AndreasLK

Member
Mar 12, 2020
16
0
1
20
Here's all my code. It's for a custom sign shop.
Code:
on rightclick on sign:
    if {sign.%player%} is "true":
        if {%2nd line of event-block%} is not set:
            set {%2nd line of event-block%} to 2nd line of event-block
            set {%2nd line of event-block%} to 2nd line of event-block
            add "%{%2nd line of event-block%}%" to {shop.signs::*}
            set {%2nd line of event-block%.location} to location of event-block
            set {%2nd line of event-block%.high} to 3rd line of event-block parsed as number
            set {%2nd line of event-block%.low} to 4th line of event-block parsed as number
            set {%2nd line of event-block%.amount} to 1st line of event-block
            set {%2nd line of event-block%.price} to random number between {%2nd line of event-block%.low} and {%2nd line of event-block%.high}
            wait 1 tick
            set 1st line of event-block to "Admin Shop"
            set 4th line of event-block to "%{%2nd line of event-block%}%"
            if player's tool is green wool:
                set 3rd line of event-block to "B %{%2nd line of event-block%.price}%"
                set {%2nd line of event-block%.bs} to "buy"
            if player's tool is red wool:
                set 3rd line of event-block to "S %{%2nd line of event-block%.price}%"
                set {%2nd line of event-block%.bs} to "sell"

            set 2nd line of event-block to "%{%2nd line of event-block%.amount}%"
            clear {%2nd line of event-block%}
        if {%2nd line of event-block%} is set:
            if {%2nd line of event-block%.1} is not set:
                set {%2nd line of event-block%.1} to 2nd line of event-block
                set {%2nd line of event-block%.1} to 2nd line of event-block
                add "%{%2nd line of event-block%.1}%" to {shop.signs::*}
                set {%2nd line of event-block%.location.1} to location of event-block
                set {%2nd line of event-block%.high.1} to 3rd line of event-block parsed as number
                set {%2nd line of event-block%.low.1} to 4th line of event-block parsed as number
                set {%2nd line of event-block%.amount.1} to 1st line of event-block
                set {%2nd line of event-block%.price.1} to random number between {%2nd line of event-block%.low.1} and {%2nd line of event-block%.high.1}
                wait 1 tick
                set 1st line of event-block to "Admin Shop"
                set 4th line of event-block to "%{%2nd line of event-block%.1}%"
                if player's tool is green wool:
                    set 3rd line of event-block to "B %{%2nd line of event-block%.price.1}%"
                    set {%2nd line of event-block%.bs.1} to "buy"
                if player's tool is red wool:
                    set 3rd line of event-block to "S %{%2nd line of event-block%.price.1}%"
                    set {%2nd line of event-block%.bs.1} to "sell"

                if {%2nd line of event-block%.1} is set:
                    if {%2nd line of event-block%.2} is not set:
                        set {%2nd line of event-block%.2} to 2nd line of event-block
                        set {%2nd line of event-block%.2} to 2nd line of event-block
                        add "%{%2nd line of event-block%.2}%" to {shop.signs::*}
                        set {%2nd line of event-block%.location.2} to location of event-block
                        set {%2nd line of event-block%.high.2} to 3rd line of event-block parsed as number
                        set {%2nd line of event-block%.low.2} to 4th line of event-block parsed as number
                        set {%2nd line of event-block%.amount.2} to 1st line of event-block
                        set {%2nd line of event-block%.price.2} to random number between {%2nd line of event-block%.low.2} and {%2nd line of event-block%.high.2}
                        wait 1 tick
                        set 1st line of event-block to "Admin Shop"
                        set 4th line of event-block to "%{%2nd line of event-block%.2}%"
                        if player's tool is green wool:
                            set 3rd line of event-block to "B %{%2nd line of event-block%.price.2}%"
                            set {%2nd line of event-block%.bs.2} to "buy"
                        if player's tool is red wool:
                            set 3rd line of event-block to "S %{%2nd line of event-block%.price.2}%"
                            set {%2nd line of event-block%.bs.2} to "sell"

Is there any way i can search for an existing variable and then make the number +1 of what it is? you can se the slow way I've done it for now
 
Status
Not open for further replies.