2

より簡単に参照できるように思われる変数がたくさんありますが、その方法がわかりません。変数名は座標系のエントリに関連付けられており、それらが書き込まれる場所も座標ベースです。Google で検索してみたり、Lua のドキュメントを調べたりしましたが、何を探しているのかわからないため、検索が妨げられていると思います。私のコードの抜粋で変数がどのように見えるかを次に示します。

-- バンク 1

local Object111 =  sItem.getTargetDetails("-4,3,-4")
local Object112 =  sItem.getTargetDetails("-5,3,-4")
local Object113 =  sItem.getTargetDetails("-6,3,-4")
local Object114 =  sItem.getTargetDetails("-7,3,-4")
local Object115 =  sItem.getTargetDetails("-8,3,-4")

local Object121 =  sItem.getTargetDetails("-4,4,-4")
local Object122 =  sItem.getTargetDetails("-5,4,-4")
local Object123 =  sItem.getTargetDetails("-6,4,-4")
local Object124 =  sItem.getTargetDetails("-7,4,-4")
local Object125 =  sItem.getTargetDetails("-8,4,-4")

local Object131 =  sItem.getTargetDetails("-4,5,-4")
local Object132 =  sItem.getTargetDetails("-5,5,-4")
local Object133 =  sItem.getTargetDetails("-6,5,-4")
local Object134 =  sItem.getTargetDetails("-7,5,-4")
local Object135 =  sItem.getTargetDetails("-8,5,-4")

-- バンク 2

local Object211 =  sItem.getTargetDetails("-4,3,1")
local Object212 =  sItem.getTargetDetails("-5,3,1")
local Object213 =  sItem.getTargetDetails("-6,3,1")
local Object214 =  sItem.getTargetDetails("-7,3,1")
local Object215 =  sItem.getTargetDetails("-8,3,1")

local Object221 =  sItem.getTargetDetails("-4,4,1")
local Object222 =  sItem.getTargetDetails("-5,4,1")
local Object223 =  sItem.getTargetDetails("-6,4,1")
local Object224 =  sItem.getTargetDetails("-7,4,1")
local Object225 =  sItem.getTargetDetails("-8,4,1")

local Object231 =  sItem.getTargetDetails("-4,5,1")
local Object232 =  sItem.getTargetDetails("-5,5,1")
local Object233 =  sItem.getTargetDetails("-6,5,1")
local Object234 =  sItem.getTargetDetails("-7,5,1")
local Object235 =  sItem.getTargetDetails("-8,5,1")

次に、これらの変数のそれぞれを関数で呼び出します。画面上の位置は名前の数字の関数であり、最初の 2 つの数字は x 座標に関連し、最後の数字は y 座標に関連しています。

mon.setCursorPos(4,4)
mon.write(Object111.StoredPercentage)
mon.setCursorPos(10,4)
mon.write(Object112.StoredPercentage)
mon.setCursorPos(16,4)
mon.write(Object113.StoredPercentage)
...
mon.setCursorPos(8,4)
mon.write(Object121.StoredPercentage)
mon.setCursorPos(8,4)
mon.write(Object121.StoredPercentage)
...
mon.setCursorPos(36,4)
mon.write(Object211.StoredPercentage)
mon.setCursorPos(42,4)
mon.write(Object212.StoredPercentage)
mon.setCursorPos(48,4)
mon.write(Object213.StoredPercentage)
etc....

これはオンザフライで生成できるはずですが、手動で呼び出さないとどこから始めればよいかわかりません。私のコードがよりきれいであれば、私はそれを好むでしょう。この段階では、釣り方を教えてもらう必要があります。誰かが私がやろうとしていることを行う方法を説明するドキュメントを教えてくれれば、私はとても感謝しています.

4

1 に答える 1

3

同じことを達成しようとしている人のための私の最終的な解決策は次のとおりです。

local Banks = 2
local Rows = 3
local Columns = 5

function Objectstatus(bank,row,column)

    Id = bank .. row .. column
    worldx = "-" .. column+3
    worldy = row+2
    if bank == 1 then worldz = -4; end
    if bank == 2 then worldz = 1; end
    Object = {}
    Object[Id] = s.getTargetDetails(worldx..","..worldy..","..worldz)
    xcursor = (column*7)+3
    if bank == 1 then 
        ycursor = (row*4)+8
    end
    if bank == 2 then 
        ycursor = (row*4)+24
    end

    mon.setCursorPos(xcursor,ycursor)
    powertext(Object[Id].StoredPercentage) -- A function that sets Texts settings based on result
    mon.write(Object[Id].StoredPercentage) -- Actually writes the result
end

    for BankTemp = 1, Banks do
        for ColumnTemp = 1, Columns do
            for RowTemp = 1, Rows do
            Objectstatus(BankTemp,RowTemp,ColumnTemp)
            end
        end
    end
于 2014-09-01T11:41:59.023 に答える