-
Notifications
You must be signed in to change notification settings - Fork 4
Scripting
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)
endsetGameVar("varName", "varValue")
local test = getGameVar("varName")setEventVar("varName", "varValue")
local test = getEventVar("varName")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"})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()
endLet 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)Like show text, but scrolling instead of message box
- mapId (Int)
- x (Int)
- y (Int)
- options (Table)
- facing (String)
"up""down""left""right"-
"retain"(default)
- fading (String)
-
"normal"(default) "none"
-
- facing (String)
movement.teleportPlayer(2, 20, 20, {facing="up"})| Parameter | Type | Descriptions |
|---|---|---|
| duration | Int | time in ms |
screen.fadeOut(200)| Parameter | Type | Descriptions |
|---|---|---|
| duration | Int | time in ms |
screen.fadeIn(200)| 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)| 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)music.pause()music.resume()| 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})| 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})- 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})prints to console for debug
log("some message")sleeps the script for some time
sleep(500) -- sleep for 500ms