冒险岛脚本编写基础教程二
本帖最后由 q964391128 于 2021-4-29 18:28 编辑第二课: Types of NPCs
NPC 主要有两种:需要 status 的,以及不需要 status 的。
最简单的区分方法 就是...显然地... status 。
编写 NPC 时,时时刻刻扪心自问:我的 NPC 会 需要两个以上的对话窗吗?如果答案为是,那你绝大多数时候会需要用到 status ;
若答案为非,那 status 可能用不太到。请见以下范例: 不须 status 的 NPC
function start() {
cm.sendOk("我是一个没有 status 的 NPC。");
cm.dispose();
}
另一个不须 status 的 NPC
function start() {
cm.sendOk("这是另一个没有 status 的 NPC。");
}
function action(mode, type, selection) {
cm.warp(100000000, 0);
cm.gainItem(4001126, 1);
cm.sendOk("看到了吗?我不用 status 就能把你传送走并给你道具。");
cm.dispose();
}
须要 status 的 NPC
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
cm.sendNext("请按下一步,我才能继续下一个 status。");
} else if (status == 1) {
cm.sendSimple("你看到我如何操作 status 了吗?\r\n #L0# 是 #l \r\n
#L1# 否 #l");
} else if (status == 2) {
if (selection == 0) {
cm.sendOk("我在这!这是另一个 status。如你在脚本中看到的,这个对
话窗是在 status 2。");
cm.dispose();
} else if (selection == 1) {
cm.sendOk("好吧,这个对话窗也是在 status 2 :)");
cm.dispose();
}
}
}
{:3_59:} 赞赞赞赞赞 看不懂 你这 一 二 对小白一点用没有
页:
[1]