【解決】this.character(-1)でエラーになる

返信する
おのき
記事: 14
登録日時: 2017年8月28日(月) 18:07
連絡する:

【解決】this.character(-1)でエラーになる

投稿記事 by おのき »

初めての書き込みです。
ツクールMVを始めてから3日目です。
プログラミングのブランクは5年あり,JavaScriptでの開発はほとんど未経験に近いです。
この度,10年前から開発予定だった新ローグライクを完成させるべく再開しました。
よろしくお願いします。
早速ですが,症状は以下の通りです。

コード: 全て選択

(function() {
  'use strict';//厳格モード

  Game_Player.prototype.moveByInput = function() {
    if (!this.isMoving() && this.canMove()) {
      var player = this.character(-1);//←エラー
      var direction = this.getInputDirection();
      if (direction > 0) {
        $gameTemp.clearDestination();
      }
      else if ($gameTemp.isDestinationValid()) {
        var x = $gameTemp.destinationX();
        var y = $gameTemp.destinationY();
        direction = this.findDirectionTo(x, y);
      }
      if (direction > 0) {
        this.executeMove(direction);
      }
    }
  };
  /*
    TypeError: undefined is not a function
    at Game_Player.moveByInput (***.js:54)
    at Game_Player.update (rpg_objects.js:7668)
    at Scene_Map.updateMain (rpg_scenes.js:609)
    at Scene_Map.updateMainMultiply (rpg_scenes.js:600)
    at Scene_Map.update (rpg_scenes.js:589)
    at Function.SceneManager.updateScene (rpg_managers.js:2024)
    at Function.SceneManager.updateMain (rpg_managers.js:1983)
    at Function.SceneManager.update (rpg_managers.js:1907)
  */
})();
最後に編集したユーザー おのき [ 2017年8月29日(火) 12:47 ], 累計 1 回
アバター
まっつUP
記事: 1149
登録日時: 2016年8月11日(木) 15:38
お住まい: タケノコ王国

Re: this.character(-1)でエラーになる

投稿記事 by まっつUP »

おのき様
お世話になります。

Game_Playerやその親クラスに//←エラーとある行の
関数が定義されていないためエラーが起こります。
RPGで笑顔を・・・

ツイッター(ツクラーの巣窟)(閲覧は自己責任でお願いします)
https://twitter.com/mattuup

github
https://github.com/mattuup/RPGMakerMZ
アバター
しぐれん
記事: 975
登録日時: 2017年3月28日(火) 22:22
連絡する:

Re: this.character(-1)でエラーになる

投稿記事 by しぐれん »

this.character()はGame_Interpreterクラスのメソッドです。
イベントコマンド「スクリプト」は暗黙にinterpreterをthisと設定しています。
プレイヤーを取得したい場合、$gamePlayerを取得してください。
現在、プラグイン依頼はお休み中です。
おのき
記事: 14
登録日時: 2017年8月28日(月) 18:07
連絡する:

Re: this.character(-1)でエラーになる

投稿記事 by おのき »

ご返信ありがとうございます。
私は今夜出勤なので,この件は明日確認したいと思います。
おのき
記事: 14
登録日時: 2017年8月28日(月) 18:07
連絡する:

Re: this.character(-1)でエラーになる

投稿記事 by おのき »

確認したところによると,rpg_managers.jsのDataManagerにまとまっていました。
イベントコマンド「スクリプト」は別物なんですね。
とくに考えずwikiのリファレンスに飛びついてしまいました。
お恥ずかしい。
まあそれでもハマっていたことは事実なので,とても助かりました。
素早い対応に感謝します。
ありがとうございました。

コード: 全て選択

var $dataActors       = null;
var $dataClasses      = null;
var $dataSkills       = null;
var $dataItems        = null;
var $dataWeapons      = null;
var $dataArmors       = null;
var $dataEnemies      = null;
var $dataTroops       = null;
var $dataStates       = null;
var $dataAnimations   = null;
var $dataTilesets     = null;
var $dataCommonEvents = null;
var $dataSystem       = null;
var $dataMapInfos     = null;
var $dataMap          = null;
var $gameTemp         = null;
var $gameSystem       = null;
var $gameScreen       = null;
var $gameTimer        = null;
var $gameMessage      = null;
var $gameSwitches     = null;
var $gameVariables    = null;
var $gameSelfSwitches = null;
var $gameActors       = null;
var $gameParty        = null;
var $gameTroop        = null;
var $gameMap          = null;
var $gamePlayer       = null;
var $testEvent        = null;
返信する

“MV:質問”に戻る