<commit_before>require 'scheduler'
require 'keys'
require 'gui/gui'

function version()
    message( 'Game Engine Testbed %3v0.2%r\nOgre 3d %3v1.7.2%r\nLua %3v5.1.4%r\nLuabind %3v0.9git%r' )
end

local old_dofile = dofile
function dofile( f )
    if f == nil then
        print 'stdin dofile tomfoolery not availible.'
        return
    end
    old_dofile( f )
end

function EventNotification( event )
    --print "Scripting System Received an Event"

    if event.type == Event.hash "EVT_KEYDOWN"  then
        if event.data.key == KeyCodes.KC_ESCAPE and #gui.modal == 0 then
            quit()
            return true
        end
    end

    if event.type == Event.hash "EVT_WINDOW_RESIZE" then
        setViewportSize( event.data.width, event.data.height )
        if type(resizeEventListen) == 'table' then
            table.foreach( resizeEventListen,
            function(k,v)
                v( event.data.width, event.data.height )
            end
            )
        end
    end

    if event.type == Event.hash "EVT_MOUSEMOVE" then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.hash "EVT_MOUSEDOWN" then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.hash "EVT_MOUSEUP" then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.hash "EVT_KEYDOWN" then
        keypressed( event.data.key )
    end<commit_msg>Cache hashes for often compared Event types.<commit_after>require 'scheduler'
require 'keys'
require 'gui/gui'

function version()
    message( 'Game Engine Testbed %3v0.2%r\nOgre 3d %3v1.7.2%r\nLua %3v5.1.4%r\nLuabind %3v0.9git%r' )
end

local old_dofile = dofile
function dofile( f )
    if f == nil then
        print 'stdin dofile tomfoolery not availible.'
        return
    end
    old_dofile( f )
end

-- Cache hash values.
Event.keydown = Event.hash "EVT_KEYDOWN"
Event.mousemove = Event.hash "EVT_MOUSEMOVE"
Event.mousedown = Event.hash "EVT_MOUSEDOWN"
Event.mouseup = Event.hash "EVT_MOUSEUP"
Event.windowresize = Event.hash "EVT_WINDOW_RESIZE"

function EventNotification( event )
    --print "Scripting System Received an Event"

    if event.type == Event.keydown  then
        if event.data.key == KeyCodes.KC_ESCAPE and #gui.modal == 0 then
            quit()
            return true
        end
    end

    if event.type == Event.windowresize then
        setViewportSize( event.data.width, event.data.height )
        if type(resizeEventListen) == 'table' then
            table.foreach( resizeEventListen,
            function(k,v)
                v( event.data.width, event.data.height )
            end
            )
        end
    end

    if event.type == Event.mousemove then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.mousedown then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.mouseup then
        mouseMoved( event.data.x, event.data.y, event.data.buttons )
    end

    if event.type == Event.keydown then
        keypressed( event.data.key )
    end
{'fraction_non_alphanumeric': 0.10366426558095834, 'fraction_numerical': 0.010021922956467273, 'mean_word_length': 2.348008385744235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4578418', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1074, 'n_words': 265}