如何在使用while循环时使用Hash.Lib插入值?

我有以下代码...在while循环内循环时,如何能够插入具有不同索引的数组列表中的值?从第2个函数(HashMine(CarID1))开始

    local function HistoryHash() -- 此函数用于打印使用Hash.Lib“挖掘”的哈希
    for Hashindex = 1, #HashHistory do
        print("哈希 "..Hashindex..":", HashHistory[Hashindex])
    end
end
--挖掘BTC待定交易
local function HashMine(CarID1)
    while stringtohash:sub(1,2) ~= "00" do
        STRINGTOHASH = stringtohash..HASHNUMBER
        stringtohash = HASHLIBRARY.sha256(STRINGTOHASH)
        HASHNUMBER = HASHNUMBER + 1
        wait(1)
        table.insert()
    end

    HashGUI.Text = stringtohash
    PendingTextGui.Text = ""
    local CarID1 = CarBought

    if CarID1 == 1 then
        ConfirmedText.Text = ("Car1 ".. game.Workspace.Cars.Car1Buy.Car1.Value .. "BTC去马耳他车行从" .. Players:GetChildren()[1].Name)
        AfterCarPurchase()
    elseif CarID1 == 2 then
        ConfirmedText.Text = ("Car2 ".. game.Workspace.Cars.Car2Buy.Car2.Value.. "BTC去马耳他车行从" .. Players:GetChildren()[1].Name)
        AfterCarPurchase()
    elseif CarID1 == 3 then
        ConfirmedText.Text = ("Car3 ".. game.Workspace.Cars.Car3Buy.Car3.Value .. "BTC去马耳他车行从" .. Players:GetChildren()[1].Name)
    end
    AfterCarPurchase()
end
点赞
用户2858170
用户2858170

table.insert() 会导致如下错误信息:

bad argument #1 to 'insert' (table expected, got no value)

根据 Lua 5.4 参考手册- table.insert,在使用 table.insert() 时必须提供要插入的表以及要插入到该表中的值。

table.insert (list, [pos,] value)

在列表 list 的位置 pos 插入元素 value,并将 list[pos]list[pos+1],一直到 list[#list] 的元素都上移一个位置。如果没指定 pos,则默认为 #list+1,也就是将 x 插入在列表 t 的末尾。

如果你想要将一个值分配给特定的表索引,你需要使用索引赋值 t[key] = value

2021-05-11 16:30:27