19 posts
Posted 02 December 2013 - 04:25 PM
Hello, im trying to fix this program or find a better solution. I want to read many MFSU's and it seems i cant even read one. this program is a friends program, but Im trying to use with the MFSU's which he says it will. I cant seem to find the error. not sure wha it is.
758 posts
Location
Budapest, Hungary
Posted 02 December 2013 - 05:30 PM
Is it just me, or is the buggy-code vs. given-explanation rate really way above 10?
19 posts
Posted 02 December 2013 - 05:43 PM
If i made something confusing sorry…but all I need is to read multiple MFSU's and print to a monitor. Like I said, the program i posted is a friends…not mine. He said it could be used to read many MFSU's but its not working.
8543 posts
Posted 02 December 2013 - 05:46 PM
What steps have you taken so far to debug it? Is it throwing any errors?
19 posts
Posted 02 December 2013 - 06:01 PM
I have tried to rearrange the code, remove, change the line that the computer was saying was wrong. I dont have the error on hand because im trying to rewrite the code shorter. However, the line of code it had an issue with was this->
info["stored"] = bb.getStored()
anything that would help me better unstand this would be great. I would like to learn to do this myself but I tend to learn from programs, examples and so on. I have written this code so far which is this..
local mon = peripheral.wrap('monitor_9')
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.yellow)
mon.setCursorPos(1,1)
mon.setTextScale(1)
mon.clear()
local mFSU = peripheral.wrap("batbox_13")
local intInfo = mFSU.getStored()
mon.write(intInfo)
This code works but doesnt update, and only reads one MFSU.
91 posts
Posted 02 December 2013 - 07:07 PM
info["stored"] = bb.getStored()
.getStored() is a method for getting the amount of energy stored.
info["stored"] takes this information and puts it into a table.
As for having your code update, you need to put it into a loop. For example:
while true do
--do stuff
sleep(5)
end
This loop will keep repeating itself continuously and wait five seconds after each time it runs. It may be better to look into using an event to tell it to update however, so your program wont be running non stop even if there is nothing to report.