-
-
Notifications
You must be signed in to change notification settings - Fork 38
Control Structures
If and else statements are used for decision logic. An if statement can be used alone or followed by an else / else if statement.
if (condition)
do something if condition is true
if (condition)
do something if condition is true
else
do something if condition is false
if (condition-1)
do something if condition-1 is true
else if (condition-2)
do something if condition-1 is false and condition-2 is true
else
do something if condition-1 and condition-2 are both false
Loops are a programming construct used for iteration. In Visual Bukkit there are three types of loops:
- Number Loop
- List Loop
- While Loop
A number loop is used to iterate a certain number of times. Use the [VB] Loop Number
block to get the loop number.
This code broadcasts the numbers from 0 to 4.
A list loop is used to loop through each value in a list. Use the [VB] Loop Value
block to get the current value of the loop.
This code loops through all online players and messages "hello!" to them.
A while loop will continuously loop while the value in the <boolean> slot is true. Be careful not to create an infinite loop i.e. a loop that never stops (it will freeze your server).
This code loops while the value of the number
variable is greater than 0. Once the variable reaches 0, the loop stops.
[VB] Stop Loop
Immediately stops the loop.
[VB] Continue Loop
Advances the loop to the next iteration.
GMOD || Fuzio SCP : https://discord.gg/KBdNp3DCgj