Introduction

Welcome to Soft Shell! This language is designed as a stepping stone between block-based coding (like Scratch) and text-based coding (like Python). It uses simple keywords and strict indentation to help you learn good coding habits.

Key Rule: Blocks of code (inside loops or if-statements) must be indented using a period . or a tab.

Variables & Types

Use the var keyword to create variables. Soft Shell figures out if it's a number or text automatically.

# Creating variables
var name "Soft Shell"
var age 15
var isCool true

# Arrays (Lists)
var items [10, 20, 30]

String Interpolation

You can put variables directly inside strings using ${variable}.

write "Hello, my name is ${name} and I am ${age}."

Input & Output

Write (Print)

Prints text to the screen.

write "Hello World"

Read (Input)

Asks the user for input. Soft Shell tries to be smart: if the user types a number, it converts it to a number automatically.

read username "What is your name? "
read userAge "How old are you? "

if userAge > 18
.write "You are an adult, ${username}."

Math & Logic

Soft Shell supports standard math and logic operators.

var score 0
var lives 3

# Incrementing
score++
score += 10

# Logic check
if score > 100 && lives > 0
.write "You are winning!"

Control Flow

Remember to use the period . to indent your code blocks!

If / Else

if age >= 18
.write "You can drive."
else if age >= 16
.write "You can learn to drive."
else
.write "Too young."

Loops

You can use standard while loops or Python-style for loops.

# Standard Loop (While)
var x 0
loop x < 5
.write x
.x++

# For Loop (Range)
loop for i in range(0, 10)
.write "Counting: ${i}"

# For Loop (Array)
var inventory ["Sword", "Shield", "Potion"]
loop for item in inventory
.write "You have: ${item}"

Functions

Define reusable code blocks.

function add x y
.return x + y

# Calling the function
var result add(5, 10)
write result

Built-in Tools

Soft Shell comes with helper functions to make games and stories easier.

Wait

Pauses the program for a specific number of seconds.

write "Starting..."
wait 2
write "Done!"

Clear

Clears the console screen.

clear

Try / Fail (Error Handling)

Prevents the program from crashing if an error occurs.

try
.var result 10 / 0
fail
.write "Math error! Cannot divide by zero."

Python Power

Soft Shell is built on Python. You can use standard Python libraries using the use keyword, and even use Python functions directly.

use random
use math

var diceRoll random.randint(1, 6)
write "You rolled a ${diceRoll}"

var root math.sqrt(25)
write root