Posted 14 March 2014 - 01:00 PM
hi guys, firs sorry for my english xD.. this Its my secos program and this control my first program to emir redstone signal to start my dynamos(TE3).. i cant see the problem.. i know other lengueges like pawn and visual c# and I trying to learn lua.. I think anyone can help in my mistakes
thanks for read! :3
Edit: the problem Is in setNumDynamo and i Can't solve this
function setNumDynamo(num)
if num < 0 then
num = 0
elseif num > MaxDynamo then
num = MaxDynamo
end
peripheral.call(ModemPoss, "transmit", DefaultChannel, DefaultChannel, tostring(num))
return num
end
function getAmmoutEnergy()
return DynamosActive * EnergyPerTick
end
function getModemPoss()
for x, pName in ipairs(peripheral.getNames()) do
if peripheral.getType(pName) == "modem" then
return(pName)
end
end
end
function setRestartEngine()
peripheral.call(ModemPoss, "transmit", DefaultChannel, RestartID, "")
end
local DefaultChannel = 1
local RestartID = 2707
local MaxDynamo = 130
local EnergyPerTick = 80
local ModemPoss = getModemPoss()
local DefaultDynamos = 42
sleep(5)
setNumDynamo(DefaultDynamos)
local Command = ""
local szOutput = { "", "$: Update Complete", "$: Dynamos Updates Complete", "$: ReBoot Complete", "$: Unknow Command" }
local aOutput = { aEmpty = 1, aUpdate = 2, aDyUpdate = 3, aReBoot = 4, aUnkCommand = 5 }
local OutputIndex = aOutput["Empty"]
local DynamosActive = DefaultDynamos
while true do
term.clear()
term.setCursorPos(1, 1)
print("Dynamos funcionando: " ..tostring(DynamosActive))
term.setCursorPos(1, 3)
print("Energia Producida: " ..tostring(getAmmoutEnergy()) .."RF/t")
term.setCursorPos(1, 6)
print(szOutput[OutputIndex])
term.setCursorPos(1, 5)
term.write("$Rak$/: ")
Command = read()
if string.find(Command, "set") then
DynamosActive = setNumDynamo(tonumber(string.sub(Command, 4)))
OutputIndex = aOutput["aDyUpdate"]
elseif Command == "Update" then
setRestartEngine()
sleep(3)
setNumDynamo(DynamosActive)
OutputIndex = aOutput["aUpdate"]
elseif Command == "reboot" then
DynamosActive = setNumDynamo(DefaultDynamos)
OutputIndex = aOutput["aReBoot"]
else
OutputIndex = aOutput["aUnkCommand"]
end
end
thanks for read! :3
Edit: the problem Is in setNumDynamo and i Can't solve this
Edited on 14 March 2014 - 01:52 PM