#chance value not working

1 messages · Page 1 of 1 (latest)

winter token
#
    set {_s} to line 2 of players's cursor slot's lore
    replace all "%% success" with "" in {_s}
    replace all "&2" with "" in {_s}
    if the player's cursor slot's lore contains "&7Swiftness I":
        if lore of event-item contains "Empty...":
            if event-item's lore doesn't contain "&7Swiftness I":
                broadcast {_s}
                chance of {_s}:
                    set {_target} to event-item
                    cancel event
                    replace "Empty..." in {_target}'s lore with "&7Swiftness I"
                    wait 2 ticks
                    set cursor slot of player to air
                    set event-slot to {_target}
                else:
                    cancel event
                    set player's cursor slot to air
            else:
                cancel event
                send "&7You already have that enchantment!"```
the broadcast sends back the correct value, but the enchant never succeeds
ocean tangle
#

don't think you can do "chance of (string):"

winter token
#

how do i get around this

#

grr

ocean tangle
#

this doesn't error

#

but idk if it works

winter token
ocean tangle
#

sad

#

got no other ideas really

#

unless you set {_s} to a number, ex. 5

winter token
#

s is a number

ocean tangle
#

then set {_rand} to random integer between 1 and 100

#

if rand <= 5, proc

#

or ig ==

#

idk too eepy

winter token
#
    permission: custom.admin
    trigger:
        set {_r} to a random integer between 1 and 100
        set line 2 of {CustomItem::SpeedBookI}'s lore to "&2%{_r}%%% success rate"
        give player {CustomItem::SpeedBookI}
on inventory click:
    set {_s} to line 2 of player's cursor slot's lore
    replace all "%% success" with "" in {_s}
    replace all "&2" with "" in {_s}
    if the player's cursor slot's lore contains "&7Swiftness I":
        if lore of event-item contains "Empty...":
            if event-item's lore doesn't contain "&7Swiftness I":
                broadcast {_s}
                chance of ({_s} parsed as number):
                    set {_target} to event-item
                    cancel event
                    replace "Empty..." in {_target}'s lore with "&7Swiftness I"
                    wait 2 ticks
                    set cursor slot of player to air
                    set event-slot to {_target}
                else:
                    cancel event
                    set player's cursor slot to air
            else:
                cancel event
                send "&7You already have that enchantment!"```
#

a random number becomes the lore of the book

#

then that lore becomes S

#

when i broadcast s i get the right number

#

the chance just doesnt work

ocean tangle
#

what does it do when you set the chance to 100%

#

also add a broadcast in each part of the chance

winter token
ocean tangle
#

both when it replaces empty and when it cancels event and sets cursor slot to air

winter token
#

it always fails

ocean tangle
#

unfortunate

ocean tangle