迷你世界UGC3.0脚本Wiki二维表变量数据管理接口 Table

迷你世界UGC3.0脚本Wiki


Menu
On this page
Sidebar Navigation
快速入门
欢迎

MOD、组件介绍

什么是Lua编程

组件介绍
组件说明

组件函数

组件属性

事件
触发器事件管理

组件事件管理

函数库
服务模块
世界模块管理接口 World

对象模块管理接口 GameObject

角色模块管理接口 Actor

玩家模块管理接口 Player

生物模块管理接口 Monster

方块模块管理接口 Block

道具模块管理接口 Item

背包模块管理接口 Backpack

界面模块管理接口 CustomUI

图文信息模块管理接口 Graphics

区域模块管理接口 Area

容器模块管理接口 WorldContainer

资源模块管理接口 Mod

计时器模块管理接口 Timer

状态模块管理接口 Buff

消息模块管理接口 Chat

普通变量数据管理接口 Data

数组变量数据管理接口 Array

二维表变量数据管理接口 Table

云服模块管理接口 CloudSever

全局函数
全局函数

枚举
枚举库

脚本常见问题
开发者常见问题

进阶指南
全局函数

触发器脚本交互

对象介绍

二维表介绍

更新日志
更新日志

二维表变量数据管理接口 Table
具体函数名及描述如下:

序号    函数名    函数描述
1    Clear(...)    清理表格数据
2    InsertValue(...)    在末尾插入一行数据
3    InsertValueByRow(...)    在某行插入一行数据
4    GetValue(...)    获取表格数据
5    GetAllValue(...)    获取表格数据
6    SetValue(...)    设置表格数据
7    RemoveRow(...)    删除序列号的值
8    GetValuesByCol(...)    获取某列的所有值
9    GetRows(...)    获取行数
10    GetCols(...)    获取列数
11    GetColIndex(...)    获取列索引
12    GetRowIndex(...)    获取指定列和值的行索引(默认判断值相等)
13    GetRowIndexs(...)    获取指定列和值的所有行索引(默认判断值相等)
14    GetTableColKeys(...)    
Clear
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
返回值及类型:
ret:bool是否成功
该方法的主要作用: 清理表格数据
具体使用案例如下:

   local isSuccess = Data.Table:Clear(varId)

   if isSuccess then

       print("清除表格成功")

   end

   local isSuccessPlayer = Data.Table:Clear(playerVarId, Player:GetHostUin())

   if isSuccessPlayer then

       print("清除玩家表格成功")

   end
InsertValue
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
...:any按照列顺序编写的值 中间值不能传nil
返回值及类型:
value:any返回的值
该方法的主要作用: 在末尾插入一行数据
具体使用案例如下:

    local isSuccess = Data.Table:InsertValue(varId, nil, 2, "aa", false)

    if isSuccess then

        print("插入表格值成功")

    end

    local isSuccessPlayer = Data.Table:InsertValue(playerVarId, Player:GetHostUin(), 2, "aaa", false)

    if isSuccessPlayer then

        print("插入玩家表格值成功")

    end
InsertValueByRow
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
value:table插入的值{[1] = xx
...} or {[key] = xx
...}
返回值及类型:
value:any返回的值
该方法的主要作用: 在某行插入一行数据
具体使用案例如下:

    local isSuccess = Data.Table:InsertValueByRow(varId, nil, {2, "sss3", false}, 1) -- 在第一行插入一行数据

    if isSuccess then

        print("按行插入表格值成功")

    end

    local isSuccessPlayer = Data.Table:InsertValueByRow(playerVarId, Player:GetHostUin(), {2, "sssa", false})-- 在最后一行插入一行数据

    if isSuccessPlayer then

        print("按行插入玩家表格值成功")

    end
GetValue
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
row:number行索引
col:number列索引或列名
返回值及类型:
value:any返回的值
该方法的主要作用: 获取表格数据
具体使用案例如下:

    local value = Data.Table:GetValue(varId, nil, 2, 2)

    if value then

        print("获取表格值", value)

    end

    local playerValue = Data.Table:GetValue(playerVarId, Player:GetHostUin(), 2, 1)

    if playerValue then

        print("获取玩家表格值", playerValue)

    end
GetAllValue
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
返回值及类型:
value:any返回的值
该方法的主要作用: 获取表格数据
具体使用案例如下:

    -- 获取后的数据格式是

    -- {

    --     {10, "RRR", 0},-- 第一行    

    --     {9, "sss", 0}, -- 第二行

    --     {0, "fff", 0}, -- 第三行

    -- }

    local allValues = Data.Table:GetAllValue(varId)

    if allValues then

        print("获取表格所有值", allValues)

    end

    local playerAllValues = Data.Table:GetAllValue(playerVarId, Player:GetHostUin())

    if playerAllValues then

        print("获取玩家表格所有值", playerAllValues)

    end
