Syntax that reads
the way it thinks.

This guide covers the core syntax in Z# . Every statement ends with :, blocks use ( ), and argument lists use [ ].

01

Hello world

A script contains one or more rooms. A Start[] function runs automatically unless it has [DR].

zsharp = type.script

noticed room Test[] (
 noticed text HelloWorld = "Hello World":

 noticed brain Start[] (
  Print(HelloWorld):
 )
)
02

Words with a job

Z# uses descriptive keywords while keeping familiar behavior from C#, Java, and C.

noticedpublic

Visible from anywhere allowed by imports

silentprivate

Limited to its containing or parent room

roomclass

Groups variables and functions

brainvoid

A function with no fixed return type

numbernumber

A signed whole or decimal value

textstring

Text inside double quotes

statusboolean

alive or dead

hordestatic

Belongs to the room rather than an object

feedreturn

Ends a function and optionally supplies a value

noticed number Score = 10:
noticed text Name = "Zombie":
noticed status Alive = alive:
noticed text() Names = ["Alex", "Sam", "Robin"]:

number.set:Score = Score + 5:
text.set.Name = Name + "!":
03

Functions and calls

Use feed for a returned value. Fully qualified calls follow Project:File:Room:Function, with unneeded location parts left out.

noticed number Add[number Left, number Right] (
 feed(number.Left + number.Right):
)

noticed brain Start[] (
 number Result = Function.call(Math:Calculator:Add [4, 6]):
 Print(Result):
)
04

Conditions and loops

Conditions support and and or. A loop continues until loop.end:; continue: starts its next pass. wait and delay accept milliseconds or seconds.

if[Alive and Health > 0] (
 Print("Still going"):
) else (
 Print("Game over"):
)

loop (
 wait(1s):
 if[Health == 0] (loop.end:)
)
05

Imports and access

Imports live inside a room and expose an entire file. Wildcards work at any import level. Code in another project, file, or room follows the same outside-to-inside order.

import Project.Folder.File():
import ZSharp.Window.*():
import another_project.*():

Print(Room.Score):
Print(File.Room.Score):
Print(Project.File.Room.Score):
06

Objects and arrays

Array types add () after the value type. Objects are created with new, and their fields and functions use dot access.

noticed text() Names = ["Alex", "Sam", "Robin"]:
Print(Names[1]):

noticed Player User = new Player["Zombie"]:
User.Move[10, 20]:
Print(User.Name):
Location stays predictable. Use User.Move in the same room, Room.User.Move from another room, then add the file and project names only when crossing those boundaries.
07

Native windows

A window file contains one window. Measurements without a suffix use zu, which follows display scale; use px for literal pixels. Positive X moves right and positive Y moves up.

zsharp = type.script:window

noticed Window Startup[] (
 import ZSharp.Window.*():

 noticed design Design[] (
  title: "My Z# App":
  icon: "assets/images/icon.png":
  scalable: alive:
  background: linear-gradient(90:#E52C3A:#5D0C38):
 )

 noticed button Launch[] (
  text: "Launch":
  width: 34zu:
  height: 12zu:
  Click[left: [Scripts:Actions:Launch]: right: []:]:
 )
)
Responsive by default. Width changes scale images, buttons, and inputs; text wraps. Height changes reveal a vertical scroll area instead of shrinking the layout.
08

Live UI changes

Scripts can change window properties while an app is running. Gradients accept any number of colors, and wait or delay can pace an animation.

Startup.Design.background.set: linear-gradient(90:#FF0000:#00FF00:#0000FF):
wait(1s):
Startup.Design.background.set: radial-gradient(180:#121212:#73001F):
Startup.AppTitle.content.set: "Ready":
Loops run independently. A repeating animation does not have to freeze the window or prevent button events and other automatic Start[] functions from running.
09

Project settings

Every project is described by project.zsettings. It sets the project identity and version, selects the Z# release, declares dependencies, and chooses the startup window for an app.

zsharp = type.settings

Project: "My Z# App":
PID: "my_zsharp_app":
Version: [1.0.0.0]:
Authors: ["Your Name"]:
Description: "Built with Z#":
ZSharp: []:

Dependencies (
 zsharpwindow:1.0.0.0
):

Window (
 Startup: "Windows/Startup.zsharp":
 Uninstall: "Windows/Uninstall.zsharp":
):
10

Build an app

Register the project, package it, and run the resulting .zapp. Packages are created inside the project's Packages folder.

zsharp project "path/to/project.zsettings"
zsharp package app "path/to/project" MyApp
zsharp run "path/to/project/Packages/MyApp.zapp"
Need the source too? Add --unbytecode to create both the normal bytecoded app and an unbytecoded package containing the original source.
11

Compiler feedback

The compiler reports misspelled keywords, missing statement terminators, unclosed rooms or functions, invalid values, and references that were not imported. Messages include the source file and line so the problem can be fixed before packaging.

Scripts/Player.zsharp:14:3: expected ':' after the statement
Windows/Startup.zsharp:8:2: File.Room was used without an import
Language generations. When a future generation replaces old syntax, the compiler can identify the old generation and show the recommended replacement.