Hi all! This is my design on how to make a random Loot Crate thing where you purchase from a vending machine and it gives you a random item. I know that this has been done before but I wanted to take a stab at making one myself, so here’s what I made:
Tutorial
Step 1: Place a Vending Machine and set your settings however you like (stock, funding, price, etc). If you want, set it to “Grant Item” but leave the “Granted Item” blank for a Question Mark icon – I thought this was a nice touch.
Step 2: Place a Trigger and set “Visible In-Game” and “Trigger by Player Collision” to No. Create a custom “When triggered…” block with the following code (it won’t let me put in a second image):
- Create a variable called “Random”.
set Random to [ random integer from [1] to [4] ]
Broadcast Message on Channel [ create text with [“RAND_”] [Random] ]
If you would like more or less items to be randomly given, change the maximum random integer. Leave the minimum random integer as 1. An image of the code will be in the replies.
Step 3: Connect a wire leading from the Vending Machine to the Trigger when “Item Purchased” => “Trigger”
Step 4: Place Item Granters. The quantity will depend on how many separate items you want. In my case, because my maximum was 4, I have 4 Item Granters. In each Item Granter, change your settings however you like, and set “Grant item when receiving on” to “RAND_” and then consecutive numbers for each, 1, 2, 3, 4…
Step 5 (optional): Place Notification devices that respond to “RAND_#” as well and set their information how you like. This will send a message with the random item granted.
That should be it. If you have any other questions, please let me know, and I can try to answer them. Thank you!