Posted 02 November 2012 - 11:06 PM
So, when I start my CC LUA program, I see this in the server console.
Basically I want this to stop spamming the server all berserk style and clean it up some. Any ideas?
03:02:28 [INFO] [mod_ccSensors] callMethod:5 args[2]:
03:02:28 [INFO] targetmod:0
03:02:28 [INFO] [mod_ccSensors] callMethod:6 args[2]:
03:02:28 [INFO] [SETTARGET] TileEntityNuclearReactor
03:02:28 [INFO] [mod_ccSensors] callMethod:9 args[2]:
03:02:28 [INFO] [mod_ccSensors] callMethod:2 args[1]:
03:02:28 [INFO] Can't find Field:maxheat in class:TileEntityNuclearReactor
03:02:28 [INFO] DEBUG] getCustomValue f::size, obj:ic2.common.TileEntityNuclearR
eactor
03:02:28 [INFO] DEBUG] getCustomValue getreactorsize
03:02:28 [INFO] DEBUG] saved to repository:size = 6
03:02:28 [INFO] [mod_ccSensors] callMethod:5 args[2]:
03:02:28 [INFO] targetmod:0
03:02:28 [INFO] [mod_ccSensors] callMethod:6 args[2]:
03:02:28 [INFO] [SETTARGET] TileEntityNuclearReactor
03:02:28 [INFO] [mod_ccSensors] callMethod:9 args[2]:
03:02:28 [INFO] [mod_ccSensors] callMethod:2 args[1]:
03:02:28 [INFO] DEBUG] getCustomValue f::Content, obj:ic2.common.TileEntityNucle
arReactor
03:02:28 [INFO] DEBUG] getCustomValue getreactorcontent
03:02:28 [INFO] 0,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 0,1 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 0,2 - 30207:93;item.itemCellUran,1xitem.itemCellUran@93
03:02:28 [INFO] 0,3 - 30207:84;item.itemCellUran,1xitem.itemCellUran@84
03:02:28 [INFO] 0,4 - 30207:76;item.itemCellUran,1xitem.itemCellUran@76
03:02:28 [INFO] 0,5 - 30207:67;item.itemCellUran,1xitem.itemCellUran@67
03:02:28 [INFO] 1,0 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 1,1 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 1,2 - 30207:92;item.itemCellUran,1xitem.itemCellUran@92
03:02:28 [INFO] 1,3 - 30207:84;item.itemCellUran,1xitem.itemCellUran@84
03:02:28 [INFO] 1,4 - 30207:75;item.itemCellUran,1xitem.itemCellUran@75
03:02:28 [INFO] 1,5 - 30207:66;item.itemCellUran,1xitem.itemCellUran@66
03:02:28 [INFO] 2,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 2,1 - 79:0;tile.ice,53xtile.ice@0
03:02:28 [INFO] 2,2 - 30207:91;item.itemCellUran,1xitem.itemCellUran@91
03:02:28 [INFO] 2,3 - 30207:83;item.itemCellUran,1xitem.itemCellUran@83
03:02:28 [INFO] 2,4 - 30207:75;item.itemCellUran,1xitem.itemCellUran@75
03:02:28 [INFO] 2,5 - 30207:66;item.itemCellUran,1xitem.itemCellUran@66
03:02:28 [INFO] 3,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 3,1 - 79:0;tile.ice,53xtile.ice@0
03:02:28 [INFO] 3,2 - 30207:90;item.itemCellUran,1xitem.itemCellUran@90
03:02:28 [INFO] 3,3 - 30207:82;item.itemCellUran,1xitem.itemCellUran@82
03:02:28 [INFO] 3,4 - 30207:74;item.itemCellUran,1xitem.itemCellUran@74
03:02:28 [INFO] 3,5 - 30207:42;item.itemCellUran,1xitem.itemCellUran@42
03:02:28 [INFO] 4,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 4,1 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 4,2 - 30207:89;item.itemCellUran,1xitem.itemCellUran@89
03:02:28 [INFO] 4,3 - 30207:81;item.itemCellUran,1xitem.itemCellUran@81
03:02:28 [INFO] 4,4 - 30207:73;item.itemCellUran,1xitem.itemCellUran@73
03:02:28 [INFO] 4,5 - 30207:41;item.itemCellUran,1xitem.itemCellUran@41
03:02:28 [INFO] 5,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 5,1 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 5,2 - 30207:88;item.itemCellUran,1xitem.itemCellUran@88
03:02:28 [INFO] 5,3 - 30207:80;item.itemCellUran,1xitem.itemCellUran@80
03:02:28 [INFO] 5,4 - 30207:72;item.itemCellUran,1xitem.itemCellUran@72
03:02:28 [INFO] 6,0 - 30207:357;item.itemCellUran,1xitem.itemCellUran@357
03:02:28 [INFO] 6,1 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 6,2 - 30207:87;item.itemCellUran,1xitem.itemCellUran@87
03:02:28 [INFO] 6,3 - 30207:79;item.itemCellUran,1xitem.itemCellUran@79
03:02:28 [INFO] 6,4 - 30207:71;item.itemCellUran,1xitem.itemCellUran@71
03:02:28 [INFO] 6,5 - 30207:40;item.itemCellUran,1xitem.itemCellUran@40
03:02:28 [INFO] 7,0 - 30207:70;item.itemCellUran,1xitem.itemCellUran@70
03:02:28 [INFO] 7,1 - 30207:94;item.itemCellUran,1xitem.itemCellUran@94
03:02:28 [INFO] 7,2 - 30207:86;item.itemCellUran,1xitem.itemCellUran@86
03:02:28 [INFO] 7,3 - 30207:78;item.itemCellUran,1xitem.itemCellUran@78
03:02:28 [INFO] 7,4 - 30207:69;item.itemCellUran,1xitem.itemCellUran@69
03:02:28 [INFO] 7,5 - 30207:40;item.itemCellUran,1xitem.itemCellUran@40
03:02:28 [INFO] 8,0 - 79:0;tile.ice,64xtile.ice@0
03:02:28 [INFO] 8,1 - 30207:93;item.itemCellUran,1xitem.itemCellUran@93
03:02:28 [INFO] 8,2 - 30207:85;item.itemCellUran,1xitem.itemCellUran@85
03:02:28 [INFO] 8,3 - 30207:77;item.itemCellUran,1xitem.itemCellUran@77
03:02:28 [INFO] 8,4 - 30207:68;item.itemCellUran,1xitem.itemCellUran@68
03:02:28 [INFO] 8,5 - 30207:39;item.itemCellUran,1xitem.itemCellUran@39
It basically floods the screen over and over. Here is the LUA code I'm using to call the sensor and the reactor.
-- Description: Nuclear Power Plant Controller
-- Authors: andersevenrud, larsmaehlum
-- URL: https://github.com/andersevenrud/TekkitScripts
--
--
-- NOTES:
--
-- REMEMBER TO FIND OUT WHICH REACTOR IS WHICH (id) THEN
-- CHECK WIRE ASSIGNMENTS BELOW IN CONFIG SECTION
--
-- FOR NON-SMP USAGE (for this configuration):'
-- Set 'coolantTime' to '2'
-- Set 'checkTicks' to '5'
-- Set 'maxHeat' to '2500'
--
-- ALWAYS PLAYS x-configured AMMOUNT OF COOLANT AND 1 FUEL INTO
-- REACTOR(s) BEFORE POWERING ON!
--
-- IF YOU DO NOT USE AUTOSTART AND FORGET TO MANUALLY SHUT-DOWN
-- REACTORS WHEN YOU LOG-OUT/RESTART -- KABOOM!
--
--
--
-- Configuration
--
reactorCount = 2
reactorsEnabled = {1, 2}
pulseTime = 0.4
sleepTime = 0.1
coolantTime = 5
bootAlarmTime = 1.0
fuelTime = 10
checkTicks = 10
buttonTicks = 11
rebootTries = 3
rebootWaitTime = 1.0
maxCoolant = 10
maxFuel = 44
maxSlots = 54
maxHeat = 2000
wlanOn = true
wlanSide = "bottom"
wlanClients = {45}
bundleSide = "back"
buttonSide = "front"
alarmSide = "top"
sensorName = "Sensor"
wireTriggers = {}
table.insert(wireTriggers, {
power = colors.red,
coolant = colors.lime,
fuel = colors.yellow
})
table.insert(wireTriggers, {
power = colors.blue,
coolant = colors.white,
fuel = colors.black
})
--
-- Internal variables
--
_debugOn = false -- Debug mode, cmd argument
_dryRun = false -- Don't send any signals, cmd argument
_lockStation = false -- Lock control-keys, cmd argument
_ctrl = sensors.getController() -- Sensor controller
_reactorStatus = {} -- Reactor statuses, see below
_argv = { ... }
-- Item names we will deal with
local m_name_ucell = "item.itemCellUran";
local m_name_dcell = "item.itemCellUranEmpty";
local m_name_ice = "tile.ice";
for i = 1, reactorCount do
table.insert(_reactorStatus, {
info = {},
contents = {},
state = false,
overHeated = false,
rebootTries = 0,
coolantTime = 0,
fuelTime = 0
})
end
--
-- Helper functions
--
function inArray(k, o)
local found = false
for re = 1, #o do
if o[re] == k then
found = true
break
end
end
return (found)
end
function dprint(msg)
print(string.format("%-6s %s", textutils.formatTime(os.time(), true), msg))
end
function cprint(msg, y)
term.setCursorPos(1, y)
term.clearLine()
print(msg)
end
function parseCmd()
local _l = nil
for i = 1, #_argv do
local _v = _argv[i]
if (i % 2) == 1 then
_l = _v
else
if _l == "-dryRun" then
if _v == "true" then
_dryRun = true
else
_dryRun = false
end
elseif _l == "-lockStation" then
if _v == "true" then
_lockStation = true
else
_lockStation = false
end
elseif _l == "-debugOn" then
if _v == "true" then
_debugOn = true
else
_debugOn = false
end
end
end
end
end
function clearScreen()
term.clear()
term.setCursorPos(1, 1)
end
--
-- Networking
--
function sendMessage(client, message)
if wlanOn then
if type(client) == "table" then
for i = 1, #client do
rednet.send(tonumber(client[i]), message)
end
else
rednet.send(tonumber(client), message)
end
end
end
function startNetwork()
if wlanOn then
rednet.open(wlanSide)
end
end
function stopNetwork()
if wlanOn then
rednet.close(wlanSide)
end
end
--
-- Reactor functions
--
function getReactorInfo(id)
local p = "Reactor"
local t = sensors.getAvailableTargetsforProbe(_ctrl, sensorName, p)
local d = nil
if t and t[id] then
d = sensors.getSensorReadingAsDict(_ctrl, sensorName, t[id], p)
end
if type(d) ~= "table" or (type(d.output) == "nil") then
d = {
heat = 0,
size = 0,
addedToEnergyNet = false,
lastOutput = 0,
output = 0
}
end
return (d)
end
function getReactorContents(id)
local contents = {
coolant = 0,
fuel = 0,
depleted = 0
}
local p = "ReactorContent"
local t = sensors.getAvailableTargetsforProbe(_ctrl, sensorName, p)
if type(t) == "table" and t[id] then
local d = sensors.getSensorReadingAsTable(_ctrl, sensorName, t[id], p)
for i = 1, #d do
local ii = d[i]
if string.match(ii, "m_name_ice") then
contents.coolant = contents.coolant + 1
elseif string.match(ii, "m_name_dcell") then
contents.depleted = contents.depleted + 1
elseif string.match(ii, "m_name_ucell") then
contents.fuel = contents.fuel + 1
end
end
end
return (contents)
end
function stopReactors()
for i = 1, #reactorsEnabled do
stopReactor(reactorsEnabled[i])
end
end
function startReactors()
for i = 1, #reactorsEnabled do
startReactor(reactorsEnabled[i])
end
end
function startReactor(id)
if not checkReactorState(id) then
dprint(string.format("STARTING REACTOR #%d", id))
sendPulse(wireTriggers[id].power)
end
end
function stopReactor(id, heat)
if checkReactorState(id) then
if _started then
if heat then
dprint(string.format("OVERHEATING!!! STOPPING REACTOR #%d", id))
else
dprint(string.format("STOPPING REACTOR #%d", id))
end
end
sendPulse(wireTriggers[id].power)
if heat then
os.sleep(rebootWaitTime)
end
end
end
function checkReactorState(id, info)
if not info then
info = getReactorInfo(id)
end
if info then
if info.output > 0 then
return (true)
end
end
return (false)
end
function _pollReactorCoolant(d, i, id)
local count = 0
if d.coolant < maxCoolant then
count = maxCoolant - d.coolant
end
return (count)
end
function _pollReactorFuel(d, i, id)
local count = 0
if d.fuel < maxFuel then
count = maxFuel - d.fuel
end
return (count)
end
function pollReactor(id, runcheck, tick)
local i = getReactorInfo(id)
local d = getReactorContents(id)
local e = checkReactorState(id, i)
local c = nil
local r = true
_reactorStatus[id].info = i
_reactorStatus[id].contents = d
_reactorStatus[id].state = e
-- Skip if not enabled
if not inArray(id, reactorsEnabled) then
return (r)
end
if _debugOn then
dprint("Polling #"..id)
end
if not _dryRun and runcheck then
local total = (d.coolant + d.fuel + d.depleted)
local full = total >= maxSlots
if e then
-- Check contents
if tick >= checkTicks then
if not full then
c = _pollReactorCoolant(d, i, id)
if c > 0 then
pushCoolant(id, c)
r = false
end
c = _pollReactorFuel(d, i, id)
if c > 0 then
pushFuel(id, c)
r = false
end
end
end
-- Check environment
if i.heat > maxHeat then
soundAlarm()
stopReactor(id, true)
r = false
_reactorStatus[id].overHeated = true
else
stopAlarm()
_reactorStatus[id].overHeated = false
end
_reactorStatus[id].rebootTries = 0
else
-- Check environment
if _reactorStatus[id].overHeated == true and (_reactorStatus[id].rebootTries <= rebootTries) then
startReactor(id)
r = false
if checkReactorState(id) then
_reactorStatus[id].overHeated = false
stopAlarm()
else
_reactorStatus[id].rebootTries = _reactorStatus[id].rebootTries + 1
end
end
end
end
return (r)
end
--
-- External Systems functions
--
function checkWire(color)
return
end
function sendPulse(color, stimeout, etimeout)
if not stimeout then stimeout = pulseTime end
if not etimeout then etimeout = pulseTime end
if not _dryRun then
redstone.setBundledOutput(bundleSide, 0)
os.sleep(stimeout)
redstone.setBundledOutput(bundleSide, color)
os.sleep(etimeout)
end
end
function pushCoolant(id, count)
if not count then count = 1 end
if not (_reactorStatus[id].coolantTime > os.clock()) then
for i = 1, count do
dprint(string.format("PUSH COOLANT %d/%d REACTOR #%d", i, count, id))
sendPulse(wireTriggers[id].coolant)
end
_reactorStatus[id].coolantTime = os.clock() + coolantTime
return (true)
end
return (false)
end
function pushFuel(id, count)
if not count then count = 1 end
if not (_reactorStatus[id].fuelTime > os.clock()) then
for i = 1, count do
dprint(string.format("PUSH FUEL %d/%d REACTOR #%d", i, count, id))
sendPulse(wireTriggers[id].fuel)
end
_reactorStatus[id].fuelTime = os.clock() + fuelTime
return (true)
end
return (false)
end
function soundAlarm(timeout)
rs.setOutput(alarmSide, true)
if timeout then
os.sleep(timeout)
stopAlarm()
end
end
function stopAlarm()
rs.setOutput(alarmSide, false)
end
--
-- Main program
--
local sx, sy = term.getSize()
local starty = (reactorCount + 3)
local running = true
local pause = false
local inited = false
local refresh = true
local lxpos = 1
local lypos = starty
local ctick = 0
local btick = 0
local bstate = 0
-- 1: Bootup
startNetwork()
clearScreen()
parseCmd()
stopReactors()
stopAlarm()
if _lockStation then
os.pullEventRaw = os.pullEvent
end
-- 2: Main loop
while running do
-- 2.1.1: Display header
if refresh then
term.clear()
term.setCursorPos(1, 1)
print(string.format("! C:%02d F:%02d S:%02d | H:%04d O:---- | DRY:%s", maxCoolant, maxFuel, maxSlots, maxHeat, tostring(_dryRun)))
refresh = false
end
-- 2.1.2: Handle last status and display statuses
if inited then
sendMessage(wlanClients, textutils.serialize(_reactorStatus))
for c = 1, reactorCount do
local d = _reactorStatus[c].contents
local i = _reactorStatus[c].info
local e = _reactorStatus[c].state
local msg = string.format("#%d C:%02d F:%02d D:%02d | H:%04d O:%04d | ON:%s", c, d.coolant, d.fuel, d.depleted, i.heat, i.output, tostring(e))
cprint(msg, 1 + c)
end
end
cprint("-------------------------------------------------", (reactorCount + 2))
term.setCursorPos(lxpos, lypos)
-- 2.2: Perform system operations (won't do anything unless on-line)
for i = 1, reactorCount do
pause = pollReactor(i, (bstate > 0), ctick) or pause
end
if pause then
os.sleep(sleepTime)
end
-- 2.3: Check input button(s)
if btick > 0 then
btick = btick - 1
else
if rs.getInput(buttonSide) then
btick = buttonTicks
if bstate == 1 then
running = false
dprint(">>> SAFE SHUTDOWN :-) <<<")
break
elseif bstate == 0 then
soundAlarm(bootAlarmTime)
startReactors()
end
bstate = bstate + 1
end
end
-- 2.4: Check display overflow and prepare for next tick
lxpos, lypos = term.getCursorPos()
if (lypos >= sy) then
lypos = starty
refresh = true
end
ctick = ctick + 1
if ctick > checkTicks then
ctick = 0
end
pause = false
inited = true
end
-- 3: Shutdown
stopReactors()
stopNetwork()
stopAlarm()
Basically I want this to stop spamming the server all berserk style and clean it up some. Any ideas?