2015-12-13 02:51:32 +09:00
|
|
|
/* ================================================= *\
|
|
|
|
* talk.sun
|
|
|
|
*
|
|
|
|
* ssc standard include utility
|
2016-01-30 07:07:55 +09:00
|
|
|
* 2015-2016 arookas
|
2015-12-13 02:51:32 +09:00
|
|
|
\* ================================================= */
|
|
|
|
|
|
|
|
// ================================================= \\
|
|
|
|
// TALK
|
|
|
|
// ================================================= \\
|
|
|
|
|
|
|
|
// flags
|
2016-02-23 11:05:02 +09:00
|
|
|
var const TALKF_WAIT = 0;
|
|
|
|
var const TALKF_CLOSE = (1 << 0);
|
2015-12-13 02:51:32 +09:00
|
|
|
|
|
|
|
// builtins
|
|
|
|
builtin getTalkMode();
|
|
|
|
builtin isTalkModeNow();
|
2016-01-30 07:08:55 +09:00
|
|
|
|
|
|
|
builtin setTalkMsgID(msgID, flags);
|
|
|
|
|
2015-12-13 02:51:32 +09:00
|
|
|
builtin getTalkNPC();
|
|
|
|
builtin getTalkNPCName();
|
|
|
|
|
2016-02-20 04:14:50 +09:00
|
|
|
builtin setValue2TalkVariable(variable, value); // stub
|
|
|
|
|
2015-12-13 02:51:32 +09:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
2015-12-13 23:22:42 +09:00
|
|
|
else {
|
2015-12-13 02:51:32 +09:00
|
|
|
yield;
|
2016-02-23 11:42:49 +09:00
|
|
|
while (!getTalkMode()) {
|
2015-12-13 23:22:42 +09:00
|
|
|
yield;
|
|
|
|
}
|
2015-12-13 02:51:32 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:05:02 +09:00
|
|
|
function talkAndWait(msgID) { talk(msgID, TALKF_WAIT); }
|
|
|
|
function talkAndClose(msgID) { talk(msgID, TALKF_CLOSE); }
|
2015-12-13 02:51:32 +09:00
|
|
|
|
|
|
|
// ================================================= \\
|
|
|
|
// SELECT
|
|
|
|
// ================================================= \\
|
|
|
|
|
|
|
|
// builtins
|
|
|
|
builtin getTalkSelectedValue();
|
|
|
|
|
|
|
|
// functions
|
|
|
|
function select(msgID, flags) {
|
|
|
|
setTalkMsgID(msgID, flags);
|
|
|
|
if (flags & TALKF_CLOSE) {
|
|
|
|
while (isTalkModeNow()) {
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2016-02-23 11:42:49 +09:00
|
|
|
do {
|
2015-12-13 02:51:32 +09:00
|
|
|
yield;
|
2016-02-23 11:42:49 +09:00
|
|
|
} while (!getTalkMode());
|
2015-12-13 02:51:32 +09:00
|
|
|
}
|
|
|
|
return getTalkSelectedValue();
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:05:02 +09:00
|
|
|
function talkAndSelect(msgID) { return select(msgID, TALKF_WAIT); }
|
|
|
|
function talkAndSelectClose(msgID) { return select(msgID, TALKF_CLOSE); }
|
2015-12-13 02:51:32 +09:00
|
|
|
|
|
|
|
// ================================================= \\
|
|
|
|
// FORCE
|
|
|
|
// ================================================= \\
|
|
|
|
|
|
|
|
// builtins
|
|
|
|
builtin __forceStartTalk(handle);
|
|
|
|
builtin __forceStartTalkExceptNpc(handle);
|
2016-01-30 07:10:48 +09:00
|
|
|
builtin forceCloseTalk();
|
2015-12-13 02:51:32 +09:00
|
|
|
|
|
|
|
// functions
|
|
|
|
function forceTalk(handle) {
|
2016-02-23 11:42:49 +09:00
|
|
|
var result = __forceStartTalk(handle);
|
|
|
|
if (result) {
|
2015-12-13 02:51:32 +09:00
|
|
|
while (!isTalkModeNow()) {
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
2016-02-23 11:42:49 +09:00
|
|
|
return result;
|
2015-12-13 02:51:32 +09:00
|
|
|
}
|
|
|
|
function forceTalkExceptNpc(handle) {
|
2016-02-23 11:42:49 +09:00
|
|
|
var result = __forceStartTalkExceptNpc(handle);
|
|
|
|
if (result) {
|
2015-12-13 02:51:32 +09:00
|
|
|
while (!isTalkModeNow()) {
|
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
2016-02-23 11:42:49 +09:00
|
|
|
return result;
|
2015-12-13 02:51:32 +09:00
|
|
|
}
|