SetValue
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
row:number,array行索引或行索引数组
col:number列索引或列名
value:any设置的值
返回值及类型:
ret:bool成功(true)
该方法的主要作用: 设置表格数据
具体使用案例如下:

local ret = Data.Table:SetValue(varId, playerId, row, col, value)
RemoveRow
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
row:number,array行索引或索引组
返回值及类型:
ret:bool成功(true)
该方法的主要作用: 删除序列号的值
具体使用案例如下:

    local isSuccess = Data.Table:RemoveRow(varId, nil, 1) -- 移除第一行

    if isSuccess then

        print("移除表格行成功")

    end

    local isSuccessPlayer = Data.Table:RemoveRow(playerVarId, Player:GetHostUin(), {2, 4}) -- 移除第二行和第四行

    if isSuccessPlayer then

        print("移除玩家表格行成功")

    end
GetValuesByCol
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
col:number列索引或列名
返回值及类型:
ret:bool成功(true)
该方法的主要作用: 获取某列的所有值
具体使用案例如下:

    local values = Data.Table:GetValuesByCol(varId, nil, 1)

    if values then

        print("获取表格列值", values)

    end

    local playerValues = Data.Table:GetValuesByCol(playerVarId, Player:GetHostUin(), 2)

    if playerValues then

        print("获取玩家表格列值", playerValues)

    end
GetRows
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
返回值及类型:
size:number行数
该方法的主要作用: 获取行数
具体使用案例如下:

    local rows = Data.Table:GetRows(varId)

    if rows then

        print("获取表格行数",rows)

    end

    local size = Data.Table:GetRows(playerVarId, Player:GetHostUin())

    if size then

        print("获取玩家表格行数",size)

    end
GetCols
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
返回值及类型:
size:number列数
该方法的主要作用: 获取列数
具体使用案例如下:

    local cols = Data.Table:GetCols(varId)

    if cols then

        print("获取表格列数",cols)

    end

    local num = Data.Table:GetCols(playerVarId, Player:GetHostUin())

    if num then

        print("获取玩家表格列数",num)

    end
GetColIndex
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
返回值及类型:
size:number列索引
该方法的主要作用: 获取列索引
具体使用案例如下:

    local colIndex = Data.Table:GetColIndex(varId, nil, "名称")

    if colIndex then

        print("获取表格列索引", colIndex)

    end

    local playerColIndex = Data.Table:GetColIndex(playerVarId, Player:GetHostUin(), "分数")

    if playerColIndex then

        print("获取玩家表格列索引", playerColIndex)

    end
GetRowIndex
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
col:number列索引或列名
value:any查询的值
cmp:function筛选函数(可为nil,function(action
value) return a == value end)
返回值及类型:
size:number行数
该方法的主要作用: 获取指定列和值的行索引(默认判断值相等)
具体使用案例如下:

    local rowIndex = Data.Table:GetRowIndex(varId, nil, 2, "sss")

    if rowIndex then

        print("获取表格行索引", rowIndex)

    end

    local playerRowIndex = Data.Table:GetRowIndex(playerVarId, Player:GetHostUin(), 3, true)

    if playerRowIndex then

        print("获取玩家表格行索引", playerRowIndex)

    end
GetRowIndexs
参数及类型:
varId:string表ID
playerId:number玩家uin(全局变量传nil)
col:number列索引或列名
value:any查询的值
cmp:function筛选函数(可为nil,function(action
value) return a == value end)
返回值及类型:
size:number行数
该方法的主要作用: 获取指定列和值的所有行索引(默认判断值相等)
具体使用案例如下:

    local rowIndexs = Data.Table:GetRowIndexs(varId, nil, 2, "sss")

    if rowIndexs then

        for key, value in pairs(rowIndexs) do

            print("获取表格行索引", value )

        end

    end

    local playerRowIndexs = Data.Table:GetRowIndexs(playerVarId, Player:GetHostUin(), 3, false)

    if playerRowIndexs then

        for key, value in pairs(playerRowIndexs) do

            print("获取玩家表格行索引", value )

        end

    end
GetTableColKeys
参数及类型:

返回值及类型:

该方法的主要作用:

具体使用案例如下:


    local colKeys = Data.Table:GetTableColKeys(varId)
Last updated: 2025/4/18 18:43

Pager
Previous page
数组变量数据管理接口 Array
Next page
云服模块管理接口 CloudSever

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值