• Hey! Register here to create your account, engage with the community, and talk about what is new!

How do you use variables?

banana_monkey123

Active member
Joined
Nov 8, 2023
Messages
55
Reaction score
3
How do I use variables? I'm making a game where you click an item to get money and it tells you how much you have ( with a /text Money: %var(money) ) and then when I add money to the variable each click, it doesn't add anything. Just so you know, in case it matters, the variable is a save variable.
 

Mipoxa

Well-known member
Mythic
Joined
Sep 6, 2020
Messages
86
Reaction score
12
How do I use variables? I'm making a game where you click an item to get money and it tells you how much you have ( with a /text Money: %var(money) ) and then when I add money to the variable each click, it doesn't add anything. Just so you know, in case it matters, the variable is a save variable.
Are you perhaps using the sum action wrong? You should probably request support for this issue, but one thing I can suggest is checking whether you're using the sum action or incrementing. For sum, the first slot in the chest will always be the resulting variable, and the rest will be the variables you need to sum up. For example, if you want to increase a hypothetical "a" variable by 1, you'd need to put the following variables in the chest: "a", "a", 1, this will set "a" to the sum of "a" and 1, but If you only put "a" and 1 in the chest, it will set "a" to the sum of 1, which is just 1. If you want to increment "a" by 1, you can also use the set variable: increment value. That action increases the variable rather than setting it, so if you put values "a" and 1 in the chest, it will increase "a" by 1.
 

Mipoxa

Well-known member
Mythic
Joined
Sep 6, 2020
Messages
86
Reaction score
12
Thank you, that worked, but i have a question - with save variables is that just per player or is that per game?
Save variables are per plot, yes. If you want to store the player's money in a variable, you can use the keyword "%default" in the name of the variable. When the code reads %default, it reads it as the name of the player who triggered the event, so for example if I join the plot, the join event will read "%default money" as "Mipoxa money", and if you do it, it will read "%default money" as "banana_monkey123 money". By the way, when you enter dev mode, you can find a reference book in your inventory. I recommend reading it for more information on keywords and coding as a whole.
 
Top Bottom