Values and conversions
Kinds of value
Section titled “Kinds of value”| Kind | Notes |
|---|---|
| empty | null, NULL, a variable nobody set |
| number | a 64-bit floating point number |
| string | a sequence of bytes |
| array | an ordered list of values |
| object | a reference to an engine or script object: an NPC, a player, a window, a request |
| function | an anonymous function |
Bornescript is almost untyped. A plain value behaves like a string that converts when an operation needs a number, so 1 == "1" is true.
true is the number 1, false is 0, null and NULL are empty, and pi is 3.141592653589793. Empty reads as "" where a string is needed and as 0 where a number is needed: temp.unset + 1 is 1.
An empty value does not stay empty once it is kept. Storing it in a variable, a field, or an array element, passing it as an argument, or returning it from a function makes it 0: after temp.a = null;, temp.a.type() is 0. A variable nobody set is still empty, and its .type() is -1. Flags (client., clientr., server., serverr.) are the exception: setting one to empty deletes it.
Number to string
Section titled “Number to string”When a number becomes text, the engine uses these rules:
- The size is limited to
2147483647, so3000000000and2 ^ 40print2147483647. - The whole part is written, then up to 9 digits of fraction, cut off, not rounded.
- Trailing zeros and a trailing
.are removed. - A value of
0.0001or less in size prints0. A value that is not a number prints0.
function onCreated() { echo(10 / 3); // expect: 3.333333333 echo(2 / 3); // expect: 0.666666666 echo(0.1 + 0.2); // expect: 0.3 echo(3.0); // expect: 3 echo(3000000000); // expect: 2147483647}Run this example in the playground
The carry rule for fractions that end in many nines is provisional (OQ-LANG-10).
String to number
Section titled “String to number”A string becomes a number the way the C function strtod reads it:
- The empty string is
0. - Leading white space and one sign are skipped. Then the longest valid number at the start is read: decimal digits with an optional fraction and exponent,
0xand hex digits,inf, ornan. - A non-empty string with no number at the start is
-1.
function onCreated() { echo("42abc" + 0); // expect: 42 echo("1e2" + 0); // expect: 100 echo("0x10" + 0); // expect: 16 echo("abc" + 1); // expect: 0 echo("abc" * 2); // expect: -2}Run this example in the playground
An array becomes 0. An object or a function becomes 0 too (OQ-LANG-11).
Lists in strings
Section titled “Lists in strings”Text with commas behaves as a list wherever an array is expected: indexing, for (x : list), in, .size(), and the array methods.
A string is a list when it has a comma outside quotes and no unquoted space. Elements may be quoted with ", and "" inside quotes is one quote.
function onCreated() { temp.s = "a,b,c,d"; echo(temp.s.size()); // expect: 4 echo(temp.s[1]); // expect: b echo("a b,c".size()); // expect: 0 echo("\"two words\",x"[0]); // expect: two words}Run this example in the playground
| String | Result |
|---|---|
"a,,b" |
3 elements, the second is empty |
"a,b," |
2 elements (one trailing comma is dropped) |
"a," |
one element |
"a", "abc", "" |
not a list: .size() is 0 and [0] is the whole text |
"a b,c", " a , b " |
not a list (an unquoted space) |
A string that is not a list used as an array has size 0, [0] is the whole string, and a for over it runs zero times. Some edge cases are provisional (OQ-LANG-12).
Array to string
Section titled “Array to string”An array becomes text by joining its elements with commas. An element that holds a space, a comma, or a quote is wrapped in quotes, with each quote doubled. An array with one element gets a trailing comma.
function onCreated() { temp.a = {"a b", "c,d", "e"}; echo("" @ temp.a); // expect: "a b","c,d",e temp.one = {"x"}; echo("" @ temp.one); // expect: x,}Run this example in the playground
Object to string
Section titled “Object to string”An object becomes its name if it has one. Otherwise it becomes a name made by the engine (OQ-LANG-13). A function value becomes a name like function_541223_1.
The origin tag (extension)
Section titled “The origin tag (extension)”A number or a string also remembers where it came from: number for literals and arithmetic, string for text, chat, file lines, web responses, and SQL text. The tag does not change how operators behave. It matters for typeof and for the strict comparison ===, and it survives being stored in an array, a flag, or a message to another computer.
Engine version 0.1.0. Built 2026-11-18.