Skip to content
Kevin Leung edited this page Sep 1, 2015 · 1 revision

[[TOC]]

Lua, have a working Haxe binding

Event Script Example:

-- 0001-0001-intro-autorun.lua
if getGameVar("talkedToHarrison") then
  message.showText("someone", "some text")
  message.showChoices({options...})
  movement.teleportPlayer(3, 10, 10)
end

Variables

Game (Global) Variables

setGameVar("varName", "varValue")
local test = getGameVar("varName")

Event (Local) Variables

setEventVar("varName", "varValue")
local test = getEventVar("varName")

Functions

Message


Show Text

Show text in a message box

Parameter Type Descriptions
characterId String
message String supports inline Message Codes
options Table (see option table below)
Option Type Accepted Values
position String "top"/ "center"/ "bottom" (default)
background String "normal" (default) / "dimmed"/ "transparent"
-- Examples
message.showText("mainchar", "my message", {position="bottom", background="normal"})

Show Choices

Let player choose one option from list

Parameter Type Descriptions
prompt String supports inline Message Codes
choices Table (see table below)
options Table (refer to showText)
Choice Field Type Accepted Values
text String supports inline Message Codes
disabled Bool default is false if not specified
hidden Bool default is false if not specified

Returns the selection index (1-based)

local selection = message.showChoices("Please choose one from below",
{
  {
    text = "Choice 1", 
    diabled = false, 
    hidden = false
  },
  {
    text = "Choice 2"
  },
  {
    text = "Choice 3"
  }
})

if selection == 1 then doSomething()
elseif selection == 2 then doSomethingElse()
elseif selection == 3 then doSomethingAwesome()
end

Input Number

Let players input a N digit number using arrow keys

Parameter Type Descriptions
prompt String supports inline Message Codes
numDigit Int number of digits of the input

Returns the number input by player

local myNumber = message.inputNumber("Please input a 4-digit number", 4)

Show Scrolling Text

Like show text, but scrolling instead of message box

Actor


Change HP

Party


Change Items

Change Party Member


Movement

Teleport Player

  • mapId (Int)
  • x (Int)
  • y (Int)
  • options (Table)
    • facing (String)
      • "up"
      • "down"
      • "left"
      • "right"
      • "retain" (default)
    • fading (String)
      • "normal" (default)
      • "none"
movement.teleportPlayer(2, 20, 20, {facing="up"})

Set Event Location

Scroll Map

Set Move Route

Screen


Fadeout Screen

Parameter Type Descriptions
duration Int time in ms
screen.fadeOut(200)

Fadein Screen

Parameter Type Descriptions
duration Int time in ms
screen.fadeIn(200)

Tint screen (change colour filter

Flash screen

Shake screen

Audio


Play Sound

Parameter Type Descriptions
id Int sound file id
volume Float volume from 0 to 1
pitch Float pitch (with 1 means normal pitch)
sound.play(1, 1, 1)

Play Background Music

Parameter Type Descriptions
id Int sound file id
volume Float volume from 0 to 1
pitch Float pitch (with 1 means normal pitch)
music.play(1, 1, 1)

Pause Background Music

music.pause()

Resume Background Music

music.resume()

Fade Out Background Music

Parameter Type Descriptions
duration Int time in ms
options Table (see option table below)
Option Type Descriptions
wait Bool if true, the script will wait until the fade ends
music.fadeOut(200, {wait=true})

Fade In Background Music

Parameter Type Descriptions
duration Int time in ms
options Table (see option table below)
Option Type Descriptions
wait Bool if true, the script will wait until the fade ends
music.fadeIn(200, {wait=true})

Picture


Show Picture

  • imageSource (String)
  • x (Int)
  • y (Int)
  • cliprect (2 formats: rectangle or indexed frame)
  • options (Table)
picture.show("pic.png", 15, 15, {x=0, y=0, w=20, h=20}, {scale=0.5})
picture.show("pic.png", 15, 15, {w=20, h=20, index=5}, {alpha=0.5, fixed=true})

Move Picture

Rotate Picture

Tint Picture

Erase Picture

Set Weather Effects (rain, storm, snow, etc)

Utils


Log

prints to console for debug

log("some message")

Sleep

sleeps the script for some time

sleep(500) -- sleep for 500ms