21 posts
Posted 02 February 2016 - 09:18 AM
how to fix this program error?
here is the code
monitor = peripheral.wrap("back")
while true do
monitor.setCursorPos(2,2)
monitor.write("Storage:")
monitor.setCursorPos(2,3)
monitor.write( getEnergyStored(draconic_rf_storage) getMaxEnergyStored(draconic_rf_storage) )
sleep(0.1)
end
2427 posts
Location
UK
Posted 02 February 2016 - 11:56 AM
the problem is this line
monitor.write( getEnergyStored(draconic_rf_storage) getMaxEnergyStored(draconic_rf_storage) )
you need to combine the two results as strings you do this like so:
monitor.write( tostring(getEnergyStored(draconic_rf_storage)).."/"..tostring(getMaxEnergyStored(draconic_rf_storage)) )
tostring is a function which will convert the number that is returned by you other function to a string so that it can be printed to the monitor
.. combines two strings
"/" just some formatting in the string to separate the two values
another things to note, I'm fairly sure that you are using your draconic_rt_storage incorrectly, it should be more like a peripheral (like you did with the monitor)
Edited on 02 February 2016 - 11:01 AM
21 posts
Posted 03 February 2016 - 08:16 AM
what does that mean?
how to fix?
2427 posts
Location
UK
Posted 03 February 2016 - 01:48 PM
local engCell = peripheral.find("draconic_rf_storage")
local monitor = peripheral.wrap("back")
monitor.setCursorPos(2,2)
monitor.write("Storage:")
while true do
monitor.setCursorPos(2,3)
monitor.write( engCell.getEnergyStored().."/".. engCell.getMaxEnergyStored() )
sleep(0.1)
end
957 posts
Location
Web Development
Posted 04 February 2016 - 11:10 PM
local engCell = peripheral.find("draconic_rf_storage")
local monitor = peripheral.wrap("back")
monitor.setCursorPos(2,2)
monitor.write("Storage:")
while true do
monitor.setCursorPos(2,3)
monitor.write( engCell.getEnergyStored().."/".. engCell.getMaxEnergyStored() )
sleep(0.1)
end
You might want to clear the line, if the energy drops from full, you will still have digits left from previous writes.
Also, I would recommend sleeping for at least a second, no reason to update too quickly.
21 posts
Posted 05 February 2016 - 05:44 AM
ok,thx