TransWikia.com

Is there a way I can store variables in my Minecraft world?

Arqade Asked on February 20, 2021

I’m trying to make bank accounts for players in a Minecraft world. Is there a feature in Minecraft commands that would enable me to do this using variables? If so, which commands would allow me to utilise this, or if not, what would be my best option?

2 Answers

Scoreboards are the tool you're looking for. All of the scoreboard commands are explained in the wiki link, but since it may be overwhelming, I'll try to present it in a more digestible format tailored to your specific needs below.

For making bank accounts, you could make a new objective for the amount of money a player has, which could be called "money". You will want this objective to be of the dummy criteria (which is what the dummy suffix below means) because it isn't based on a preexisting Minecraft value, and you won't want players to arbitrarily control their own money.

scoreboard objectives add money dummy

Then to begin tracking a player's money:

scoreboard players add playerName money

Or better yet, use target selectors for generic player inclusion:

scoreboard players add @p money

There are many different commands to modify and evaluate a player's money. set, add, remove, and test are probably vital. They can be used as follows:

Set a player's balance to 0:

scoreboard players set playerName money 0

Add 10 to a player's balance:

scoreboard players add playerName money 10

Remove 10 from player's balance:

scoreboard players remove playerName money 10

Test if a player's balance is greater than or equal to 100:

scoreboard players test playerName money 100

Here are some other commands you can use.

In order to have a well-functioning and automatically managed bank, you'll also want to investigate command blocks. Conditional command blocks are particularly vital. Target selectors will also be necessary (as opposed to the playerName I gave in my above examples), because you shouldn't be using player names if you want a scalable system.

Correct answer by Graham on February 20, 2021

Have a bank user use a "Key" that is specific to their account to access their selected currency. The key can be any item that is named. An example of this would be an apple that is named "Open". The key will have to be placed in a chest or hopper which will lead to redstone circuitry that will "unlock" the said bank account. The user will then put their goods in a chest that will put their goods away into their account before a lever is pulled and the key is dropped out again for the user.

Answered by DustyRB on February 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP