Platform Builder

Platform Builder

评价数不足
Command Prompt for dummies
由 Anti 制作
Command Prompt is a very useful tool in Platform Builder that allows you to customize your games easier and a lot better. Here I will be explaining how to use them at best. After learning at full Platform Builder's command prompt, you'll see like learning a real programming language is actually easier.

Guide updated at PB version: PB 9.0
   
奖励
收藏
已收藏
取消收藏
Basic Commands
First of all, you should know what a command is.
"Commands are text that you put inside command prompts to perform certain actions."
Now you may be wondering what's a command prompt.
"Command prompts are the places where commands are placed, and they are executed by certain actions."

To start a little bit, we should start using one of the most basic commands ever.
health = 5
This command will set the player's health to 5. Simple? Let make it a little bit more interesting.
You can change the operator, to make operations such as add or subtract.
health + 5
You can also change other parameters, such as money, ammo, max health etc.
//Adds 3 to max health, and then, will add 3 to health max health + 3 health + 3

Platform Builder allows you to comment your code. This is part of the code that won't be executed nor compiled but eases the understanding process of the code, commenting what all stuff does. Anything after // won't be executed nor compiled. Take that in account!
You can add comments like this:
//Hello, I'm a comment

Note: Most PB commands aren't space-sensitive nor case-sensitive
Basic Structure of a Command
Most of the commands in Platform Builder works in the same way:
//command | operator | value
There are some other ways to use commands, but this is one of the simplest ways.
Variables
Yeah. You listened right! Platform Builder also allows you to create custom variables.
There are four types of variables.
  • Area variables
  • Course variables
  • Game variables
  • Local variables
The difference between them is how much time they will last to be destroyed. Area ones will be cleared once you leave that area. Course ones when you leave the full course. And game ones will last forever. Its recommended to use them correctly for avoiding variable cluttering on memory, causing bad performance.

Local variables are special because they are local to the object that executed them. This means, you can have 5 same enemies and each one will have this same variable, but each one will have a different value for it. This could be useful in various manners. One example is to count how many times an enemy jumped.

First of all, you should declare any variables you will use before using them.
To declare any variable just say the type and "var", then the name for it.
Example:
area var jumps = 0 course var collectibles = 0 game var totalscore = 0 var i = 0 //These work just like area variables, but we declare it shorter local variable dashTime = 0

For changing its value, we don't need to put the type again

jumps = 0 //Sets the variable called jumps to 0 collectibles + 3 //Adds to collectibles the amount of 3 totalscore * 2 //Sets totalscore to its double dashTime * 0.5 //Multiplies dashTime variable by 0.5 (Basically resulting in the half)

You can also get the value of another variable by just using its name.
health = max health //This will set our health to the value of max health (Important: health and max health are two normal commands / built-in variables)

You can also use [] around the variable names and will work the same way. But this is made specially for text commands. In those commands just placing the name won't work.
<hud text 1>Ammo: [ammo] //Make the hud text 1 say the amount of ammo we have <player 1>I've jumped [jumps] times! //Makes player 1 say how many times he jumped.

Important things to note:
  • Variable names can't hold any numbers, and probably won't hold most of other special characters too.
  • If a variable is not working properly, you may check before if the variable is being confused by Platform Builder as a command. (For example, naming a variable health will make PB confuse it with health command). You should avoid using command names for variables.

Conditionals
Conditionals are such one of most common things in programming. Conditionals allows you to check for stuff before doing anything. That means, you can check if your money is 100 or higher, and if it does, gives you a life.

Example:
if money >= 100 { lives + 1 money - 100 }

Conditionals can have multiple operator checkers:
= //Checks if its equal to the value > //Checks if its larger than < //Checks if its smaller than <= //Checks if its smaller or equal to >= //Checks if its larger or equal to != //Checks if its not equal to

You can also combine conditionals, for example:
if health != max health & money >= 500 { money - 500 health = max health }

You can use & for checking if both conditions meet, and | for checking if at least one of them meets.
You can do this way too for the same thing:
if health != max health and money >= 500 { money - 500 health = max health }

You can check else after a conditional, and it will be executed if the condition doesn't meet.
//Check if we have the spike boots equipped. If not, else commands are executed. if spikeBoots = true { <npc 1>You may pass! } else { harm + 1 <npc 1>You shall not pass! }

Lastly, you don't need to put {} if there is only one command to be executed
if jumps > 10 complete course

Some important things to note:
  • In Platform Builder, tabbing isn't really needed, but its helpful to read the code more clearly.
  • Conditionals are kinda more space-sensitive. Just saying!
Small stuff to check for yourself
You've learned the basics of command prompt. Now to finish, try to put the below code on the looping command prompt of your character:
//Running system: When you press pick button, makes you run. Just changing your speed.
//Feel free to change these values to whatever you want.
if key = pick speed = 70 else speed = 40

Also, check full list of commands, conditionals and bracketings here: https://theplatformbuilder.com/Command-Prompt/

See you next time!
2 条留言
Anti  [作者] 2020 年 12 月 20 日 上午 3:47 
Ty
CG_Maker (CGM) 2020 年 6 月 30 日 下午 7:09 
Looks great!