Posted 29 August 2013 - 12:59 PM
Title: Need help with autorunning script efficiently every x seconds
Im using this script on a server, so I need some efficiency. All solutions I (LUA noob much) tried tend to produce lag or even worse disasters…
Set up:
I want the CCmonitor to show current ammount of spoilsbags (the un-player-inventorized ones) in my AE network.
I have a computer connected to a monitor and a ME Bridge.
Script so far:
The code shows the spoils bag ammount just fine, but I need it to run every x seconds, which is where I did not succeed.
Any help on how to achieve this or even how to make my current code better is greatly appreciated.
Im using this script on a server, so I need some efficiency. All solutions I (LUA noob much) tried tend to produce lag or even worse disasters…
Set up:
I want the CCmonitor to show current ammount of spoilsbags (the un-player-inventorized ones) in my AE network.
I have a computer connected to a monitor and a ME Bridge.
Script so far:
--credit to voidreality on FTB forums for the ME Bridge basics
m = peripheral.wrap("bottom")
mon = peripheral.wrap("right")
mon.clear()
a = 6297 --spoils bag ID
x, y = mon.getSize()
local function cwrite (text, y)
cx = math.ceil((x/2)-(string.len(text)/2))
mon.setCursorPos(cx, y)
mon.write(text)
end
myList = m.listItems()
boo = false
cwrite("Spoils", y/2 - 1)
cwrite("Bags:", y/2)
for k, v in pairs (myList) do
if k == a then
boo = true
cwrite(tostring(v), y/2+2)
end
end
if boo == false then cwrite("0", y/2+2) end
The code shows the spoils bag ammount just fine, but I need it to run every x seconds, which is where I did not succeed.
Any help on how to achieve this or even how to make my current code better is greatly appreciated.