Jump to content




Program Error


  • You cannot reply to this topic
5 replies to this topic

#1 TheBlueKingLP

  • Members
  • 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

Attached Thumbnails

  • Attached Image: Screen Shot 2016-02-02 at 5.17.37 PM.png


#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

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 by Lupus590, 02 February 2016 - 12:01 PM.


#3 TheBlueKingLP

  • Members
  • 21 posts

Posted 03 February 2016 - 08:16 AM

what does that mean?
how to fix?

#4 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

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


#5 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 04 February 2016 - 11:10 PM

View PostLupus590, on 03 February 2016 - 01:48 PM, said:

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.

#6 TheBlueKingLP

  • Members
  • 21 posts

Posted 05 February 2016 - 05:44 AM

ok,thx





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users