Command blocks documentation

Command blocks documentation

Postby dzienny » 17 Mar 2012, 19:43

I’ve been working on command block functionality for some time and althought it’s not finished it can be used to some extent already. To add a command block you have to edit a map config file.

There is separate config file for each map and it is saved in XML format. The file is located in the same directory as a map file and its name is constructed according to the following rule ‘[map name].cfg.txt’, for example if there is a map saved as cube.lvl the corresponding config file will be named "cube.cfg.txt".

The structural design of the configuration file that contains command blocks info:
Code: Select all
<MapSettings>
<CommandBlocks>
<CommandBlock x = "" y = "" z = "" block = "" onChange = "">
<Command trigger = "" cooldown = "" >command syntax</Command>
<Command … > … </Command>

</CommandBlock>

</CommandBlocks>
</MapSettings>

Attributes x, y, z and block are obligatory, the remaining ones are not.
x,y,z – position of a block
block – a block name,
onChange – action that is performed when the block is hit or built at the given position, possible values: ‘Restore’, ‘DoNothing’, ‘Destroy’, where ‘Restore’ is a default value and ‘Destroy’ is not implemented yet. ‘Restore’ – if the block is changed by a player it is restored right after, ‘Destroy’ – if a block is changed by a player the command block is removed, ‘doNothing’ – if a block is changed it is not restored but command block is still active.
trigger – defines action that triggers a command. Valid values for this attribute are ‘Hit’, ‘Build’, ‘Walk’. They can be combined, for example if a command is meant to be triggered in case a block is built, or hit the value should be ‘Build, Hit’. A comma delimits values.
cooldown – defines the time that has to pass before the command can be triggered again. The time is measured in seconds, and it can be represented as decimal value. Default value is 1.
command syntax – it is the place where you type command name and command arguments.

You can create multiple command blocks and each command block can contain multiple commands, which can be triggered on different occasions. But you can’t create more than one command block at the exactly same position as it will cause errors, and it wouldn’t make much sense either since you can put as many commands as you want in one command block element.
In order to add command block you have to edit file manually and use ‘/setlava reload cmdblocks’ command, or just reload the map, as command blocks are loaded at the same time that map is being loaded.

Not implemented yet, but in progress:
- possibility to add command blocks from within the game,
- ‘Destroy’ property,
- a special type of commands that will be more concrete, and made especially for command blocks.

Example of a valid command block settings that works for cube.lvl:
Code: Select all
<MapSettings>
  <CommandBlocks>
    <CommandBlock x="35" y="33" z="35" block="water">
      <Command trigger="Walk" cooldown = "5">say This message is showed every 5 second.</Command>
      <Command trigger="Walk" cooldown = "10">say %cThis message is displayed every 10 second!</Command>
    </CommandBlock>
    <CommandBlock x="30" y="33" z="30" block="red">
      <Command trigger="Hit" cooldown = "0">say Don't hit me!</Command>
    </CommandBlock>
    <CommandBlock x="29" y="33" z="30" block="yellow" onChange="DoNothing">
      <Command trigger="Hit, Build" cooldown = "0">say %dYou just changed the block at (29,33,30)</Command>
    </CommandBlock>
    <CommandBlock x="29" y="33" z="29" block="green" onChange="DoNothing">
      <Command trigger="Hit" cooldown = "0">say %cYou destroyed a block</Command>
      <Command trigger="Build" cooldown = "0">say %aYou placed a block!</Command>
    </CommandBlock>
    <CommandBlock x="28" y="33" z="30" block="lava" onChange="Restore">
      <Command trigger="Hit" cooldown = "0">say %eWow, how did you do it?</Command>
      <Command trigger="Build" cooldown = "0">say %aIt is unbreakable!</Command>
      <Command trigger="Walk" cooldown = "10">say %bAre you taking a lava bath?</Command>
    </CommandBlock>
  </CommandBlocks>
</MapSettings>
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Return to News and Announcements

Who is online

Users browsing this forum: No registered users and 1 guest

cron