Denizen/Commands/Flag: Difference between revisions

From Citizens Wiki

< Denizen‎ | Commands

No edit summary
Line 3: Line 3:
A flag can be placed on the player, the NPC or globally. Flags placed on a player only apply to that player, and flags placed on an NPC only apply to that individual NPC based on its ID, so NPCs with the same name have different flags because they have different IDs. However, a global flag applies to the entire server and can easily be read from any script.
A flag can be placed on the player, the NPC or globally. Flags placed on a player only apply to that player, and flags placed on an NPC only apply to that individual NPC based on its ID, so NPCs with the same name have different flags because they have different IDs. However, a global flag applies to the entire server and can easily be read from any script.


If a flag's type (player, npc or global) is not specified, the flag is placed on the player by default, and if a value for the flag is not specified, the value is "true" by default.
Once you set a flag, you can call it back at any time with one of the [[Denizen/Replaceable_Tags#Flags|replaceable tags]].


== Usage ==
== Usage ==
To start off, you should set a flag. You can do this by using  
To begin, you need to actually set a flag. You can do this by using  
{| class="wikitable" border="1"
{| class="wikitable" border="1"
||- flag ({player}|npc|global) [name([#])](:action)[:value] (duration:#)
||- flag ({player}|npc|global) [name([#])](:action)[:value] (duration:#)
|}
|}
You can then use the [[Denizen/Replaceable_Tags#Flags|replaceable tags]] to call back the flag in any script.
If a flag's type (player, npc or global) is not specified, the flag is placed on the player by default, and if a value for the flag is not specified, the value is "true" by default.


...Too much for you? Let's slow it down.
...Too much for you? Let's slow it down.
=== Strings ===
=== The Basics ===
The first, most used, most basic flag you need is a string flag. Strings are basically just variables that represent words or phrases that you can change at any time.
 
To start using flags, you must first understand the basics. This means learning the 4 types of flags you can use: booleans, strings, integers, and lists.
 
==== Boolean ====
 
The first, most used, most basic flag you need (besides a default flag) is a boolean flag. A boolean is a variable that represents either true or false.
You can set a boolean flag to true by using <pre>- flag "RandomFlag"</pre> ...That's it. That automatically sets the flag named RandomFlag attached to the player interacting with the script as 'true'.
You can set it to false by simply doing <pre>- flag "RandomFlag:false"</pre>
This type of flag is helpful for 'if' statements. More information on that can be found [[Denizen/Commands/If#Flags|here]].
 
==== String ====
 
Let's move forward. Probably the second most important flag you'll need on your journey is the string flag. Strings are variables that represent words or phrases that you can change at any time.


For example, <pre>- flag "RandomFlag:Blah something whatever"</pre> would set the flag 'RandomFlag' on the player who's interacting with the script as 'Blah something whatever'.
For example, <pre>- flag "RandomFlag:Blah something whatever"</pre> would set the flag 'RandomFlag' on the player who's interacting with the script as 'Blah something whatever'.
Remember, you can also attach the flag to the NPC that the script is being run by, or the server itself by specifying 'npc' or 'global'. That will be covered in the advanced section.
==== Integer ====

Revision as of 16:57, 7 July 2013

Introduction

Flags are variables that can be checked anywhere in a script and in other scripts by using flag replaceable tags or the flagged requirement. A flag can be placed on the player, the NPC or globally. Flags placed on a player only apply to that player, and flags placed on an NPC only apply to that individual NPC based on its ID, so NPCs with the same name have different flags because they have different IDs. However, a global flag applies to the entire server and can easily be read from any script.

Once you set a flag, you can call it back at any time with one of the replaceable tags.

Usage

To begin, you need to actually set a flag. You can do this by using

- flag ({player}|npc|global) [name([#])](:action)[:value] (duration:#)

If a flag's type (player, npc or global) is not specified, the flag is placed on the player by default, and if a value for the flag is not specified, the value is "true" by default.

...Too much for you? Let's slow it down.

The Basics

To start using flags, you must first understand the basics. This means learning the 4 types of flags you can use: booleans, strings, integers, and lists.

Boolean

The first, most used, most basic flag you need (besides a default flag) is a boolean flag. A boolean is a variable that represents either true or false.

You can set a boolean flag to true by using

- flag "RandomFlag"

...That's it. That automatically sets the flag named RandomFlag attached to the player interacting with the script as 'true'. You can set it to false by simply doing

- flag "RandomFlag:false"

This type of flag is helpful for 'if' statements. More information on that can be found here.

String

Let's move forward. Probably the second most important flag you'll need on your journey is the string flag. Strings are variables that represent words or phrases that you can change at any time.

For example,

- flag "RandomFlag:Blah something whatever"

would set the flag 'RandomFlag' on the player who's interacting with the script as 'Blah something whatever'.

Remember, you can also attach the flag to the NPC that the script is being run by, or the server itself by specifying 'npc' or 'global'. That will be covered in the advanced section.

Integer