Posted 04 September 2013 - 06:43 PM
Hello, I spent today learning Lua in order to write a program that would manage a list of tasks and display them one at a time on an advanced monitor,e.g., "Build an oil refinery!" "Breed industrious bees!" The only part I've had trouble with is formatting the string for display on the monitor so that the lines break naturally. It's much more complicated than I thought it would be and I'm stumped!
The advanced monitor is three blocks wide and two blocks tall. The text scale on the monitor is set to 1.5. The top text row is taken by a title bar and the bottom three text rows taken by buttons, so I want to be able to display a task in the four intermediate text rows. I'm storing the task as a particular string in an array of strings (let's say, taskList[currentTask]). I was hoping someone could help me write a function that writes the string on the four lines so that the lines break between words (the lines are 19 columns long except for the first, which has three initial characters for the task number, a period, and a space so only 16 columns for the task). I'm having trouble figuring out Lua's string library, so would be very grateful for any ideas on how to do this!
The advanced monitor is three blocks wide and two blocks tall. The text scale on the monitor is set to 1.5. The top text row is taken by a title bar and the bottom three text rows taken by buttons, so I want to be able to display a task in the four intermediate text rows. I'm storing the task as a particular string in an array of strings (let's say, taskList[currentTask]). I was hoping someone could help me write a function that writes the string on the four lines so that the lines break between words (the lines are 19 columns long except for the first, which has three initial characters for the task number, a period, and a space so only 16 columns for the task). I'm having trouble figuring out Lua's string library, so would be very grateful for any ideas on how to do this!