无法识别具有多个参数的DoGet



我目前正在尝试将Lua脚本与GS WebApp连接起来。连接正在工作,但由于我缺乏GScripting方面的知识,我不确定为什么它不能正确保存我的数据。

在Lua方面,我只是传递一个硬代码,一个随机名称和一个简单的数字userid。

local HttpService = game:GetService("HttpService")
local scriptID = scriptlink
local WebApp 
local function updateSpreadSheet ()

local playerData = (scriptID .. "?userid=123&name:Jhon Smith")
WebApp = HttpService:GetAsync(playerData)
end
do 
updateSpreadSheet()
end

在谷歌脚本方面,我只保存最后一行的数据,然后添加userid和名称的值。

function doGet(e) {
console.log(e)
// console.log(f)
callName(e.parameter.userid,e.parameter.name);
}
function callName(userid,name) {
// Get the last Row and add the name provided
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(sheet.getLastRow() + 1,1).setValues([userid],[name]);
}

然而,脚本保存的唯一数据是名称,由于我尚未发现的原因,绕过了userid

setValues((需要一个2D数组,范围维度应与该数组相对应。脚本只得到1 x 1的范围,并且setValues参数不是2D数组。修复语法或使用appendRow

sheet.getRange(sheet.getLastRow() + 1,1,1,2).setValues([[userid,name]]);
//or
sheet.appendRow([userid,name])

参考文献:

  • appendRow

最新更新