articles/Variables
THIS PAGE IS OUTDATED
//i.imgur.com/OPLBqGe.png" rel="noopener nofollow" target="_blank">http://i.imgur.com/OPLBqGe.png" alt="[EN] English" title="[EN] English">
Variables and its Types
Variables are data pieces which are stored by the plugin. You can use the primitive types from programming like strings (text/letters), ints, decimals (numbers), but you can also use minecraft related types like players, locations and regions. These data pieces are stored in the plugin, and in an outsider database in the plugins folder. You can set variables and use them later for any purpose.
Set, Read and Use
To set a variable use the: /cc setvar <name> <value> command. With this order you can set the value of the variable easily to any text or number. But what about players, locations and regions? Locations can be given as text in a given format, so it can also be given as value with this command. Any other types which cannot be printed directly must be a result of another CleverCommand command. Then you use a @ mark before the command and there you go. For example:
/cc setvar tpCount @cc tp*count*mobs #from:#rg:myGarden #to:#warp:farm
This command teleports all the mobs (non-player entities) from my garden (a given worldGuard region) to the previously set warp called farm. The mobs arrive, and the command returns the value I asked (with *count), the count of mobs have been teleported. Then sets the value of the 'tpCount' named variable to the count.
But what can I use it for? You're able for example... getting information about the teleportation, and broadcast it:
/cc bc Broadcast!! %tpCount% animal teleported to the public farm, free fresh meat guys!!
And as you press enter you will se the result of your command, but instead of seeing %tpCount% in the message there will be the number of the mobs teleported there previously.
Sure this was a silly example, but you can count the players on a given region. This sounds bad too? And use it as a requirement later? What about an arena, which teleports the players from the lobby room when they reach the minimum participant count of the arena? Pretty usable and efficient I think. Requirements will be added (in working state) a little bit later, but until then you can use variables in any other command between the %% marks.
Just like:
/mute %player%
/broadcast Hello, I use variable in native mc command: %myVariable%
Value returner commands cannot be used in commands directly like:
/broadcast @cc tp*count #from:.. #to:... mobs teleported!
Because, as you see, there are spaces between the command arguments and the CleverCommand plugin won't figure out where is the end of the asked command (@), and where continues the text of the broadcast command. However, it is planned in a form as the following:
/broadcast @{cc tp*count #from:.. #to:..} mobs teleported!
But again, this is just planned.
Comments