Project1

标题: 这到底是哪里出了问题 完全按照教程来的 [打印本页]

作者: cvb666    时间: 2016-9-10 15:45
标题: 这到底是哪里出了问题 完全按照教程来的
JAVASCRIPT 代码复制
  1. /**
  2.  * Created by Administrator on 2016/9/10.
  3.  */
  4. //==========================================================================================================
  5. // RandomWeapon.js
  6. //==========================================================================================================
  7. /*:
  8.  * @plugindesc 随机获取一把武器.
  9.  * @author DYART
  10.  *
  11.  * @param price
  12.  * @desc 每次购买所需要的钱.
  13.  * @default 1000
  14.  * @help This plugin does not provide plugin commands. 这个插件没有提供插件命令。
  15.  * 使用方法: 在事件指令里输入: RandomWeapon get
  16.  */
  17. //这东西是定义一个对象,然后把插件里面的东西都藏在这对象里面,防止和别人起名字冲突了.
  18. var RandomWeapon = window.RandomWeapon || { };
  19. //外面调用的话,都要用RandomWeapon.来调用
  20. //读取参数的对象
  21. RandomWeapon.parameters = PluginManager.parameters( 'RandomWeapon');
  22. //这是我们允许随机获得武器的id,id是根据dataWeapons.js里面的id属性确定的.
  23. RandomWeapon.weaponsList = [1,2,3,4];
  24. //每次随机的价格.从参数里面获得
  25. RandomWeapon.price = parseInt (RandomWeapon.parameters[ 'price' ] || '1000' ) ;
  26.  
  27. RandomWeapon._Game_Interpreter_pluginCommand =Game_Interpreter. prototype.pluginCommand;
  28. Game_Interpreter . prototype. pluginCommand = function(command, args )  {
  29.     RandomWeapon._Game_Interpreter.pluginCommand.call ( this, command, args);
  30.     if (command === 'RandomWeapon') {
  31.         switch (args[0]) {
  32.             case ' get ': //命令 get
  33.                 RandomWeapon.getWeapon( );
  34.                 break;
  35.         }
  36.     }
  37. };
  38.  
  39.  
  40. //这是获得武器的函数,在面向对象里面,我们叫它"方法".
  41. RandomWeapon.getWeapon = function () {
  42.     if ($gameParty.gold()<RandomWeapon.price)//判断钱够不够,不够直接跳出去
  43.     {
  44.         return ;
  45.     }else{//钱够的话,
  46.         //来个临时变量,先获得0¬1之间的随机数,然后乘以允许获得的武器数量,然后取整数部分,做为我们随机选定的武器ID
  47.         var id = Math.ceil (Math.random()*(RandomWeapon.weaponsList.length) );
  48.         //获得item,RPGMakerMV的核心函数,前一个参数是从json里面得到武器的对象,后一个参数是数量,我们只要一个.
  49.         $gameParty.gainItem($dataWeapons[RandomWeapon.weaponsList[id]],1);
  50.         //最后把钱扣掉
  51.         $gameParty.loseGold(RandomWeapon.price);
  52.     }
  53. }




作者: shitake    时间: 2016-9-10 16:37
你的'.'号有问题
作者: cvb666    时间: 2016-9-10 18:48
shitake 发表于 2016-9-10 16:37
你的'.'号有问题

我勒个去 那么多点 那个点有问题???
作者: cvb666    时间: 2016-9-10 19:29
没人知道吗???????????????????
作者: 在野月光    时间: 2016-9-10 22:06
2楼+1

自定义参数不吻合。
27行是  _p
29行是   .p

作者: cvb666    时间: 2016-9-11 08:41
在野月光 发表于 2016-9-10 22:06
2楼+1

自定义参数不吻合。

谢谢 已经搞定了 还有就是 'get '后面多了个空格




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1