Posted 24 April 2014 - 10:40 AM
Hello fellow computercrafters
I'm back with another roadblock that i'd love to get some assistance with.
I'm quite new to lua, so please forgive if my requets are silly.
So i'm making a program that does energy readings on my capacitor bank (enderio) and submits it to a monitor.
This is the code i'm using to write my data onto the monitor: (If you see something silly, and/or any easier way to do this please let me know)
The message["energyMax"] = getMaxEnergyStored() on the capacitor bank
So the problem is that the "energy" can go up and down and i've made it so it will round it and give it 1 decimal.
So it goes from 90M to ie. 85.7M
Which will make the text go outside of my "Box" where my stats are written.
so my box looks like this everything inside the "box" has a different backgorund color then the rest of the program.
Sorry for my sketchy drawings, hope it makes it clear what i'm trying to do.
What i was thinking is that i could somehow m ake it read the string length in the "message["energy"]" and then set the cursor pos accordingly.
ie.
I'm back with another roadblock that i'd love to get some assistance with.
I'm quite new to lua, so please forgive if my requets are silly.
So i'm making a program that does energy readings on my capacitor bank (enderio) and submits it to a monitor.
This is the code i'm using to write my data onto the monitor: (If you see something silly, and/or any easier way to do this please let me know)
if id == 5 then --3 is the Id of the main pc
mon.setBackgroundColor(outputBgC)
mon.setTextColor(outputTxtC)
mon.setCursorPos(1,4)
mon.write(" ")
mon.setCursorPos(1,4)
mon.write("Stored: "..round(message["energy"]/1000000, 1).."M")
mon.setCursorPos(1,5)
mon.write(" ")
mon.setCursorPos(1,5)
mon.write("Max: "..round(message["energyMax"]/1000000, 1).."M")
mon.setCursorPos(1,6)
mon.write(" ")
mon.setCursorPos(1,6)
mon.write("Percent: "..round(message["energy"]/message["energyMax"]*100, 1).."%")
mon.setCursorPos(1,7)
mon.write(" ")
mon.setCursorPos(1,8)
mon.write(" ")
mon.setCursorPos(1,9)
mon.write(" ")
mon.setCursorPos(1,10)
mon.write(" ")
end
The message["energy"] = getEnergyStored() on the capacitor bankThe message["energyMax"] = getMaxEnergyStored() on the capacitor bank
So the problem is that the "energy" can go up and down and i've made it so it will round it and give it 1 decimal.
So it goes from 90M to ie. 85.7M
Which will make the text go outside of my "Box" where my stats are written.
so my box looks like this everything inside the "box" has a different backgorund color then the rest of the program.
Sorry for my sketchy drawings, hope it makes it clear what i'm trying to do.
What i was thinking is that i could somehow m ake it read the string length in the "message["energy"]" and then set the cursor pos accordingly.
ie.
if message["energy"] string length == 5 then
mon.setCursorPos(7,2)
mon.write(message[energy])
if message["energy"] string legnth == 3 then
mon.setCursorPos(5,2)
mon.write(message[energy])
This is just an example. :)/>Edited on 24 April 2014 - 08:55 AM