tutorials/Using the if command

Overview

/logicif is a command that can drastically increase what users can do with the plugin. Currently it is barebones, but more content will be added in the near future.

There is also an API for using the command, for developers that wish to contribute with their own plugins.

Basic Structure

Every logicif command is made up of three parts: the "flag", the "true command", and the "false command", and is formatted like so:

if <flag>... ? [true command]... : [false command]...

The "flag" is similar to a normal command in that is starts with a unique identifier/name, and is followed by multiple arguments. Like commands, other plugins can register flags of their own. The "flag" is either true or false, and depending on which it is, will either execute the true command or the false command.

Either the true command or the false command can be left blank, and nothing will happen when the flag is that respective type.

Examples

if hasequip @e[t=zombie] head @i[m=skull_item,d=3,o=FootofTape] ? c kill @e[t=zombie] :

  • This would check if the nearest zombie has a skull owned by FootofTape on its head, and if so, kill it.

if haspassenger @e[t=minecartrideable] ? c accelerate @e[t=minecartrideable] 0 0 5 : c kill @e[t=minecartrideable]

  • This would check if the nearest minecart has someone in it, and if so accelerate it, destroying it otherwise.

Using && syntax

Normally, commands can be chained by using <command> && <command>, but this works slightly differently for the if command. The best way to show you how is through examples:

if inventory @p isfull ? say It's full : say It's empty & c kill @p

If the nearest player's inventory is full, the server will say "It's full". Otherwise, the server will say "It's empty" and then kill the nearest player.

if inventory @p isfull ? say It's full : say It's empty && c kill @p

If the nearest player's inventory is full, the server will say "It's full" and then kill the nearest player. Otherwise, the server will say "It's empty" and then kill the nearest player.

Helpful links

List of flags included in LogiBlocks

Using setflag and getflag


Comments

Posts Quoted:
Reply
Clear All Quotes