---
description: >-
  This page provides details about writing your custom behaviors for articles
  and actions of your VR product.
---

# Step 4 - Custom

This step allows you to write your customer behavior outcomes for articles and their action-responses. The articles and their respective action-responses are made available to design your Virtual Reality Scene behaviors. Following are the allowed code-constraints to write your behaviors (customized business rules).

Behaviors can be written using conditional statements. We have created customized conditional constructs which are easy for non-coding practitioners like Requirement Analysts to author behaviors at their convenience.&#x20;

Following are the allowed Syntax conditional constructs

### **If**&#x20;

This is used as **if** type behavior conditional expression. Following is the conditional construct. The text in italics is for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: If**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior condition_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark>**:**<mark style="color:orange;"><</mark> _behavior outcome here_ <mark style="color:orange;">></mark>**!**

### Elf

This is used as **Else-if** type behavior conditional expression. Following is the conditional construct. The text in italics is for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: EIf**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior condition_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark>**:**

&#x20;                     <mark style="color:orange;"><</mark> _behavior outcome here_ <mark style="color:orange;">></mark>

&#x20;                  <mark style="color:orange;"><</mark>_behavior outcome here_ <mark style="color:orange;">></mark>**!**



### Switch

This is a typical Switch case type behavior conditional expression. Following is the conditional construct. The text in italics is for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: Switch**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior condition_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark>**:**&#x20;

&#x20;                   **case**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark><mark style="color:orange;">:<</mark>_behavior outcome here_ <mark style="color:orange;">></mark>

&#x20;                **case**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark><mark style="color:orange;">:<</mark>_behavior outcome here_ <mark style="color:orange;">></mark>

&#x20;                **case**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:blue;">#</mark><mark style="color:orange;">:<</mark>_behavior outcome here_ <mark style="color:orange;">></mark>

&#x20;               **default**:<mark style="color:orange;"><</mark>_behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:orange;">**!**</mark>

### For

This is a typical **for** loop type behavior conditional expression. Following is the conditional construct. The text in italics is for for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: For**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior initialization_<mark style="color:orange;">>/<</mark> _behavior range_<mark style="color:orange;">>/<</mark> _behavior iteration_<mark style="color:orange;">></mark><mark style="color:blue;">#:</mark>

&#x20;                   <mark style="color:orange;"><</mark>_behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:orange;">**!**</mark>

### While

This is a typical **while** loop type behavior conditional expression. Following is the conditional construct. The text in italics is for for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: While**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior initialization_<mark style="color:orange;">></mark><mark style="color:blue;">#:</mark>

&#x20;                   <mark style="color:orange;"><</mark>_behavior outcome here_ <mark style="color:orange;">></mark><mark style="color:orange;">**!**</mark>

### Do-While

This is a typical **Do-While** loop type behavior conditional expression. Following is the conditional construct. The text in italics is for for expression behavior condition and behavior outcome if the condition succeeds.&#x20;

**Syntax: Do**<mark style="color:blue;">#</mark><mark style="color:orange;"><</mark> _behavior outcome_<mark style="color:orange;">></mark><mark style="color:blue;">#:</mark>

&#x20;               **While**<mark style="color:orange;"><</mark>_behavior condition_ <mark style="color:orange;">></mark><mark style="color:orange;">**!**</mark>





**Here is the backend template of custom.json file**

```json
{
	"behavior":[
	{
		"bid":"",
		"bname":"",
		"bdescription":"",
		"articlesused":"",
		"logic":""
	}
	],
	
	"borderasync": "",
	"bordersync": ""
}
```

**Here is the finalized template of custom.json before getting published into the database**

If we observe the behavior rules are converted into BASE-64 encoding as we cannot save a code-snippet inside a JSON file. We provide a provision to decode the BASE-64 behavior rule for pracitioners to review the behavior logic.

```json
{
	"behavior":[
	{
		"bid":"pinfall",
		"bname":"behavior for pin fall",
		"bdescription":"",
		"articlesused":"",
		"logic":"aWYoIHtfZ2FtZWJhbGwgJGhpdHMgX2FueXBpbn0gT1Ige19hbnlwaW4gJGhpdHMgX2FueXBpbn0pCnRoZW4gJGZhbGwoX2FueXBpbik="
	},
	{
		"bid":"scoreupdate",
		"bname":"rule for scoring",
		"bdescription":"",
		"articlesused":"",
		"logic":"aWYgKCRyb2xsID0gdHJ1ZSkKcG9pbnQgPSAjY291bnQoJGZhbGwoX2FueXBpbikpICogaW5kX3BvaW50CmVsc2UgCnBvaW50ID0gbnVsbAo="
	},
	{
		"bid":"strikescore",
		"bname":"rule for scoring",
		"bdescription":"",
		"articlesused":"",
		"logic":"aWYgKHskcm9sbCA9IHRydWV9IEFORCB7I2NvdW50KCRmYWxsKF9hbnlwaW4pPTEwfSkKdGhlbiBwb2ludCA9IHN0cmlrZV9wb2ludAplbHNlCnBvaW50ID0gbnVsbA=="
	}
	]
}
```

Managing State



{% code overflow="wrap" lineNumbers="true" %}
```json
{
    "state": [
        {
          "id": "",
          "name":"",
          "initial": "",
          "transition":[
            {
              "event":"", 
              "target":""
            },
			{
              "event":"", 
              "target":""
            }
          ]
          "final":""
        },
        {
          "id": "",
          "name":"",
          "initial": "",
          "transition":[
            {
              "event":"", 
              "target":""
            },
			{
              "event":"", 
              "target":""
            }
          ]
          "final":""
        }
    ]
}
```
{% endcode %}
