---
description: Welcome to the world of somewhat friendly computing!
---

# Getting Started

## Loading the OS

Currently all ways to use the OS are through GameJolt initially, if any other ways to use it show up I will add them.

### #1 - GameJolt Play

Step 1: [Press play on GameJolt](https://gamejolt.com/games/smileos/758766)

Step 2: Profit!

### #2 - GameJolt Download

Step 1: [Download the sb3 file from GameJolt](https://gamejolt.com/games/smileos/758766)

Step 2: Open the editor through the link provided on GameJolt [or here](https://turbowarp.org/editor?hqpen\&clones=Infinity\&offscreen\&limitless\&turbo\&fps=250\&extension=https://smilefordiscord.github.io/extensions/utilsv2.js\&extension=https://smilefordiscord.github.io/extensions/eval.js\&extension=https://smilefordiscord.github.io/extensions/dotprop.js)

Step 3: Load the project into TurboWarp

Step 4: Profit!

## The difference between OS and SS commands

There are 2 forms of command that can be sent to the operating system, OS level commands, and SS (SmareScript) commands.

OS commands are specifically for OS related stuff (Who coulda guessed), basically meaning that they run at a "higher" level than SS. Typically they run faster than a SS command due to being programmed directly through Scratch instead of running the SmareScript interpreter.

SmareScript, or SS commands, go directly to the SS interpreter which is the embedded programming language of SmileOS. To run an SS command directly you have to go through the **run** OS command.

## SmareScript

### Co~~r~~e Concepts

SmareScript is an interpreted programming language with a pseudo compiler, created specifically for SmileOS.

Syntax was inspired by Python, Lua, C++ and Basic. I would argue the language is easier to learn than all of these, however it remains fully capable of doing pretty complex stuff.

When a program is run it will continue until the main thread reaches the end of the compiled code.

### Hello World

Creating a "Hello World" program is very simple in SmareScript.

```objectivec
print("Hello World")
// Alternatively
print(Hello World)
```

SS always starts at the first line of a program.

### A more complex program&#x20;

Here's a piece of software to benchmark the speed of a variable sized loop:

```objectivec
var(time_after)
var(timer)

var(counter)
var(max_cycles)
counter $= 0
max_cycles $= 0

var(old_answer)
var(new_answer)
old_answer $= globals.answer()
new_answer $= globals.answer()

cls()
print("Speed Benchmark for SmareScript")
print("What number should it go to?")

// This function will wait until the user sends a new answer
func(check_answer) [
    new_answer $= globals.answer()
    if(old_answer ! new_answer) {
        max_cycles $= new_answer
    }
    if(old_answer = new_answer) {
        jump(check_answer)
    }
]
call(check_answer)

print("Starting!")

func(counting_function) [
    //print(.)
    counter += 1
    if(counter < max_cycles) {
        jump(counting_function)
    }
]

timer $= globals.y2k()
call(counting_function)

time_after $= globals.y2k()
time_after -= timer
time_after *= 100
time_after $= math.round(time_after)
time_after /= 100

cls()
print(string.join("Benchmark completed in ",time_after," seconds."))
```

As you can see, it's not a very complex language! However it does have some quirks that do need explaining.

### Variables

As seen above, declaring a variable in SmareScript looks like this

```objectivec
// Declares "Var1" as a variable
var(Var1)
// The compiler will now know this exists
// At compile time the program is scanned for each use of this variable
// Then replaced by a memory address, which means
Var1 $= "Hello World"
// Is the same as
v.1 $= "Hello World"
```

It should also be noted that the compiler is very stupid!\
<mark style="color:red;">**So make every variables name unique than the rest!**</mark>\
Otherwise this may occur:

```objectivec
// Obviously here we want 2 different variables to be made
var(Counter)
var(CounterOther)
Counter+= 10
Counter2 += 20

// However due to the poor naming the compiler will read this is as
v.1 += 10
v.1Other += 20
// This case is so bad that the broken piece wont even run

// With proper named it should look like this
var(Counter01)
var(Counter02)
Counter01 += 10
Counter02 += 20

// And it would compile to this
v.1 += 10
v.2 += 20
```

I would recommend avoiding using memory addresses directly.

SmareScript also has no form of variable types, if you attempt to parse a string as a number it will parse as 0. The words "true" and "false" also have special properties, being parsed as Booleans.

### Changing variable values

Changing the value of a variable is as simple as writing the variables name and using one of the 5 operators.

```objectivec
// Declares the variable
var(Variable1)
var(Variable2)
// $ sets the value of a variable
Variable1 $= 100
// + adds anything past the = to the variable
Variable1 += 100
// - subtracts anything past the = to the variable
Variable1 -= 100
// * multiplies anything past the = to the variable
Variable1 *= 100
// / divides anything past the = to the variable
Variable1 /= 100
// % performs a modulo operation
Variable1 %= 2 // It effectively acts like (2 mod Variable)

// Variables can also be set from other variables
Variable1 $= Variable2
// As well as using any of the included libraries (Excluding gfx.)
Variable1 $= math.floor(Variable1)
Variable1 $= string.join(Variable1, " is cool.")
Variable1 $= globals.y2k()
Variable1 $= keys.y2k()
Variable1 $= mouse.y2k()
// Note: Some functions in libraries do not return any value
// The value retuned will essentially be random, so dont use those!

```

[Click here to learn more about modulo](https://en.scratch-wiki.info/wiki/\(\)_Mod_\(\)_\(block\))

### Getting user input

SmareScript doesn't have any built in functions to wait for a user to import text.\
It is possible, but you will need to create your own routine for it.

So how would we go about it? Well lets see how the example program dealt with this.

```objectivec
// Creates variables
var(counter)
var(max_cycles)
var(old_answer)
var(new_answer)

counter $= 0
max_cycles $= 0
// We set the new and old answer to the current anwser
old_answer $= globals.answer()
new_answer $= globals.answer()

cls()
print("Speed Benchmark for SmareScript")
print("What number should it go to?")

func(check_answer) [
    // new_answer is updated every loop
    new_answer $= globals.answer()
    // Checks if new_answer is not equal to old_answer
    if(old_answer ! new_answer) {
        max_cycles $= new_answer // If so it sets the variable we want to update
    }
    // If the answers are the same it will go back to the start of the function
    if(old_answer = new_answer) {
        jump(check_answer)
    }
]
call(check_answer) // Starts the function
```

Now there's a lot to unpack here. Lets first go over func(), jump(), and call().

### Functions

Functions in SS dont have reserved any reserved names to start a program, as programs always start from the first line.

<mark style="color:red;">Functions are also stupid like variables so you still have to careful with names</mark>

<pre class="language-objectivec"><code class="lang-objectivec"><strong>func(main) [
</strong>    print("Hello World")
    jump(main)
]
call(main)
</code></pre>

The function above will print "Hello World" indefinitely.\
<mark style="color:green;">Tip: You can end any program at any moment by press</mark> <mark style="color:green;"></mark>_<mark style="color:green;">shift + C</mark>_

#### Anatomy of a function constructor

Creating a function looks like this

```objectivec
func(main) [

]
```

Functions use square brackets to contain the code within.\
You dont have to use strings to define a functions name

#### What's the difference between jump() and call()

Both **jump()** and **call()** will start a function the same way, the difference comes when the function ends.

When a function reaches the end of the code it contains, it checks if it should continue after the line of code that started it.

Basically **call()** tells the function to continue on after the **call()** function when it ends\
On the other hand **jump()** will not do this, and the function will continue after its closing bracket.

Make sure when you need a function to loop back on itself to **NEVER** use **call()** as it will create a perpetually expanding list of addresses that it needs to jump to before it can continue.

```objectivec
// So now looking at this piece of code it should make a lot more sense
func(check_answer) [
    new_answer $= globals.answer()
    if(old_answer ! new_answer) {
        max_cycles $= new_answer
    }
    if(old_answer = new_answer) {
        jump(check_answer)
    }
]
call(check_answer)
```



