@name W64-Processor
@inputs Game Graphic:entity Sound:entity Interface:entity
@inputs TurnOn 
@outputs E:entity On GameOut Thi 
@persist GTABLE:gtable
@trigger 
@model models/expression 2/cpu_processor.mdl

if (first() | duped()){
    E = entity()
    E["Sound", entity] = Sound
    E["Graphic", entity] = Graphic
    E["Interface", entity] = Interface
    Version = "0.0.1" # version?
    Graphic["Ver",string] = Version
    
    GTABLE = gTable("CONSOLE_CAKE",1) 
}

if (TurnOn && ~TurnOn){
    On = 1
    E["On", number] = 1
}
if (!TurnOn && ~TurnOn){
    On = 0
    E["On", number] = 0
}

if (Game > 0){
    E["Game", number] = Game
    Thi = 1
    GameOut = E:id()
}

if (Game <= 0){
    GameEnt = entity(E["Game", number])
    GameEnt["Started", number] = 0
    E["Game", number] = 0
    Thi = 0
    GameOut = 0
    if (On){
        On = 0
       timer("Reset", 100)
    }
}

if (clk("Reset")){
    On = 1
}

