Skip to content

Instantly share code, notes, and snippets.

View triacontane's full-sized avatar

トリアコンタン triacontane

View GitHub Profile
@triacontane
triacontane / iterate.js
Last active January 18, 2016 17:11
オブジェクトのプロパティに対して繰り返し処理を行う
if (!Object.prototype.hasOwnProperty('iterate')) {
Object.defineProperty(Object.prototype, 'iterate', {
value : function (handler) {
Object.keys(this).forEach(function (key, index) {
handler.call(this, key, this[key], index);
}, this);
}
});
}
@triacontane
triacontane / tims.js
Created January 18, 2016 17:14
指定した回数分処理を繰り返す
Number.prototype.times = function(handler) {
var i = 0; while(i < this) handler.call(this, i++);
};
Number(4).times(function(i) {
console.log(i)
}.bind(this));
// 0
// 1
@triacontane
triacontane / readdir.js
Created January 20, 2016 12:16
ピクチャ一覧を取得
var fs = require('fs');
var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/img/pictures/');
if (path.match(/^\/([A-Z]\:)/)) {
path = path.slice(1);
}
console.log(fs.readdirSync(path));
@triacontane
triacontane / AnimationErase.js
Created January 28, 2016 12:56
再生中のアニメーションを削除
var eventId = 1;
SceneManager._scene._spriteset._characterSprites.forEach(function(sprite) {
if (sprite._character instanceof Game_Event && sprite._character.eventId() === eventId) {
sprite._animationSprites.forEach(function(animation) {
animation.remove();
});
}
});
SceneManager._scene._spriteset._characterSprites.forEach(function(sprite) {
@triacontane
triacontane / missSpell.js
Created January 28, 2016 13:43
スペルミス
Game_Map.prototype.refereshVehicles = function() {
this._vehicles.forEach(function(vehicle) {
vehicle.refresh();
});
};
Game_Map.prototype.refreshVehicles = function() {
this._vehicles.forEach(function(vehicle) {
vehicle.refresh();
});
@triacontane
triacontane / LastSkillUser.js
Created February 12, 2016 23:37
最後に行動したのが敵か味方か
var value = BattleManager._subject instanceof Game_Actor;
$gameSwitches.setValue(100, value);
alert($gameSwitches.value(100));
@triacontane
triacontane / CustomizeConfigItem.js
Created March 1, 2016 16:52
オプション任意項目作成プラグイン Boolean項目のアイコン表示
/* アイコンを表示するために変更した箇所 開始 */
var _Window_Options_drawItem = Window_Options.prototype.drawItem;
Window_Options.prototype.drawItem = function(index) {
_Window_Options_drawItem.apply(this, arguments);
var rect = this.itemRectForText(index);
this.drawIcon(this.statusIcon(index), rect.width - Window_Base._iconWidth, rect.y + 2);
};
Window_Options.prototype.statusIcon = function(index) {
var symbol = this.commandSymbol(index);
@triacontane
triacontane / getClassName.js
Created March 4, 2016 15:33
クラス名取得
var getClassName = function(object) {
return object.constructor.toString().replace(/function\s+(.*)\s*\([\s\S]*/m, '$1');
};
@triacontane
triacontane / PictureChange.js
Created June 12, 2016 03:06
ピクチャのチラつきを防いで画像を差し替えるスクリプト
var pictName = 'ピクチャ名';
var bitmap = ImageManager.loadPicture(pictName);
bitmap.addLoadListener(function() {
$gameScreen.picture(ピクチャ番号)._name = pictName;
});
@triacontane
triacontane / randomRangeInt.js
Created July 2, 2016 13:09
指定した変数値の範囲内の乱数を取得します
var min = $gameVariables.value(1);
var max = $gameVariables.value(2);
$gameVariables.setValue(3, min + Math.randomInt(max - min + 1));