Creating a vending machine

by rmalex (PM)

See everything made by this user or team.

Current Language: English
Very Helpful
of 5 vote(s).

Welcome to my first tutorial, hope you enjoy :)

Start by creating a vending machine using the tile sets. Then place some blocks behind it to make it soid.

Secondly add a zone underneath the machine and script it for when the player presses the action key above it. Below is the structure of the script but I will quickly go though it underneath the picture as well.

First create a message box with a yes and no option; leave the no option blank. For the yes branch add a comparison branch to check the player's money (greater than or equal to), if they don't have enough then set a message to tell them that, if they do then remove the price from their money and then either add the effect of the product or add the product to their inventory.

There is an alternative to sell multiple products in one go. For the first message box ask them what they want to buy. Then for each option add a different product. Copy the previous steps for each product and it should work fine.

I know it's not a very long tutorial but it should be everything.

There's been a total of 3639 views(s).
There's been 1817 people that have viewed.