Skip to content
L.J. Lim edited this page May 19, 2016 · 3 revisions

Script basics

A script is made up of lists of actions and their args. E.g.

script = {
  prologue = {
    {"SetBackground", {image = "bg/bg1.png", animation = {type = "fadein", time = 0.5}}},
    {"PlayMusic", {track = "sound/music/2spooky4me.ogg", loop = true}},
    {"AddText", {speakerID = "Ada", textID = "prologue1", instant = false, pause = true}},
    {"AddSprite", {id = "sophia", image = "sprites/sophia2.png", position = {640, 0}, anchor = {800, 200}, animation = {}}
    {"JumpToScript", "prologue2"}
  },
  prologue2 = {
    {"AnimateSprite", {id = "sophia", animation = {x = 200, y = 0, time = 1, simultaneous = false}},
    {"PlaySound", {sound = "sound/sfx/shatter.wav"}},
    {"ShowChoices", 
      {
         {"killThem", function() Spring.Echo("foo") end},
         {"spareThem", function() Spring.Echo("bar") end},
      }
    },
    {"ShakeScreen", {time = 2, strength = 50}},
    -- ...
  }
},
local scriptID = "prologue"    -- for knowing which localization file to load, where to go during save/load, etc.

return scriptID, script

Every widget:Update(dt), the VN widget advances by dt seconds. If it is currently in an animation or writing text, it progresses accordingly. Else, it moves to the next item in the current script, unless the current action pauses at its end (e.g. text by default). Clicking will make it advance to the next part of the script.

Actions

AddText

Adds text. Pauses the VN afterwards, unless set not to.

AddSprite

Adds a sprite image with the specifiedID and image file, at the specified location, with the specified animation. Anchor should preferably be set in a definition file somewhere but can be overridden if necessary.

AddBackground

PlaySound

PlayMusic

Pause

Pauses the VN until the user clicks.

Wait

Waits for x seconds before progressing to the next item in the script.

###ShakeScreen

ShowChoices

Creates a window with two or more buttons; the user clicks one to make a decision.

Widget tables

Sprites

local sprites = {
  sophia = {id = "sophia", image = "bla", position = {}, wantedPosition = {}, speed = 10}
}

Every widget:Update(dt), the widget moves the sprites from their current position towards their wantedPosition by speed/dt. speed is assigned whenever the script calls an animation, based on the initial position, wantedPosition and animation time.

Misc. stuff

Text speed:

  • Slow: 1 character every 0.2 seconds.
  • Medium: 1 character every 0.1 seconds
  • Fast: instant