@name Chat Spy
@inputs Screen1:wirelink On Screen2:wirelink Up1 Down1 Up2 Down2
@outputs C Count
@persist History:array C
@trigger 
runOnChat(1)
if(first()){
    C=1
    History=array()
}
if(On){
    Up=Up1|Up2
    Down=Down1|Down2
    End="                                                                                                                            "
    Count=History:count()
    timer("count",500)
    if(clk("count")){
        C=clamp(C+(Up-Down),0,History:count())
    }
    Message=lastSpoke():name()+": "+lastSaid()+End
    if(chatClk()){
        Screen1["Reset",number]=1
        Screen2["Reset",number]=1
        Screen1["Reset",number]=0
        Screen2["Reset",number]=0
        History:pushString(Message)
    }
    timer("delay",50)
    if(clk("delay")){
    
        Screen1:writeString(Message,0,0)
        Screen2:writeString(History[C,string],0,0)
    }
}
if(!On){
Screen1["Reset",number]=0
Screen2["Reset",number]=0
}
