コマンドラインバージョンのluaですべての機能を実行できるという問題がありますが、プログラムを実行してもエラーは発生せず、終了するだけです。これを診断する方法がわかりませんが、さまざまなことに対してエラーを数回スローしようとしましたが、エラーが発生してエラーが出力されます。
power = peripheral.wrap("bottom")
mon = peripheral.wrap("top")
x,y = mon.getSize()
clearTerm = function()
term.clear()
term.setCursorPos(1,1)
end
clearBoth = function()
clearMon()
clearTerm()
end
intLen = function(bar)
tab = tostring(bar)
tab = string.len(tab)
return tab
end
checkPower = function()
total = power.getMaxEnergyStored()
local til = intLen(total)
local yy = math.floor(y/2)
local tol = math.floor(x-til)
mon.setCursorPos(yy+0,tol/2)
for z=1,til do mon.write("-") end
mon.setCursorPos(yy-1,tol/2)
mon.write(total)
while true do
current = power.getEnergyStored()
local cil = intLen(current)
local col = math.floor(x-cil)
mon.setCursorPos(yy+1,col/2)
mon.write(current)
sleep(1)
end
end
プログラム全体のペーストビンへのリンクもここに残しておきます。