A sequel to the Ultimate Guide For Every Deviceâ€¦see [ đź“ś ] The Ultimate Guide To Every Device Part 1!

May be merged into the Ultimate Guide for Everything.

Part 4 of the â€śTUGâ€ť Series.

**Note: You may see some users mention transmissions, channels, etc. If you donâ€™t know what that is, look at this guide.**

Blocks. Block Coding is what any advanced game needs to create mechanics. This guide will tell you what each block does, and which devices will be compatible with blocks!

The Basics: This is what you need to know before actually doing block coding.

## Devices Compatible With Blocks

- Trigger
- Knockout Manager
- Inventory Item Manager
- Item Granter
- Popup
- Notification
- Overlay
- Text
- Tag Zone
- Questioner

## How to Access

When first coding, one thing you may want to know is how to get there! It is quite simple. When viewing a block compatible device interface, you should see this.

Click on that.

After that, you should either a couple options. Some devices have more, others have less. (Triggers have 1, Questioners have 4). On Wire Pulse means whenever it receives a signal from a wire, the block of code will run. When Receiving on Channel means that the block will run when receiving on a specific channel. Click on one of those.

After, you should see a couple categories. Some will have the for this device only, others, like the trigger, will not have that. Anyway, that is how to get to the block interface!

## Block Categories

You will find that there are 5 (or 6) main categories to blocks. Their names are â€śEssentialsâ€ť, â€śLogicâ€ť, â€śMathâ€ť, â€śTextâ€ť, and â€śVariablesâ€ť.

## Essentials and Variables

## Branch of Mathematics

**Numbers**

The first block in the Math category is a simple block with a 0.

This block can be placed inside of other blocks. Like this:

Easy right? Well this simple little block is extremely important. Itâ€™s one of the most important blocks in GKC, because it can allow you to increment properties, do advanced mathematics, and so much more!

**Basic math**

The second block in the math category is this one:

This block enables us to do basic math operations, such as: addition, subtraction and multiplication. In order to do a simple adition do this:

Now that you have that, why isnâ€™t anything happening??? Simple, we need to add a way for the result to be sent. Add the following:

Then press play and see the result. (Make sure you have a lifecycle wired to the trigger to trigger it when event occurs)

(Your resolution should be at 80% or less to see the small message at the bottom right corner)

Above you can see what it should look like in game.

Picture in editing mode:

Weâ€™ve made a simple math equation! Pat yourself on the back. Sometimes people want to make really complicated equations using basic operators, but how?

Letâ€™s say we want to find what is the result of 3+(1/5)-9. In mathematics you have PEMDAS for the order of operations, well, so does the computer!

Do this:

In the images above the result would be

Now normally when we do 3+(1/5)-9 we get -5.8 so why did we get that super long number? Well in coding this happens a lot because the computer is transforming the response to a string and well it changes its format to a decimal thatâ€™s very long. In order to fix that head on over to the next part of the Branch of Mathematics!

**Rounding and estimation**

In mathematics we get a lot of weird and long numbers like in the example above, so how do we fix it? Rounding! One of the most powerful tools in math. Itâ€™s the sixth block in the math category. Here it is:

Looks very simple, right? Well this little tool can be a life saver when it comes to weird and long numbers! Add it like this to the blocks we have:

Why did it say the answer was 6? Well remember that rounding a number means it goes to the neareest **whole** number, not the nearest tenth or decimal point. I sadly donâ€™t know how to find the nearest tenth, but maybe you can find a way!

- Homework! Try to find a way to find the nearest tenth or decimal of a number, instead of the whole number!

If you tap on the word â€śroundâ€ť inside of the block you will see this:

If you want to round up or down instead of just the nearest whole number, chose one of those options. They are constantly overlooked, but they can be quite useful for certain things, like: finding the position of someone on a coordinate plane and things like that.

**Randomizing**

You may want to randomize a password to a door, but how? The random block! Itâ€™s the last block in the math category. This is it:

Now onto how to randomize stuff! So this block is very simple to understand, but essential in mathematics. Letâ€™s say we want to multiply two different numbers that are random. Hereâ€™s what to do:

It should send you the answer that is completly random. In order to know what numbers were picked to multiply do this:

You may notice we have two variables in the picture to multiply, well thatâ€™s because we can do math with variables, not just numbers! (Properties too!)

The small button above is next to the create text with block.

Drag the item block into the j0in area.

And now hit run and it should send something like this:

**Logic in math**

By now you have probably noticed this block:

But what exactly is it, and what do you do with it? Well thatâ€™s where logic in math comes in! This probably should be in Logic Gates, but itâ€™s in the Branch of Mathematics, because it uses math!

**Advanced Mathematics**

(Leaving this to WhoAmI)

**Trigonometry**

(Leaving this to WhoAmI)

## Logic Gates

**If statements**

If statements run a check to see if specified conditions are true or false.

Clicking on the gear opens a sub-menu.

In the sub-menu, you can build the sub-blocks to create more complex IF statements.

*If-else*

If the statement above it returns FALSE, then run the if statement. Will not run if the one above it returns TRUE.

*Else*

If all other statements in the IF block return false, the Else returns true. Any that return true above it causes it to not run.

At any statement in the block, if the conditions are TRUE, then it stops checking and executes the code in the statement that returned true.

Other blocks from the LOGIC category can be put into the IF blockâ€™s statements. These check conditions and decide if it returns TRUE or FALSE

**EXAMPLES**

In this example, only the one line will run: the one that checks if var NUM = 2.

Because var NUM does indeed equal 2, the first line will return false, moving to the next line,

`ELSE IF: NUM = 2`

Because the ELSE IF statement returns true, the code inside it is executed, and the entire IF block ends.

**And or or?**

The third block in the logic category is the and operator. This operator allows you to check if multiple things are true intsead of 1.

In the picture above, the block of code *will* broadcast the message on channel true because num1 and num2 both equal true. If one of them was false or something else besides true, it would not broadcast the message on channel true. If you tap on the word â€śandâ€ť of the block it will show you this:

Tap on or and set num2 to false. Even though num2 equals false it still sends the message on channel true because the or operator checks if at least 1 of the variables(or other things) are true.

**More details**

If you want to learn more on logic gates check out this guide.

## Terminology

**Increment**

Incrementing means to add 1 to a variable or property. You would do these:

You can also say incrementing by 5 or any number, but that doesnâ€™t really have any uses.

## Text

## For this device only

## Other

## User Assignments

Anythinger: Iâ€™m doing Essentials and Variables

WhoAmI-The Branch of Mathematics is mine.

Heretohelp- Every deviceâ€™s â€śfor this device onlyâ€ť

@mysz- i wanted to do mathetmatics :( , but I guess Iâ€™ll do text.

Dragontamer: Iâ€™m doing logic gates.

Getritheked: Iâ€™m doing terminology.

VALUEX- Helping out WhoAmI with the Branch of Mathematics.

# No one is currently editing

## Changelog (UTC)

2023-07-21T20:00:00Z

WhoAmI added a list of block compatible devices.

2023-07-21T21:59:00Z

Anythinger edited skeleton to match TUG for Devices.