Change image using the system clock

I am trying to make a clock using 6 textures on 6 planes one each for the hh mm ss, I am using uv animator to shift a tiled image around, the tiled image in this instance being the last tile is the seconds counter, has 10 tiles from 0-9
my script works but I am taking the time as a string and I need it split it into 2 integers, one for each of the “ss” textures.

I know I can do this with guitext but I want to use my images.

I think this something like what I need, I need to convert the hh, mm, and ss, into single numbers to insert in the vector position

import System;

var date = DateTime.Now;

InvokeRepeating("Start", 2, 0.10);


function Start () {
    
    
    var TheHours = System.DateTime.Now.ToString("HH"); 
    var TheMinutes = System.DateTime.Now.ToString("MM"); 
    var TheSeconds = System.DateTime.Now.get_Second(); 
    var TheMonth = System.DateTime.Now.get_Month(); 
    var TheDay = System.DateTime.Now.get_Day(); 
    var TheYear = System.DateTime.Now.get_Year(); 
    
    //guiText.text = ""TheSeconds;
    
    var uvAnimationTileX = 10; //columns per sheet.
    var uvAnimationTileY = 1; //rows per sheet

.



    // Calculate index
    // This works but calls the seconds as an integer,
    //I really need to extract is as a string and split it into 2 integers like this
    //var index : int = minutesa; //minutesa is the first digit in TheSeconds script
    var index : int = TheSeconds;  //Time.time * framesPerSecond;
    
    // Size of every tile
    var size = Vector2 (1.0 / uvAnimationTileX, 1.0 / uvAnimationTileY);
    
    // split into horizontal and vertical index
    var uIndex = index % uvAnimationTileX;
    var vIndex = index / uvAnimationTileX;

    // build offset of the tile size
    // v coordinate is the bottom of the image in opengl so we need to invert.
    var offset = Vector2 (uIndex * size.x, 1.0 - size.y - vIndex * size.y);
    
    renderer.material.SetTextureOffset ("_MainTex", offset);
    renderer.material.SetTextureScale ("_MainTex", size);
}

http://pastie.org/2214123.js

You have it, for example System.DateTime.Now.get_Second() will give you a number (not a string representing a number, like ar TheMinutes = System.DateTime.Now.ToString(“MM”) does. So just don’t ‘to string’ them.

To turn a 2-digit integer into 2 one-digit integers, do:

var tens = TheSeconds / 10;
var units = TheSeconds % 10;

Note that your code shouldn’t compile with InvokeRepeating up there like that, Nor should you be trying to call Start anyway. Just put all that code inside Start and yield for 0.1 seconds inside the loop:

function Start
{
    while (true) {
        UpdateTheDisplayHere
        yield WaitForSeconds(0.1);
    }
}

Of course, you also need to do all digits, not just seconds.