An intro to blocks | TUTORIAL | Difficulty: 🟩

So you want to code in gimkit? This is a tutorial that will try give you a good introduction to the subject!

First steps

Only some devices can run code. Some examples of this are the trigger and text object. For now, we’ll use triggers, so go ahead and place one down. When you click on it, will be two tabs on the left: Options and Blocks. Click Blocks!

Next, click “When triggered”, under create new block. This makes a place where we can write code. The code will run when the trigger is triggered (Hence the name “When triggered”)!

Now, we get a place where we can code! Let’s write our first program! Click on the tab that says essentials, and drag out the “Add Activity Feed For Everyone” and “Triggering Players Name” blocks.

The add activity feed block makes a message pop up in the bottom right corner of the screen, kind of like when you tag someone in tag! The triggering player’s name block holds the name of the player who stepped on the trigger. Piece the two blocks together like shown below, then play the game and step on the trigger! You’ll see your name pop up in the bottom right corner! Cool! If you invite a friend to your game, you’ll see their name pop up as well!

Properties and Math

Don’t get scared by math, it can be really useful. We’ll get to something more fun in a minute, but for now, we are going to do some number doubling to answer the question: If your running speed doubled every second, how fast would you be going after 5 seconds? What about 10? How many seconds until you’re running faster than the Flash?

So what is a property? A property is a device that holds data we can use in our code! Let’s make one! Go to your devices tab and search for “property”. It should look something like this:

Now, lets set a starting value, type, and name for our property! The name is what the property is called, the starting value is what the property stores when the game starts, and the type is the type of data the property stores, like numbers or text. We’ll call our property “number”, set it’s starting value to 2, and set it’s type to number:

Now, lets open up our trigger! However, when we go to the blocks tab instead of clicking the box under “Create Block”, click the box under “Edit Block”!

So now we need to get the value of our property. How do we do that? Luckily for us, there is a block for this! Click on the essentials tab again, and drag out the “Get Property” Block! When you do, you should see a menu pop up asking you what property you want to get. Select “number”, the property we just made!

Drag the two new blocks together, so you have something that looks kind of like “Get Property: Number”. Now, we need to display the value of our property in the activity feed. Drag out the “Add activity item for everyone” block from the essentials tab, and attach the get property block to it:

However, this wont work. Why? Because the activity feed only displays text. Computers can be really smart, but sometimes they can be pretty stupid. Trying to display a number without converting it to text just doesn’t work. To fix this, we can convert our number into text. Go to the text tab, and drag out a “Convert Number to Text (with commas)” block, and put it in between the get property and add activity feed blocks like this:

Now if you go into the game, you’ll see the number “2” when you step on the trigger! However, we want the number to double. To do this, we need to set the property to two times it’s current value. How do we do this? With the “Set property”! Drag one out from the essentials tab. Once again, select “number”, and attach the blocks together like this:

This means that we will set the property after we show it’s value. But how do we find the new value? With math of course! Go to the math tab and drag out an addition block. Click the drop down menu in the center and select “X” (Multiplication).

Then go back to the math tab and drag out a number. Change the number to two, and drag it into one of the slots within the multiplication block!

Now we need to get the value of the property again, and put it in the other slot. Try to do this without help, but if you don’t remember how to get the property, you can scroll up a bit and find where we did it the first time. After this is done, here is our code:

![image|690x205](upload://znj8feJbjhrIqwimD7ioNFSOOBq.jpeg

Now let’s test it!

As you can see from my activity feed, each time, the number is twice as large as the previous one! See if you can use this information to figure out now fast you would be running (if your running speed doubled every second) after 5 seconds! What about 10?

What we learned & conclusion

We learned how to make code, and we wrote our first bit of code, and did a bit of math. If you want to explore on your own, another fun thing to mess with is text objects, which also have a coding option. If you want me to make this tutorial into a series, leave a like! If you have questions, ask in the comments! If you spot any errors I made while writing this, leave a comment and I’ll fix it!

Thanks for reading!

— Blackhole927

29 Likes

This is actually helpful! Thanks!

3 Likes

This is a question for Help. Right now, I need to setup a server so I won’t be able to test untill tomorrow. Post this in Help and see if anyone else knows!

4 Likes

Really nice tutorial. Just wanted to let you know one of the images is in link form.

1 Like

Thanks! I can’t edit this right now, but I will as soon as I can!

2 Likes

Question: How do you make activity feed that says this: (player name) joined the game

I’m assuming that you mean a player joining late. Put a lifecycle device that is for “player joins late”. If you want to use less memory, wire it to a notification. If you wish to do an activity feed, wire pulse it to some text and add activity feed blocks.

1 Like

@Blackhole927 welcome to the community!

I second that.

What do you mean, he joined before you :joy:

Also, why are you resigned?

1 Like

Now find my first post >:)

Hint: It’s on something Cameron posted

read through the devices post in help

I third that.

While you are at that, find my first post too…

It is impossible to find my first post, because it was on the 1000 chat chain I think, and that obviously got deleted, so…

yeah i just checked your whole account (yes in one minute) and it is not there

Anythinger’s first post is currently on a locked post.

i just found a post where @CringeKarlScott @ArcherThesu and some random person ive never heard of all had their first post! but it was closed so i couldn’t welcome them

At least it’s visible…

1 Like

Only 22 days late lol

2 Likes