Kobalt Programming Language v1.1.3

Official Technical Specification (Stable Release)

Kobalt is a lightweight, imperative scripting language designed for text-based game engines and logic prototyping. Version 1.1.3 introduces major core improvements including PEMDAS math support and complex data nesting.

Download Kobalt v1.1.3 Suite (.zip)

1. Core Principles

Kobalt follows a specific set of rules that distinguish it from other languages:

2. Variables (var)

Use the var keyword to initialize a variable. Variables in Kobalt can hold Numbers, Strings, Lists, or Dictionaries.

var player.hp = 100
var player.name = "Abdul"
var is_active = 1 # 1 represents true, 0 represents false

3. Mathematics and Operators (set)

The set command is used to modify existing variables or perform calculations.

UPDATE v1.1.3: Kobalt now supports standard Order of Operations (PEMDAS). Multiplication and Division are prioritized over Addition and Subtraction.
set x = 10 + 5 * 2   # Result: 20 (Standard Math)
set y = 100 % 3      # Modulo operator (Result: 1)
set name = "Mr. " + player.name # String concatenation

4. Logic and Boolean Algebra

Kobalt supports compound conditions using and and or operators.

if hp > 0 and stamina > 0
    print "You can still fight!"
elif has_potion == 1 or is_god_mode == 1
    print "You survive."
else
    print "Game Over."
end

5. Advanced Data Structures

Lists (Arrays) & Mutation

Ordered collections accessed by a numerical index (starting at 0). Version 1.1.3 adds direct mutation support.

list inventory
push inventory "Sword"
push inventory "Shield"

set_at 0 inventory "Laser Sword" # Direct modification at index 0

var item = ""
at 0 inventory item # item becomes "Laser Sword"

Dictionaries (HashMaps)

Collections of Key-Value pairs. Keys must be Strings. Values can now be Lists.

dict weapon_stats
dict_set weapon_stats "Sword" 50
dict_get damage weapon_stats "Sword" # damage becomes 50

6. Loops (while / foreach)

Iterate through code blocks based on conditions or collection items.

foreach i in inventory
    set msg = "- " + i
    print msg
end

7. String Processing Suite

CommandUsageDescription
to_lowerto_lower [res] [src]Converts text to lowercase.
to_upperto_upper [res] [src]Converts text to uppercase.
splitsplit [list] [src] [sep]Splits a string into a List by separator.
replacereplace [res] [src] [A] [B]Replaces string A with string B.
containscontains [res] [src] [part]Returns 1 if part exists in src, else 0.

8. Functions and Return Values

Functions now support returning values directly to variables using the set ... call syntax.

def calculate_atk base bonus
    var total = base + bonus
    return total
end

var my_dmg = 0
set my_dmg = call calculate_atk 10 5 # my_dmg becomes 15

9. Persistent File Storage (I/O)

write_file "save.txt" player.hp    # Overwrites file
append_file "log.txt" "New Action" # Adds new line

list data
read_file data "save.txt"          # Reads entire file into a list

10. Safety and Exception Handling

try
    to_num value user_input
    set res = 100 / value
catch
    print "Error: Calculation Failed."
end

11. Full Command Index

CommandArgumentsPurpose
set_at[index] [list] [val]New: Modifies a list item at specific index.
print[value]Outputs data to terminal.
input[variable]Receives line of text from user.
random[var] [min] [max]Generates a random integer.
import"filename.kbl"Executes an external Kobalt script.
file_exists[res] [name]Returns 1 if file exists.
return[value]Exits function and optionally returns a value.

© 2026 Kobalt Interpreter Project. All Rights Reserved.