Lua Array深层阵列搜索Open Tibia脚本

时间:2014-06-10 15:33:06

标签: arrays lua

希望从数组中的数组中获取信息,而基本上没有确切的信息。

    local cfg_raids = {
    [2] =
    {
        ["10:17"] = {
            raidName = "Rats - Thais",
            Event_Type = "Raid Activated",
            Storage = 1234,
            alreadyExecuted = false
        },
        ["10:20"] = {
            raidName = "Testing this shit",
            Event_Type = "Raid Activated",
            Storage = 1235,
            alreadyExecuted = false
        },
    },
    [3] =
    {
        ["12:00"] = {
            raidName = "OrcsThais",
            Event_Type = "Raid Activated",
            Storage = 1236,
            alreadyExecuted = false
        },
    },

尝试随机抽出时间而不实际拥有确切的时间戳。

因此,当脚本激活时间戳数组[" 10:17"]时,它会抓取所有下一个数组信息[&#​​34; 10:20"],而不会实际知道[&# 34; 10:20"]

OPEN TIBIA INFORMATION:http://otland.net/threads/looking-for-some-assistance-on-a-script.216303/

1 个答案:

答案 0 :(得分:2)

使用非整数键,你无法真正做到这一点。您可以尝试使用next函数从当前密钥中获取下一个密钥,但如果表中有两个以上的密钥,则无法保证下一个密钥可以获得(您甚至无法保证它会一直是下一个关键词。)

您可以在该表中使用整数索引,并将时间作为表的一个字段,然后只需使用下一个整数作为下一个键即可。

您还可以在表(或其他表)中的整数索引中以您想要的顺序存储用作键的时间,并使用它而无需重做表本身(例如cfg_raids = { [2] = { "10:17", "10:20", ["10:17"] = {...}, ["10:20"] = {...} } }