Solved Sign shop with dynamic price not working

  • 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
19
Code:
on rightclick on sign:
    if {sign.%player%} is "true":
        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%.high} to 3rd line of event-block
        set {%2nd line of event-block%.low} to 4th line of event-block
        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}%"
        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 to "%{%2nd line of event-block%.amount}%"
        clear {%2nd line of event-block%}

This should set the 3rd line of the sign to something random between 2 numbers
But instead it just says <none> (though still "B")
 
Instead of putting the value in a variable which contains the expression, just use a constant or temporary variable.

Code:
set {_high} to 3rd line of event-block
set {_low} to 4th line of event-block
set {_amount} to 1st line of event-block
set {_price} to random number between {_low} and {_high}

Then use the variable after like this:
Code:
if player's tool is green wool:
    set 3rd line of event-block to "B %{_price}%"
 
I tried to do this :
Code:
command /test [<TEXT>] [<TEXT>]:
    trigger:
        set {_high} to arg 1
        set {_low} to arg 2
        set {_price} to random number between {_low} and {_high}
        message "%{_price}%"
and the output is just "<none>"
 
The arguments you are using are texts, you will have to parse them as numbers or change the arguments to <number>.

Code:
command /test [<TEXT>] [<TEXT>]:
    trigger:
        set {_high} to arg 1 parsed as number
        set {_low} to arg 2 parsed as number
        set {_price} to random number between {_low} and {_high}
        message "%{_price}%"

or
Code:
command /test [<number>] [<number>]:
    trigger:
        set {_high} to arg 1
        set {_low} to arg 2
        set {_price} to random number between {_low} and {_high}
        message "%{_price}%"
 
The arguments you are using are texts, you will have to parse them as numbers or change the arguments to <number>.

Code:
command /test [<TEXT>] [<TEXT>]:
    trigger:
        set {_high} to arg 1 parsed as number
        set {_low} to arg 2 parsed as number
        set {_price} to random number between {_low} and {_high}
        message "%{_price}%"

or
Code:
command /test [<number>] [<number>]:
    trigger:
        set {_high} to arg 1
        set {_low} to arg 2
        set {_price} to random number between {_low} and {_high}
        message "%{_price}%"
I used "parsed as number" to make it work
Thank you so much!
You are my hero!
 
Status
Not open for further replies.