Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

TheREALtigR

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by TheREALtigR

  1. Forgive my lack of competence with lua and programming in general.

    I am trying to display information about my power systems ** in the centre of a 5x1 screen and I am struggling to achieve this without simply setting the text at a position on the screen, and I would much rather have the centre of the text string centered on 'width/2' and 'height/2' as the power level updates every 0.1 second and the string is different lengths in each update.

    **

    while true do
    	
    	energy = bank.getEnergyStored(4)
    	capacity = bank.getMaxEnergyStored(4)
    	
    	percentcalc = (energy / capacity) * 100
    
    	digits = 1
    	shift = 10 ^ digits
    	percent = math.floor(percentcalc*shift + 0.5) / shift
    
    	term.clear()
    
    	print("Power = "..energy.."/"..capacity.." (RF) - "..percent.."%"
    
    	os.sleep(0.1)
    
    end

    Thanks for any help

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.