TUTORIALS - Variables and Expressions in @MenuBuilderBot

TUTORIALS - Variables and Expressions in @MenuBuilderBot

MegaHubTelegram

This tutorial will tell you about the most common practices of using variables, as well as provide step-by-step guidance on how to create functionality based on them. About what variables are, what principles and mechanics underlying the work with them can be found in the manual on variables. The method of presenting information in this manual assumes that you have already read the documents indicated by the links and generally understand the principles of the described functionality.


πŸ“œ The translation of this materials into your native language can be automatically done using the Google translator. Follow the link and select the desired language in the title:
https://translate.googleusercontent.com/translate_c?depth=1&sl=en&tl=es&u=https://telegra.ph/TUTORIALS-Variables-and-Expressions-in-MenuBuilderBot-EN-11-16



⬛ Purchase of functionality


All functionality is purchased IN YOUR BOT, for this go to your bot:
☞ πŸ”Admin | 🧩Extensions
All functions will be located in buttons with πŸ“‚Folder

The package of additional "Function Tokens" is purchased IN YOUR BOT, for this go to your bot:
☞ πŸ”Admin | 🧩Extensions | πŸ“‚Actions

❗IMPORTANT: The purchase of functionality for the bot is available only to the Creator (owner) of the bot. Admins CANNOT buy functionality!


⬛ Working with variables in expressions


The convenience of using expressions in Bonus buttons, in Exchange buttons, directly in messages and especially in Actions lies in the fact that it makes it possible to perform all the necessary calculations and assign all the necessary values ​​by one click of the button by the user.


β—Ό How to zero a variable:

If you add this expression to the Bonus, Exchange, or Action buttons, it sets the variable to zero. Although Actions are already able to set the desired value, so it is not necessary to use any expression for this.


β—Ό How to set a specific value while deleting the old one:

Zeroes the value of the variable and adds 5 to it - use it if you need to set a specific value in the variable using the Bonus button.


β—Ό How to compare a text variable:

All text variables must be quoted. Emoji can also be compared.
It can be used to check a password or a code word from a video task for a match.


β—Ό How to add a percentage to a variable:

In the bot, expression like:
{%variable% + 10%}
DOES NOT work.
Instead, you need to perform the calculation in the expression itself:

Abbreviated version of the entry:

And the shortest entry is:

The result of all the above expressions will be 10% change.

Examples of numbers and percentages:
*1.1 is +10%
*1.15 is +15%
*1.25 is +25%
*1.5 is +50%
*2 is +100%
*2.5 is +150%

And so on...


⬛ Working with bool_symb() in expressions


This string function allows you to create messages with dynamically changing content.


β—Ό How to show different emoji depending on the time of day.

USER CASE: Your support service cannot work around the clock and you want to show users that it is night for you now and they need to wait for an answer longer than usual - until morning and the beginning of working day.
TASK
: To display in message the 🌞 icon during the day and the πŸŒ’ icon at night. Let's say the day starts at 8 am and the night starts at 11:59 pm.

Let's use one of the functions for working with Date and Time (dt_left) and the date macro %date%:
dt_left("%date% 08:00:00") == 0  ➨ 8 am has already arrived (there is no time left before it)
dt_left("%date% 23:59:00") > 0 ➨ 12:00 am has NOT come yet (there is time left before it)

The final Expression will look like this:


β—Ό How to show the amount of something using emoji.

USER CASE: In your game, the user can receive rewards and you would like to graphically show the number of reward characters using emoji πŸŽ–.
TASK
: To show in message the icons πŸŽ– in amount which is equal to the current number in the %reward% variable, and if there are no rewards, show the corresponding message. Let's say the number of rewards and the value in the %reward% variable is 3, the maximum number of rewards is 5.

The expression will look like this:

Result : πŸŽ–πŸŽ–πŸŽ–


β—Ό How to show the current and remaining to the maximum amounts of something using emoji.

USER CASE: In your game, the character has health points and you would like to graphically show the amount of character's health using emoji, as well as the current amount of damage to the character.
TASK
: Show in the message icons in amount which is equal to the number in the %hp% variable, as well as πŸ’” icons in an amount missing from maximum in case of damage and a corresponding message if there are no health points left at all. Let's say the current number of health points and the value in the %hp% variable is 7, the maximum number of health points is 10.

The expression will look like this:

The: \n is a line change character

Result (if health is 7):
πŸ’šπŸ’šπŸ’šπŸ’šπŸ’šπŸ’šπŸ’šπŸ’”πŸ’”πŸ’”

Result (if health is 0 (zero)):
Unconscious character...
πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”πŸ’”


⬛ Working with randi() in expressions


Some calculations need to use a random number generator. The examples below will help you with this.


β—Ό Random number from -100 to +100:

Will generate a random number between 1 and 100 and make it negative or positive. Thus, a random number from -100 to -1 and from +1 to +100 (not zero) will drop out. When you need to randomly add or subtract a number. If you multiply any number by this expression, it will randomly determine its sign, which will allow you, for example, to randomly add or subtract a value in a variable (or a bonus, for example).


https://telegra.ph/Menu-Builder---All-Help-Materials-02-22

Report Page