查看: 6001|回复: 2

[已经解决] MV变量代码使用

[复制链接]
梦石
0
星屑
723
在线时间
530 小时
注册时间
2010-6-9
回帖
668
发表于 2016-2-25 16:38:58 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
原方法是这么定义的,如何写出实现(变量1)减去1的效果?
$gameVariables.setValue(1,2),只是设置1为2,减法怎么弄?
  1. Game_Interpreter.prototype.operateVariable = function(variableId, operationType, value) {
  2.     try {
  3.         var oldValue = $gameVariables.value(variableId);
  4.         switch (operationType) {
  5.         case 0:  // Set
  6.             $gameVariables.setValue(variableId, oldValue = value);
  7.             break;
  8.         case 1:  // Add
  9.             $gameVariables.setValue(variableId, oldValue + value);
  10.             break;
  11.         case 2:  // Sub
  12.             $gameVariables.setValue(variableId, oldValue - value);
  13.             break;
  14.         case 3:  // Mul
  15.             $gameVariables.setValue(variableId, oldValue * value);
  16.             break;
  17.         case 4:  // Div
  18.             $gameVariables.setValue(variableId, oldValue / value);
  19.             break;
  20.         case 5:  // Mod
  21.             $gameVariables.setValue(variableId, oldValue % value);
  22.             break;
  23.         }
  24.     } catch (e) {
  25.         $gameVariables.setValue(variableId, 0);
  26.     }
  27. };
复制代码
梦石
0
星屑
1314
在线时间
904 小时
注册时间
2014-12-4
回帖
349
发表于 2016-2-25 17:13:55 | 显示全部楼层
  1. $gameVariables.setValue(1,$gameVariables.value(1)-1)
复制代码

点评

因为setValue方法才能给变量赋值,你直接value(1)-1的话并不能给变量赋值,这是硬性规定  发表于 2016-2-25 19:26
这个真别扭,$gameVariables.value(1)-1这个“值”我能理解为啥有问题,但不知道怎么解决。  发表于 2016-2-25 18:36
$gameVariables.value(1)-1这个值为什么不能单独拿出来用?我用这个会报错,整句的话我回家试试。  发表于 2016-2-25 18:33
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
177
在线时间
936 小时
注册时间
2010-11-13
回帖
897
发表于 2020-8-3 21:45:24 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部