Idiot Script Documentation
verion 6.2022.2a
Getting Started
Welcome to Idiot Script! Idiot Script is a simple block based programming language built in under a week. This Documentation is meant to provide explanation and walk throughs to the workings of this langauge and you can find a navigation bar to the left of this page.
First navigate to http://brohouse.dev/idiotscript. Once you have navigated to IdiotScript you will find three sections: The main board (center), the console output (right), and the block list (top). These sections will be explained as you continue
Press space to start the board (Start all of the starts start blocks)
Boards
Boards are the workspaces in which you place your blocks and block blocks. When you right click the board a context menu will appear with a few different options
- Clear Board
This will remove all blocks and block blocks from the board without saving
- Save Board
This option downloads the current board as a .is file called example_board.is
- Load Board
Opens a file choose dialog where you can pick .is files to load into your board. This does not remove the current board
- Set Board Speed
Sets the wait time between block calls in milliseconds. If you set the board speed to 1000 is will wait 1 second between every block. If speed is less than 1 it will activate Efficiency Mode
Efficiency Mode
Efficiency Mode is activated whenever you set the board speed to anything less than 1. This mode will essentially pour almost all resources into running the program rather than rendering and updating the blocks. This mode is useful for making real time programs such as game or simulations.
If you are using an infinite loop with Efficiency Mode such as a render loop you must use wait blocks in between loops. If you dont the page will loop forever and freeze.
Blocks
Every action event or otherwise is a block. Blocks contain arguments but never return anything. Blocks can only adjust current variables or create new variables.
A collection or line of blocks is called a block block. Add blocks to a block block by dragging a block to the end of the block block. Move the block block by clicking and dragging the first block of a block block. If you click on a block in the middle of the block block it will split the block block in two. The first block is regarded as the start of the block block
When right clicking a block block (the first block of a line of blocks) it will open a context menu for some things you can do with the block block
- New Block Block -wip-
- Delete Block Block Removes entire block block and all its block components
- Clone Block Block Copies entire block block to below
When right clicking a block (any block that isnt the first in a block block) it will open a context menu for some things you can do with the block
- Set Variable Name Opens a menu where you can edit the parameters of a block. What a block does with these parameters depends on what it does. For instance for a create var block the first input would be the variable name and the second input would be the value
- Delete Block Removes block and rest of the blocks in the line are shifted down
- Clone Block Copies block to below the block
Variables
Variables
Variables, like most languages, are named values that can be changed by blocks. For instance if you put a create variable block, set the variable name to "Test" and the value to 0, then have a set rand block set to "Test", the value of "Test" will now be a random value. If you then print out this variable with the print var block with variable name set to "Test" it will now print out the contents of "Test".
Trigger name
Trigger names differ from variables in the fact that they dont store anything. They are simply a marker for trigger/jump blocks to be linked up. You can have both a variable and trigger name without conflict
Triggers
Event Blocks
Start
The start block starts running the block block from the point in which the block is at. If the block is the beginning it will run the entire block block. Press space to run start blocks
- No arguments
On Draw Button
This event will trigger when the user presses a key on the draw window. It sets the variable e to the key code.
- No arguments
On Draw Mouse
This event will trigger when the user click the draw window. It creates variables mouseX and mouseY and sets their values. It also sets the variable e to the mouse button (0, 1, 2)
- No arguments
Variable Blocks
Create Var
Creates a new variable with the provided primitive as the value.
- New variable name
- Primitive value to store
Clone Var
Clones the value of the variable provided and stores it in a new variable with the name provided. If the new variable provided already exists it will overwrite the value inside.
- New variable name
- Variable to clone
Input Var
Halts everything and waits for input in the console. Once console input is recieved the program will continue. It will create (or overwrite) the variable and store the value input in the console into the variable
- New variable name
Set Rand
Creates (or overwrites) a variable with
- New variable name
Print Var
Prints the value of the variable to console
- Variable to print
Create Array
Creates an array with the given name provided
- New array name
Array Push
Appends the given variable to array
- Array name
- Variable to append
Set Index Of
Sets a specific index of array to given variable. It must be a valid index for it to work. For it to be a valid index it must be 1 less than the length and greater than 0.
- Array name
- Variable storing the index
- Variable to set
Get Index Of
Creates (or overwrites) a variable and sets the value to the value at array index provided.
- Array name
- Variable storing the index
- Variable to create/overwrite
Remove Index
Removes value at index from list.
- Array name
- Variable storing the index
Length Of Array
Creates (or overwrites) a variable and sets the value to the length of the array provided
- Array name
- Variable to create/overwrite
Print Primitive
Print but with no variables. Anything you put in the arguments will be printed to the console.
- The thing you want to print
Method Blocks
Add Vars
Sets the first variable to the two variables added together. Similar to the += operator in other languages
- Variable 1
- Variable 2
Multiply Vars
Sets the first variable to the two variables multiplied together. Similar to the *= operator in other languages
- Variable 1
- Variable 2
Divide Vars
Sets the first variable to the two variables divided. Similar to the /= operator in other languages
- Variable 1
- Variable 2
Subtract Vars
Sets the first variable to the first subtracted to the second. Similar to the -= operator in other languages
- Variable 1
- Variable 2
Floor Float
Sets the variable to itself floored. Aka (0.5) would become (0)
- Variable to floor
Sin / Cos / Tan
Sets the variable to itself through the trig function used.
- Variable
Mod vars
Sets the first variable to the first variable mod the second. Similar to the %= operator in other languages
- Variable to be modded
- Variable that will be the modulo
Concatinate Vars
Sets the first varible to the two variables added together as strings. Can be used to build messages for debugging or messages in console.
- Variable 1
- Variable 2
Wait
Waits the amount of time the variable states in milliseconds.
- Variable contianing the time to wait in mil
Trigger Blocks
Trigger
A marker for where jump blocks will jump to. If executed normally in line it will be skipped and not trigger since it does actually execute anything.
- Name of trigger (Not a variable)
Jump
Halts current block block and jumps to the trigger with the same name as the argument provided here. You will need a "continue" trigger block for a jump to have the argument "continue"
- Name of trigger to jump to (Not a variable)
Jump To Var
Does the same as Jump but instead uses a variable contianing the destination to jump to rather than a primitive. This is good for functions and dynamic returns. there are no return from subroutine equivalents so you will have to manage your own stack and use this block to jump back using your own stack. You can use an array to store a list of trigger names (pushed before jumping) and go back through to return.
- Variable containing the trigger name.
Jump If =
Does the same as Jump but only if the condition is met. Variable 1 must equal variable 2 for the jump to execute.
- Name of trigger to jump to (Not a variable)
- Variable 1
- Variable 2
Jump If !=
Does the same as Jump but only if the condition is met. Variable 1 must not equal variable 2 for the jump to execute.
- Name of trigger to jump to (Not a variable)
- Variable 1
- Variable 2
Jump If >
Does the same as Jump but only if the condition is met. Variable 1 must be greater (exclusive) than variable 2 for the jump to execute.
- Name of trigger to jump to (Not a variable)
- Variable 1
- Variable 2
Jump If <
Does the same as Jump but only if the condition is met. Variable 1 must be less (exclusive) than variable 2 for the jump to execute.
- Name of trigger to jump to (Not a variable)
- Variable 1
- Variable 2
Draw Blocks
<Note> If doing an infinite loop with drawing you must use a wait block.
Draw Window
Creates a window for the rest of the draw blocks to use.
- No arguments
Draw Var
Draws the value in the variable as a string on the draw window at the position of the two other variables provided
- Variable to print
- Variable of position x
- Variable of position y
Draw Square
Draws a square with the first two variables being the position and the third being the size
- Variable of position x
- Variable of position y
- Variable of position size
Draw Rect
Draws a rectangle with the first two variables being the position and the third and fourth being the length and width
- Variable of position x
- Variable of position y
- Variable of position length
- Variable of position width
Clear
Clears the screen. Keep in mind this sets the color to white.
- No arguments
Set Color
Sets the pen color to a css color ex. rgb(50, 50, 50) or red etc
- Variable containing the color
Start Poly
Starts the poly path. This block MUST have an end poly block somewhere downstream.
- No arguments
Set Point
Adds a point to the poly with the first variable being the x and the second variable being the y
- Variable containing the x
- Variable containing the y
End Poly
Ends the poly path. This finished the path and draws the finished poly to the screen.
- No Arguments