Arithmetic Error?

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

Hibela

Member
Jan 22, 2020
4
0
1
19
Code:
                set {_stock} to line 2 of lore of clicked item
                replace "- Stock : " with "" in {_stock}
                set {_stock} to "%{_stock}%" parsed as integer
                set {_sum} to {_stock} - item number of clicked item
                broadcast "%{_stock}%, %{_sum}%"
                {_sum} < 0:
                    set {_clicked} to clicked item
                    set clicked item to barrier named "&cNot Enough Stock!"
                    wait 2 second
                    set clicked item to {_clicked}
                    stop

Line 2 of lore of clicked item is

"- Stock : %integer%".

5th line of the code,

"broadcast "%{_stock}%, %{_sum}%"",

When broadcast outputs {_stock}, it is set correctly. But when I do

"{_stock} - item number of clicked item"

It keeps outputting negative numbers and {_stock} is considered as 0...

What is wrong with this arithmetic???


Skript ver : 2.2-dev34
 
Status
Not open for further replies.