When you press ctrl+r
to run your code, it executes it from top to bottom by default. But you can use various functions to change its flow.
Functions are the essential building blocks of programming. They take inputs in their (parentheses) and proceed to do their action. Here are the functions that have to do with codeflow:
loop(value)
- Repeats the code before it. Repeats forever by default. The value input changes the amount of loops. You can also do var=loop()
to get how many iterations have been ran through. Any code after the loop()
function will be run once after the loop is done. You can even go crazy with having multiple loops, but this can be confusing.stop()
- Stops the entire script.wait(value)
- Halts the script for value seconds, then continues.flip()
- Updates the screen, making all preceding lines run at a consistent framerate. moveto(target)
- Moves to the target line. You can either put in a number to change the line by that amount forwards or backwards, or you can input a "string" to move towards an anchor of that name.key("key")
- Returns 1 or 0 based on if the input "key" is pressed or not. You can use any Love2d keyconstant > linkModifiers change how lines are ran. They go right before a line.
*
- Makes the line never run. Useful for commenting out code or text.!
- Makes the line only run on the first loop.?
- Makes the line happen with a 50% chance.??
- Makes the line happen with a 25% chance.^
- Makes the line run if the previous one did too.*^
- Makes the line run if the previous one didn't.@
- Turns the line into an anchor, which you can move to using moveto(anchor)
.
Hashing is SIGN's weird way of handling conditionals, but it isn't very like other languages. They are a combined interaction between two registers - hash
and tag
- and 4 modifiers - =#, >#, <# and x#
.
hash
& tag
- The two variables that get compared. Hash begins at 0 and tag at 1.=#
- Makes the line run if hash
is equal to tag
.>#
- Makes the line run if hash
is bigger than tag
.<#
- Makes the line run if hash
is smaller than tag
.x#
- Makes the line run if hash
is not equals to tag
.Math is very important when programming, and there's a couple of things you need to keep in mind if you want to use it in SIGN.
value=value
- Sets one value to another.value+value
- Adds two values together.value-value
- Subtracts one value from another.value*value
- Multiplies one value with another.value/value
- Divides one value with another. If you want it to round after you divide, use \
instead. This is also how you can round values: var\1
for example.value&value
- Concatenates one value with another. Concatenation is very simply glueing two numbers or strings together, for example: print(17&29)
results in 1729.value%value
- Modulates one value with another.random(min|max)
- Returns a random number between min and max.base(var|target) or base(var|origin|target)
- Converts a var to a different base. Can go up to base 36 and cannot go below base 2. You can use the origin to set the base of the original variable.In SIGN variables don't need to be defined, but there are a couple variables that have a specific impact by default, called registers. Variables start at 0 by default.
You can use a bunch of functions and registers to draw things on the screen. The screen consists of 48 by 32 characters, which all have a fore- and background colour. They all must adhere to a specific tileset and colour palette.
Controlling where you draw on the screen is done via the sprite, which you can manipulate using these registers:
sx & sy
- The x and y position of the sprite in tiles.show
- Wether the sprite is visible or not. 1 = visible, 0 = invisible.sprite
- The character(s) representing the sprite.bg & fg
- The fore- and background colour of the sprite.There are various ways to write characters on screen, and it is important to understand how the different functions function.
print(value)
- Prints the given write(value)
- Does the same as print()
, but does not add a newline afterwards, and moves the sprite to the tile after what has been written.stamp(value)
- Stamps the sprite on its location. Can optionally have a wrap
- Register that controls wether the sprite wraps around the screen or not.
SIGNpad uses a SIGNSCII tilest, which has some non-letter characters too. You can access these by going in fullscreen, showing a little guide to all the characters. Once you know what you want to type, simple type the tile's number, and press ctrl+b
to convert it to that character. Do note that copy+pasting over these characters can be a bit weird at times.
clear(colour)
- Changes the background colour of all tiles. Sets it to white (colour 3) by default.char("string"|target)
- Returns a specific character from a string.read("target")
- Reads and then returns the target property of the sprite's tile. Target can be "fg", "bg" or "char".length(value)
- Returns the length of the value.byte(char)
- Converts a character into its tile index (number).totile(index)
- Does the opposite of byte(char)
.