查看: 5946|回复: 2

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

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

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

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

×
原方法是这么定义的,如何写出实现(变量1)减去1的效果?
$gameVariables.setValue(1,2),只是设置1为2,减法怎么弄?
[pre lang="javascript"]Game_Interpreter.prototype.operateVariable = function(variableId, operationType, value) {
    try {
        var oldValue = $gameVariables.value(variableId);
        switch (operationType) {
        case 0:  // Set
            $gameVariables.setValue(variableId, oldValue = value);
            break;
        case 1:  // Add
            $gameVariables.setValue(variableId, oldValue + value);
            break;
        case 2:  // Sub
            $gameVariables.setValue(variableId, oldValue - value);
            break;
        case 3:  // Mul
            $gameVariables.setValue(variableId, oldValue * value);
            break;
        case 4:  // Div
            $gameVariables.setValue(variableId, oldValue / value);
            break;
        case 5:  // Mod
            $gameVariables.setValue(variableId, oldValue % value);
            break;
        }
    } catch (e) {
        $gameVariables.setValue(variableId, 0);
    }
};[/pre]
梦石
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
星屑
172
在线时间
935 小时
注册时间
2010-11-13
回帖
897
发表于 2020-8-3 21:45:24 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部