Posted 27 July 2015 - 02:45 PM
Minecraft version : 1.7.10
Forge version : 10.13.4.1448
Computercraft version : 1.74
OpenPeripheralAddons version : 0.3.1
Hello world !
I work on HUD with OpenP. Addons and Terminal Glasses, it's quite similar to the Plastic Program made by 1lann, but I wanted to do it myself but I would summon your help because I'm stuck when i'm trying to center a text, the function worked perfectly with the previous version of Computercraft and OpenMods, but nowadays the sync() function disturbs me.
I know how to center a text :
The main box is 110px wide.
There is 10px between the border of the screen and the beginning of the main box.
Here an image to explain my problem :
http://gyazo.com/cd0...64d059ef516c991
I have this function to center the text :
I know I have to multiply the 'MidText' by a number but I don't know which one.
I've also tried to use the same function as 1lann but it didn't works anymore with this version :
His code :
Modified, to match with mine (works with OpenP.Addons 0.2.0 snapshot):
Forge version : 10.13.4.1448
Computercraft version : 1.74
OpenPeripheralAddons version : 0.3.1
Hello world !
I work on HUD with OpenP. Addons and Terminal Glasses, it's quite similar to the Plastic Program made by 1lann, but I wanted to do it myself but I would summon your help because I'm stuck when i'm trying to center a text, the function worked perfectly with the previous version of Computercraft and OpenMods, but nowadays the sync() function disturbs me.
I know how to center a text :
math.ceil((BoxLengh/2) - (TextLengh/2))
The main box is 110px wide.
There is 10px between the border of the screen and the beginning of the main box.
Here an image to explain my problem :
http://gyazo.com/cd0...64d059ef516c991
I have this function to center the text :
function centerText(text, object)
object.setText("")
object.setText(text)
local MidText = text:len()/2
local PosX = 65 - MidText
print(MidText)
object.setX(PosX)
Glasses.sync()
end
I know I have to multiply the 'MidText' by a number but I don't know which one.
I've also tried to use the same function as 1lann but it didn't works anymore with this version :
His code :
math.ceil(((136/2)-(plastic.getStringWidth(text)*(0.65)/2))+20-0.5)
Modified, to match with mine (works with OpenP.Addons 0.2.0 snapshot):
((110/2 -10)-(Glasses.getStringWidth(text))*(0.65)/2))+20-0.5
Edited on 31 July 2015 - 08:53 PM