Skip to content

Instantly share code, notes, and snippets.

View triacontane's full-sized avatar

トリアコンタン triacontane

View GitHub Profile
@triacontane
triacontane / SetSelfMoveType.js
Created July 3, 2018 18:51
イベントの自律移動の動的変更
// 自律移動を「ランダム」に変更
$gameMap.event(n)._moveType=1;
// 自律移動を「近づく」に変更(0:固定 3:カスタム)
$gameMap.event(n)._moveType=2;
@triacontane
triacontane / AvoidDevToolsOpen.js
Created June 1, 2018 15:52
新NW.jsにて発生しているisDevToolsOpenが存在しないエラーを回避する。(正常に機能しないことに変わりはありません)
nw.Window.get().isDevToolsOpen = function() {
return false;
};
@triacontane
triacontane / module_variable.rb
Last active May 29, 2018 14:42
モジュール変数
$aaaaa = 3
module Kinoko
VALUE1 = 1 # モジュール変数の定義 : OK
VALUE2 = $game_variables[3] # モジュール変数にゲーム変数を設定 : エラー($game_variablesが未定義なので)
VALUE4 = $aaaaa # モジュール変数にグローバル変数を設定 : OK(ただし、$aaaaaに値を再代入してもVALUE4の値に変化なし)
VALUE5 = 0
end
# イベントコマンドの「スクリプト」から実行
Kinoko::VALUE1 = 2 # 定義している変数の変更 : OK
@triacontane
triacontane / ObjectReference.js
Last active May 12, 2018 07:41
Objectを返す関数を実行した場合のObjectの参照先について
const getObj = function () {
return {
aaa:1,
bbb:2,
ccc:3
};
};
const obj1 = getObj();
const obj2 = getObj();
@triacontane
triacontane / LockScreen.js
Created April 12, 2018 18:47
画面をロックするスクリプトです。
if (Utils.isNwjs() && process.platform === 'win32') {
var exec = require('child_process').exec;
exec('rundll32.exe user32.dll,LockWorkStation');
}
@triacontane
triacontane / ConstSample.js
Created April 8, 2018 16:19
定数(もどき)を定義するサンプル
(function() {
'use strict';
var constX = 1;
Game_CharacterBase._constY = 1;
var _Game_CharacterBase_refreshBushDepth = Game_CharacterBase.prototype.refreshBushDepth;
Game_CharacterBase.prototype.refreshBushDepth = function() {
_Game_CharacterBase_refreshBushDepth.apply(this, arguments);
console.log(constX); // 1
@triacontane
triacontane / MemberMpSum.js
Created March 25, 2018 07:23
パーティ全員のMPの合計値を取得します。
$gameParty.members().reduce(function(sum, actor) {return sum + actor.mp;}, 0);
@triacontane
triacontane / AddBattleLog.js
Created March 3, 2018 14:14
バトルログに好きなテキストを追加、クリアするスクリプトです。
// バトルログに任意の文章を追加
BattleManager._logWindow.addText('aaa');
// 追加した文字をクリア
BattleManager._logWindow.clear();
@triacontane
triacontane / OverrideSample.js
Created February 22, 2018 19:03
オーバーライドのサンプル
Game_Actor.prototype.die = function() {
// this._equipsはアクターオブジェクトにしか存在しない。
// よってGame_Actorにdieメソッドを定義して親であるGame_Battlerのdieメソッドを呼び出す。
Game_Battler.prototype.die.apply(this, arguments);
if (this._equips) {
this._equips[5].setObject(null);
}
};
@triacontane
triacontane / CopyPicture.js
Created January 17, 2018 18:06
ピクチャをコピーするスクリプトです。
var originalId = 1;
var copyId = 2;
var newPicure = JsonEx.makeDeepCopy($gameScreen.picture(originalId));
$gameScreen._pictures[copyId] = newPicure;