我有一个新问题,我想知道你是否能够在Lua内做enumartions,我不确定这是否是正确的名称,我能解释的最佳方式是如果我给你看一个例子使用PAWN(如果您知道C类型语言,那将是有意义的).
#define MAX_SPIDERS 1000
new spawnedSpiders;
enum _spiderData {
    spiderX,
    spiderY,
    bool:spiderDead
}
new SpiderData[MAX_SPIDERS][_spiderData];
stock SpawnSpider(x, y)
{
    spawnedSpiders++;
    new thisId = spawnedSpiders;
    SpiderData[thisId][spiderX] = x;
    SpiderData[thisId][spiderY] = y;
    SpiderData[thisId][spiderDead] = false;
    return thisId;
}
这就是它在PAWN中的样子,但我不知道如何在Lua中这样做......这就是我到目前为止所做的.
local spawnedSpiders = {x, y, dead}
local spawnCount = 0
function spider.spawn(tilex, tiley)
    spawnCount = spawnCount + 1
    local thisId = spawnCount
    spawnedSpiders[thisId].x = tilex
    spawnedSpiders[thisId].y = tiley
    spawnedSpiders[thisId].dead = false
    return thisId
end
但显然它会出错,你们中有谁知道这样做的正确方法吗?谢谢!
像这样的东西吗?
local spawnedSpiders = {}
local spawnCount = 0
function spawn_spider(tilex, tiley)
    spawnCount = spawnCount + 1
    spawnedSpiders[spawnCount] = {
      x = tilex,
      y = tiley,
      dead = false,
    }
    return spawnCount
end
编辑:于浩比我快:)
| 归档时间: | 
 | 
| 查看次数: | 5595 次 | 
| 最近记录: |