1522 posts
Location
The Netherlands
Posted 14 January 2013 - 09:47 AM
function printScreen()
clear()
print("=======================================")
print("= Status: "..state.." =")
print("---------------------------------------")
print("= Wood collected: "..wood.." =")
print("= Saplings left: =")
print("= Bone Meal left: =")
print("=======================================")
end
The status things works correctly since there is only 1 string length.
The problem that I am having is that if the string wood is more than 1 character, my whole UI is screwed up. Im planning to do something similair with saplings and bonemeal (not have gotten to write that part, thats why there are no variables) only there it goes from 3 characters to 1 and that screws it up to.
thanks in advance,
Engineer
I love to see the codes you guys eventually will post and I thank you for that :)/>
NOTE: sorry if this is common, I didnt saw another thread about this
504 posts
Location
Seattle, WA
Posted 14 January 2013 - 10:22 AM
You'll have to compute the number of spaces between the end of the line which ends with an equals sign.
Assuming that the equals sign will be located at the position (37, 4), you could subtract the length of the amount of wood as a string plus 17 from 37 to calculate how many spaces you will need to make the UI even.
17 is the number of characters between the start of the line and where you're printing the amount of wood collected.
function printScreen()
clear()
print("=======================================")
print("= Status: "..state.." =")
print("---------------------------------------")
print("= Wood collected: "..wood.. string.rep(' ', 37 - (tostring(wood):len() + 17))'=')
print("= Saplings left: =")
print("= Bone Meal left: =")
print("=======================================")
end
2088 posts
Location
South Africa
Posted 14 January 2013 - 10:47 AM
You could also do this if the above makes no sense,
just get the right co-ords
function printScreen()
clear()
print("=======================================")
print("= Status: "..state.." =")
print("---------------------------------------")
print("= Wood collected: =")
print("= Saplings left: =")
print("= Bone Meal left: =")
print("=======================================")
term.setCursorPos(19, 4)
write(wood)
end