Topic: A few questions

Hey guys,

So, I created a game in which the graphics were made entirely separate from the scripts. All of the basic scripts were created inside of a test environment. They work in that area.
Now, however, when I have applied the scripts to the larger level (which has roughly 400 objects), there are certain areas that nonsensically just don't work. I'm thinking it has something  to do with the amount objects inside of the level. If it is necessary to  split the area up into different levels, then it is fine to do so.
Although, is there something I should be doing differently as far as object properties/code?

    if (isKeyPressed('UP')) then
        offset = offset < 3 and offset + 0.2 or offset
        setBehaviorVariable(camera, 1, 'offset', {0, 7, 2 + offset})
    if (isKeyPressed('DOWN')) then
        offset = offset > -3 and offset - 0.2 or offset
        setBehaviorVariable(camera, 1, 'offset', {0, 7, 2 + offset})

this area used to work fine, but for some reason it hates the down key now. When I press the down key, Maratis freezes, returns errors of certain objects not existing (as a result of it freezing), and forces me to exit the program.
I can even comment out the up key section entirely and it simply just hates the down key

Another area:
    if (isKeyPressed('SPACE')) then
        if (coll > 1) then
            addCentralForce(player, {0, 0, 20})
            changeAnimation(playerMesh, 2)

this makes the program not be able to present any kind of recognition to pressing keys and freezes, but i can still hit esc.
the game throws the error for the line if(coll >1)then

Re: A few questions

coll is defined as
local coll  = getNumCollisions(playerFeet)
it throws the attempt to compare with nil error.

Re: A few questions

What is inside or outside of the game loop?

Re: A few questions

Everything except:

local player     = getObject('PlayerObj')
local playerMesh= getObject('Player')
local playerFeet= getObject('PlayerFeet')

local camera    = getObject('Camera0')
local camera1   = getObject('Camera1')
local offset    = 0

local terrain   = getObject('Terrain')
local toggle    = 2
local damage    = 10
local crit      = damage * 2.2
local k0k       = {}
local k9k       = {}


linearSearch    = function(t, x)
    for _,v in next,t do
        if (v == x) then return _ end
    return false