Outils pour utilisateurs

Outils du site


en:variables

Ceci est une ancienne révision du document !


The variables

First of all, a variable is an element of the game whose value can be changed. Take for example the number of lives in an RPG: the variable could have the name “life_points” and its value 5, or life_points = 5.
You can count wounds, a number of rounds, a number of keys, etc. Anything is possible.

Now here's how to include and use a variable in the bot:

[...]
*********************
2 First_jet
You roll a 6 die. If you roll 5 or 6, go to room (3), otherwise (1).
of_six|variable|%=1:6|You get v_result_v|A 6-sided die.
1|v_of_six_v.in.1-4|Your result is too good to start again let's see! Go and get your medal (3)! You go back to the beginning to start again...
3|v_of_six_v.in.5-6|Your result is too bad to continue, go back to the beginning (1)!|Congratulations, you will receive a medal for that!
*********************
[...]

Variables are declared in the same way as objects, on the same line in a room. Ignore for now the lines in black.

Let's look at each part in detail:

  • Variable name: with no spaces or accents.
  • "variable" is the keyword telling the bot that this is a variable (this is similar to how “invisible” works)
  • Assign or modify the value of the variable:
    • =X”: The variable has the value X
    • %=X:Y” : The variable has a random value between X and Y (in our example, des_six will have a value between 1 and 6, like a classic dice)
    • *%+X:Y“: A random number between X and Y is added to the variable.
      * “
      %-X:Y”: A random number between X and Y is subtracted from the variable.
      +X”: Adds X to the current value of the variable.
      * “
      -X”: Subtracts X from the current value of the variable (it can be negative)
      * <html><span style=“color:#30B000”>Sentence to be displayed.</span></html> You can display nothing (you then put “null”), and you can display the value of a variable in the sentence by surrounding it with “v_”. For example “v_result_v” will display the value of the random.
      * “
      v_result_v”, “v_value_v”, “v_response_v” are variables pre-defined by the bot.
      v_result_v“: Is equal to the result of the last random used (for example “%=1.6”)
      * “
      v_value_v”: Equals the last “code” or “bet” indicated in a command “!advance [box] [code]”.
      * “
      v_response_v”: Is used with the command “j!repondre
      * <html><span style=“color:#8000FF”>Variable description</span></html> (the value of a variable can be included with “v_variable_name”)

      ===== Textual variables: =====

      Textual variables have a word or phrase as their value. They are declared/modified on the same line as classic variables, objects, states, etc., in the form :

      <html><div style=“background:#dddddd”>
      <span style=“color:#FF0000”>variable_name</span>|<span style=“color:#0000FF”>variable_t</span>|<span style=“color:#FFA000”>Value</span>|<span style=“color:#30B000”>Phrase displayed when modified by player</span>|<span style=“color:#8000FF”>Description</span>
      </div></html>
      * <html><span style=“color:#FF0000”>Variable name:</span></html> without spaces or accents.
      * <html><span style=“color:#0000FF”>“variable_t”</span></html> is the
      keyword telling the bot that this is a textual variable (this is similar to how “variable” works)
      * <html><span style=“color:#FFA000”>Assigning or modifying the value of the variable</span></html> (a word or text)
      * <html><span style=“color:#30B000”>This sentence will only be displayed when the player changes the value</span></html> via “
      I!rep value
      * <html><span style=“color:#8000FF”>Description displayed if the player examines the variable</span></html>

      To display this variable in a text, you need to surround it with “
      t_” and “_t”. For example “Nice to meet you t_heros_name_t**”