on step on pressure plate:
if event-block is a iron pressure plate:
if block below event-location is iron block:
set {_number} to a random integer between 1 and 4
if {_number} is 1:
give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢"
if {_number} is 2:
give player white dye named "&fIron Chunk" with lore "This is worth 5$"
if {_number} is 3:
give player iron ingot named "&fIron Ingot" with lore "This is worth 25$"
if {_number} is 4:
give player iron block named "&fIron Block" with lore "This is worth 500$"
wait 1 tick
#How do I add chance to an item so 1/2 or 1/4 of getting the item
1 messages · Page 1 of 1 (latest)
by using random integers
i know
right now its 25% each
o
u see now?
no
{_n} can only be set to one object, not more
on step on pressure plate: if event-block is a iron pressure plate: if block below event-location is iron block: set {_n} to a random integer between 1 and 2 and 3 if {_n} is 3: set {_n} to a random integer between 4 and 5 and 6 if {_n} is 6: set {_n} to a random integer between 7 and 8 and 9 if {_n} is 1 or 2: give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢" if {_n} is 4 or 5: give player white dye named "&fIron Chunk" with lore "This is worth 5$" if {_n} is 7 or 8: give player iron ingot named "&fIron Ingot" with lore "This is worth 25$" if {_n} is 9: give player iron block named "&fIron Block" with lore "This is worth 500$"
im trying to do 2/3 to 1/3
says it can only be 1
@vital coyote
what the hell
?
is that
on step on pressure plate:
if event-block is a iron pressure plate:
if block below event-location is iron block:
set {_number} to a random integer between 1 and 5
if {_number} is 1 or 2:
give player iron nugget named "&fIron Nugget" with lore "This is worth 25¢"
if {_number} is 3:
give player white dye named "&fIron Chunk" with lore "This is worth 5$"
if {_number} is 4:
give player iron ingot named "&fIron Ingot" with lore "This is worth 25$"
if {_number} is 5:
give player iron block named "&fIron Block" with lore "This is worth 500$"
wait 1 tick
this is what i mean
not the full code
but its an example
40% / 20% / 20% / 20%
i need 50 25 12.5 etc
so make it like that then
oh wait
i mean 33
and whatever is after
thats why i have it as 1 and 2 and 3
but it says {_n} can only be set to one object, not more
oh wait
im stupid
Just 2^(-x) = (1/2)^x = 1/(2^x)
real
Heres an exampleloop 5 times: chance of 2^(0 - (loop-number - 1)): broadcast “&aSUCCESS! There was a %2^(0 - (loop-number - 1))%%% chance of this succeeding” else: broadcast “&cFAILED! There was a %2^(0 - (loop-number - 1))%%% chance of this succeeding”
chance of 50% = chance of 0.5 = chance of 1/2