Language

Doll Script

Worn assets run Doll Script. The language is MAGIC: functions, classes, and modules, compiled to JavaScript. Doll runs that JavaScript.

Names

A doll has a name. Mira is mira. The witch is witch. The tiefling is tiefling. The singer is singer. The same pattern names the rest of the company: reaper, mandy, kimmel, miller, billy, elon, desi, trump.

A dot reaches what she wears. The doll and the asset are the same kind of thing. Each one has properties, functions, and events.

  • mira.speaking is a property.
  • mira.say("hello") is a function.
  • mira.always is an event.
  • mira.coffee.pos places the cup.
  • mira.coffee.hold_target is a number that lives on the cup.
  • mira.coffee.hold() is one of the cup's functions.

A few of the worn names: mira.coffee, witch.hat, witch.wand, witch.book, tiefling.horns, tiefling.ears, tiefling.tail, reaper.scythe, mandy.flower, miller.fangs, desi.mic, singer.guitar.

The cup

That file is assets/coffee/script.magic. hold is the cup's own function, so the host names come in by import. @doll brings every host name when you are not using one of them for yourself. A function in the doll's own file lands on her. hello() in assets/mira/script.magic is mira.hello.

import ik, curl, emit, closeJaw, tilt, speaking from "doll"

fn hold()
  ik("right", "mChest", "mHead", "hold", "sip")
  curl("right")
end

fn steam()
  emit()
end

fn sip()
  closeJaw("sip_jaw")
  tilt("mHead", "sip_nod")
end

let holds = "right"

fn always()
  mira.coffee.hold()
  mira.coffee.steam()
  if speaking() then
    mira.coffee.sip()
  end
end

The numbers stay on mira.coffee. The file is the performance.

Events

Write fn chapterEnd in the file that owns the event. That function is the object's handler, and it runs first. + chapterEnd(chapter) listens after it. - chapterEnd removes the listeners this script added. It leaves fn chapterEnd in place. -n + 1 stays arithmetic. raise("tick", 4) sends that name and one value. Listeners run in the order they were added.

EventWhen it runs
initOnce, when that script loads.
startPlay or export begins.
stopPlay or export ends.
destroyThe script is replaced.
chapterStartA chapter opens. The argument is that chapter.
chapterEndThat chapter closes. The argument is the chapter that closed.
alwaysEvery pose. The doll first, then each worn asset. The cup sips here, while the line is hers.
poseWith always.
timerAfter setTimer(seconds).
attachWhen it is worn.
touchWhen it is touched.
listenWhen someone speaks. The argument is who, text, and how. how is say, whisper, or shout.

The chapter argument is title, start, end, speaker, time, and speaking. chapterStart receives the chapter that opened. chapterEnd receives the chapter that closed. On a prop, phase is 0 at rest and 1 at the middle of its performance. On the doll, phase is how far the chapter has gone, from 0 to 1. chapter is the title on the clock.

The language

Doll Script is MAGIC. A class has fields and functions. An interface names functions and has no fields. class Child is Cup does Named has one parent. interface Tagged is Named includes the parent interface. type of an instance is the class name. The interface is not a value.

interface Named
  fn label() as string
end

class Cup does Named
  fn label() as string
    return "coffee"
  end
end

try needs catch, finally, or both. finally runs before return, break, and continue leave. A throw with only finally runs that cleanup, and then the error leaves. throw "broke" and throw error("broke") are the same kind of error.

try
  risky()
catch err
  print err.message
finally
  print "done"
end

On the page

Square brackets mark the page, the way a link does. A paragraph with no name is Mira's, so an older page still plays. Mira: at the start of a line still names her.

[@Mira] The cup is warm.

[@Witch] The wand is awake. [!spark]

[@Trump!trump.rant] The suit is the avatar.

[!sip](mira.coffee.sip())
MarkWhat it does
[@Witch]Selects that speaker for the words that follow.
[@Mira :)]A smile can sit in the bracket. :smile: does the same.
[&shanty @Singer]Turns singing on. Shanty is the type. Singer is the mouth.
[&shanty]Sets the type and leaves the mouth.
[@Singer]Selects who sings.
[end]Closes the song.
[!sip]Runs the function sip.
[@Trump!trump.rant]Runs that script on Trump, even when another mouth is talking. ! names the script, so the cue is trump.rant.
[!mira.coffee.hold]Runs that function.
[!hold](mira.coffee.hold())Runs the script after the bracket.
[! mira.coffee.sip() ]The call can sit inside the brackets.

