gamecircle.Whispersync.DecrementAccumulatingNumber

类型 函数
gamecircle.*
返回值
修订 版本 2024.3703
关键词 累加,数字,Whispersync,递减

概述

将分配给“键”值的累加数减少指定数量。

语法

gamecircle.Whispersync.DecrementAccumulatingNumber(key, value, NT_constant)
(必填)

字符串. 用于访问特定累加数的键。

(必填)

数字. 递减累加数的数量。

NT_常量 (必填)

字符串. NT_常量,可以是“INT”或“DOUBLE”,决定“值”如何应用于累加数。如果为“INT”,则仅忽略数字的小数点值。如果为“DOUBLE”,则将包括小数点值。如果给定的字符串无效,则默认使用“INT”。

示例

local gamecircle = require("plugin.gamecircle")   
gamecircle.Init(false, false, true)    
gamecircle.Whispersync.IncrementAccumulatingNumber("myFirstAccumNum", 25.255, "INT")  
gamecircle.Whispersync.DecrementAccumulatingNumber("myFirstAccumNum", 15.743, "INT")  
print("The value of the AccumNum should be 10. It is: " .. gamecircle.Whispersync.GetAccumulatedNumber("myFirstAccumNum", "INT"))  
--The value will be 10 because we used the NT_constant (NumberType) of "INT", meaning the decimal places were ignored for all the numbers. 
gamecircle.Whispersync.IncrementAccumulatingNumber("mySecondAccumNum", 25.255, "DOUBLE")  
gamecircle.Whispersync.DecrementAccumulatingNumber("mySecondAccumNum", 15.743, "DOUBLE")  
print("The integer value of the second AccumNum should be 9. It is: " .. gamecircle.Whispersync.GetAccumulatedNumber("mySecondAccumNum", "INT"))  
--The value stored with WhisperSync is actually 9.512, but because we used the "INT" NT_constant with the Get functions, we only got the 9 value.   
print("The double value of the second AccumNum should be 9.512. It is: " .. gamecircle.Whispersync.GetAccumulatedNumber("mySecondAccumNum", "DOUBLE"))  
--Using the NT_constant "DOUBLE", we are able to get the full decimal number stored with Whispersync.   
print("These are all the Accumulated Numbers I've generated under the current GameData set of Whispersync.")  
local keys = gamecircle.Whispersync.GetAccumulatingNumberKeys()  
for i,key in ipairs(keys) do  
    print("-" .. key)  
end