Added some stdlib scripts.
This commit is contained in:
parent
7bdcb485b3
commit
3d2f1fe230
4 changed files with 156 additions and 0 deletions
15
stdlib/common.sun
Normal file
15
stdlib/common.sun
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* ================================================= *\
|
||||
* common.sun
|
||||
*
|
||||
* ssc standard include utility
|
||||
* 2015 arookas
|
||||
\* ================================================= */
|
||||
|
||||
// return values for typeof(x)
|
||||
const TYPE_INT = 0;
|
||||
const TYPE_FLOAT = 1;
|
||||
const TYPE_STRING = 2;
|
||||
|
||||
import "system.sun";
|
||||
import "talk.sun";
|
||||
import "sound.sun";
|
12
stdlib/sound.sun
Normal file
12
stdlib/sound.sun
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* ================================================= *\
|
||||
* sound.sun
|
||||
*
|
||||
* ssc standard include utility
|
||||
* 2015 arookas
|
||||
\* ================================================= */
|
||||
|
||||
// builtins
|
||||
builtin startBGM(num);
|
||||
builtin stopBGM(num);
|
||||
|
||||
builtin startSE(num);
|
14
stdlib/system.sun
Normal file
14
stdlib/system.sun
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* ================================================= *\
|
||||
* system.sun
|
||||
*
|
||||
* ssc standard include utility
|
||||
* 2015 arookas
|
||||
\* ================================================= */
|
||||
|
||||
// builtins
|
||||
builtin getSystemFlag(flag);
|
||||
builtin setSystemFlag(flag, value);
|
||||
|
||||
// functions
|
||||
function setOnSystemFlag(flag) { setSystemFlag(flag, true); }
|
||||
function setOffSystemFlag(flag) { setSystemFlag(flag, false); }
|
115
stdlib/talk.sun
Normal file
115
stdlib/talk.sun
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* ================================================= *\
|
||||
* talk.sun
|
||||
*
|
||||
* ssc standard include utility
|
||||
* 2015 arookas
|
||||
\* ================================================= */
|
||||
|
||||
// ================================================= \\
|
||||
// TALK
|
||||
// ================================================= \\
|
||||
|
||||
// flags
|
||||
const TALKF_WAIT = 0;
|
||||
const TALKF_CLOSE = (1 << 0);
|
||||
|
||||
// builtins
|
||||
builtin getTalkMode();
|
||||
builtin isTalkModeNow();
|
||||
builtin getTalkNPC();
|
||||
builtin getTalkNPCName();
|
||||
builtin setTalkMsgID(msgID, flags);
|
||||
|
||||
// functions
|
||||
function waitTalkStart(name) {
|
||||
while (true) {
|
||||
if (isTalkModeNow()) {
|
||||
if (getTalkNPCName() == name) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
yield;
|
||||
}
|
||||
}
|
||||
function waitTalkStartHandle(handle) {
|
||||
while (true) {
|
||||
if (isTalkModeNow()) {
|
||||
if (getTalkNPC() == handle) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
yield;
|
||||
}
|
||||
}
|
||||
|
||||
// sets message (blocking)
|
||||
function talk(msgID, flags) {
|
||||
setTalkMsgID(msgID, flags);
|
||||
if (flags & TALKF_CLOSE) {
|
||||
while (isTalkModeNow()) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
yield;
|
||||
while (getTalkMode() != true) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
|
||||
function talkAndWait(msgID) { talk(msgID, TALKF_WAIT); }
|
||||
function talkAndClose(msgID) { talk(msgID, TALKF_CLOSE); }
|
||||
|
||||
// ================================================= \\
|
||||
// SELECT
|
||||
// ================================================= \\
|
||||
|
||||
// builtins
|
||||
builtin getTalkSelectedValue();
|
||||
|
||||
// functions
|
||||
function select(msgID, flags) {
|
||||
setTalkMsgID(msgID, flags);
|
||||
if (flags & TALKF_CLOSE) {
|
||||
while (isTalkModeNow()) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
else {
|
||||
yield;
|
||||
while (getTalkMode() != true) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
return getTalkSelectedValue();
|
||||
}
|
||||
|
||||
function talkAndSelect(msgID) { select(msgID, TALKF_WAIT); }
|
||||
function talkAndSelectClose(msgID) { select(msgID, TALKF_CLOSE); }
|
||||
|
||||
// ================================================= \\
|
||||
// FORCE
|
||||
// ================================================= \\
|
||||
|
||||
// builtins
|
||||
builtin __forceStartTalk(handle);
|
||||
builtin __forceStartTalkExceptNpc(handle);
|
||||
|
||||
// functions
|
||||
function forceTalk(handle) {
|
||||
var res = __forceStartTalk(handle);
|
||||
if (res == true) {
|
||||
while (!isTalkModeNow()) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function forceTalkExceptNpc(handle) {
|
||||
var res = __forceStartTalkExceptNpc(handle);
|
||||
if (res == true) {
|
||||
while (!isTalkModeNow()) {
|
||||
yield;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
Loading…
Reference in a new issue