Singing stays on through later paragraphs until [end], or until a different narrator is selected, so the mark is not repeated on every verse. The words from the on mark to [end] are one song. The types are ballad, shanty, waltz, march, and dirge.

A fence is three backticks. Doll shows that listing on the terminal, in the same colors, while the chapter is on the clock. MAGIC inside the fence is highlighted and checked.

The spoken text leaves the marks off, and it leaves the markdown marks off too. A call with no words of its own rides on the nearest spoken line. LOL and LMAO are a laugh. IMHO is “in my humble opinion”. The voice says the words. It does not spell the letters.

The project starts as main.md and main.ms. A short call can sit on the page. Longer functions live in main.ms. Typing @ then ! completes the names.

While she sings

singing() is true on a sung line. tune() is ballad, shanty, waltz, march, or dirge. bpm() is the tempo. beat() counts from the start of the chapter. pulse() is 1 on the strum and falls to 0 across the beat. It is 0 when nobody is singing.

The guitar is singer.guitar. It hangs on the chest. The left hand frets. The right hand stays on the body. hands() puts both hands there.

@doll
import pulse, tune, setRot, setPos, hands from "doll"

fn strum()
  let hit = pulse()
  let kind = tune()
  let amp = 0.12
  if kind == "shanty" then
    amp = 0.18
  elseif kind == "waltz" then
    amp = 0.15
  elseif kind == "march" then
    amp = 0.10
  elseif kind == "dirge" then
    amp = 0.08
  end
  let sway = hit * amp
  setRot(-1.4208, sway, 0.55 + sway * 0.2)
  setPos(0.08, -0.02, -0.10 - hit * 0.006)
  hands()
end

let holds = "both"

fn always()
  strum()
end

Beside LSL

The short names act on the object whose event is running. These are the calls a worn asset actually makes. Land, money, teleport, experiences, and vehicles are not in this room.

LSLDoll
llGetPos llSetPospos setPos
llGetRot llSetRotrot setRot. Euler radians.
llGetScale llSetScalescale setScale
llGetOwnerowner. Here that is mira.
llGetKeykey
llGetTimeclock
llSay llWhisper llShoutsay whisper shout. listen hears them.
llSetTimerEventsetTimer
llParticleSystememit
llAbs llFloor llCeil llRoundabs floor ceil round
llSqrt llPow llLog llLog10sqrt pow log log10
llSin llCos llTansin cos tan
llAsin llAcos llAtan2asin acos atan2
llFrandfrand
llVecMag llVecNorm llVecDistmag norm dist
llToUpper llToLower llStringTrimupper lower trim
llSubStringIndex llGetSubStringfind slice. Indexes start at 0. slice stops before end.

min, max, mod, dot, cross, lerp, and clamp are the small arithmetic. mod(a, 0) is 0. == stays exact. same compares lists and {x, y, z} records by value. replace swaps one piece of text for another. split breaks text into a list. Aiming the hand is ik, curl, tilt, and closeJaw. A tail wags with sway. prop("hold_target") still reads a number. So does mira.coffee.hold_target.

speaker() is the chapter speaker, lowercased. live() is the line being spoken. offer("witch") points a worn mic at another doll. wearer() is the doll who owns the asset whose script is running. owner() is the page doll.

Picture

@2d and @3d are MAGIC's picture modules. In Doll they draw into the room. A 3D sprite or box uses that module's axes: X to the right, Y up, Z toward you. Doll maps those onto the scene, where Z is up and the face looks down +X.

setCamera moves the view, from @3d or from @doll. camera reads it back. A 2D sprite sits on the picture. sprite, box, motion, update, and onCollision keep their names.

Terminal keeps a cell grid. place(x, y, z) sits that grid in an Apple II on the stage, and the glass colors the MAGIC. @games, @sound, and @hex are here too.

@3d as world

let scene = new world.Engine()
scene.sprite("✦", 0.15, 1.3, -0.2, 0.12)
scene.box(0.2, 0.9, -0.4, 0.15, 0.15, 0.15, "#d4552a")

fn always()
  scene.update()
end

tv, news, terminal, dragon, frog, cat, dog, bird, aquarium, and plant are the script names. prop("tv-2") reaches a second one. The fish swim. tv.text and tv.image set the screen. The image is a WebP. news.text is the line on the glass. terminal.text is the listing. dragon.stance is fly or ground. Ground folds the wings. Fly lifts him and spreads them.

Contribute

Buy me a coffee

The language page is free to read. The coffee button is Contribute.

☕ Buy me a coffee