赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 4676 |
最后登录 | 2017-8-6 |
在线时间 | 68 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 68 小时
- 注册时间
- 2014-7-8
- 帖子
- 50
|
3楼
楼主 |
发表于 2016-3-15 06:34:34
|
只看该作者
andrewx 发表于 2016-3-15 02:05
保存为js插件并打开。在事件里执行插件指令,输入你的插件指令名。
谢谢!我还想请教一下,怎么样才能像编译器一样定位到发生错误的具体代码行数?
比如游戏报错出Type Error : Cannot read property '0' of undefined
完全不懂错哪了。。- var foobar20160315 = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function (command, args)
- {
- foobar20160315.call(this, command, args);
- if (command.toUpperCase() === 'CALLMYFUNC')
- {
- var arr = new Array();
- for (var i = 0; i < 100; i++)
- {
- arr[i] = new Array();
- for (var j = 0; j < 100; j++)
- {
- arr[i][j] = "";
- }
- }
- var dir = new Array();
- for (var i = 0; i < 8; i++)
- {
- dir[i] = new Array();
- for (var j = 0; j < 2; j++)
- {
- dir[i][j] = "";
- }
- }
- var Width = $gameVariables.value(1);
- var Height = $gameVariables.value(2);
- dir = [[0, 1], [1, 0], [-1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]];
- for (var i = 0; i < Width; i++)
- {
- for (var j = 0; j < Height; j++)
- {
- var sumA = 0;
- var sumB = 0;
- for (var k = 0; k < 8; k++)
- {
- var tX = i + dir[i][0];
- var tY = j + dir[i][1];
- if (tX >= 0 && tX < Width && tY >= 0 && tY < Height)
- {
- var e = $gameMap.eventIdXy(i, j);
- var m = $gameMap.mapId();
- if ($gameSelfSwitches.value([m, e, 'A']))
- {
- sumA++;
- }
- else if ($gameSelfSwitches.value([m, e, 'B']))
- {
- sumB++;
- }
- }
- }
- var sum = sumA + sumB;
- if (sum == 3)
- {
- if (sumA >= 2)
- {
- arr[i][j] = 1; // Black+
- }
- else
- {
- arr[i][j] = 2; // Red+
- }
- }
- else
- {
- if (sum == 2)
- {
- arr[i][j] = 3; // +-
- }
- else
- {
- arr[i][j] = 0; // -
- }
- }
- }
- }
- for (var i = 0; i < Width; i++)
- {
- for (var j = 0; j < Height; j++)
- {
- var e = $gameMap.eventIdXy(i, j);
- var m = $gameMap.mapId();
- if (arr[x][y] == 0)
- {
- $gameSelfSwitches.setValue([m, e, 'A'], false);
- $gameSelfSwitches.setValue([m, e, 'B'], false);
- }
- else if (arr[x][y] == 1)
- {
- if ($gameSelfSwitches.Value([m, e, 'B']) == false)
- {
- $gameSelfSwitches.setValue([m, e, 'A'], true);
- }
- }
- else if (arr[x][y] == 2)
- {
- if ($gameSelfSwitches.Value([m, e, 'A']) == false)
- {
- $gameSelfSwitches.setValue([m, e, 'B'], true);
- }
- }
- }
- }
- }
- };
复制代码 |
|