InitScene = function()
end

OnMouseMove = function()
end

OnMouseDown = function(item_name)
end

function PostGameMessage( msg )
end

function DelayedExec(timeout, func, group)
    group = group or 1;
    local anim = {time = timeout * 1000, onFunction = func}
    AddRequest(anim, group)
end

function DelayedExecStr(timeout, func, group)
    group = group or 1;
    local anim = {time = timeout * 1000, onFunction = loadstring(func)}
    AddRequest(anim, group)
end

function table_size(array)
	counter = 0;
	for key, value in pairs(array) do
		counter = counter + 1;	
	end
	
	return counter;
end

function random(value)
    math.randomseed(GetTimer() * 1000)
    return math.random(value)
end

function EffectorPlay(eff, name, loop, group)
     assert(eff and name)
     loop = loop or false;
     group = group or 1;
     EffectorStart(eff, name, loop, group);
end

function RemoveGFX(screen, gfx_id)
    cpp_remove_GFX(screen.name, gfx_id)
end

function CreateZoneParticles(screen, zoneName, particlesName, pos_x, pos_y)
    local pos_x = pos_x or 0;
    local pos_y = pos_y or 0;
    
	local id = cpp_create_GFX(screen:GetName(), particlesName, 0, 0, 130)
	cpp_attach_GFX(screen:GetName(), id, zoneName, 1, pos_x, pos_y, false)

	local itemw = ItemGetWidth(zoneName);
	local itemh = ItemGetHeight(zoneName);
	local w = itemw / 4
	local h = itemh / 4

	cpp_adjust_GFX(screen:GetName(), id, {rect = {-w, -h, w, h}})
	
	cpp_set_layer_depth_GFX(screen:GetName(), PARTICLE_ACTIVE_ZONE_ID, zoneName, 1);
	
	return id;
end

function SetState(par1, par2, par3)
    if(type(par1) == "string" and type(par2) == "string" and type(par3) == "string") then
        cpp_set_state(par1, par2, par3)
    end
    --cpp_save_players();
end

function CreateParticle(screen, zoneName, particlesName, pos_x, pos_y, time)
    local pos_x = pos_x or 0;
    local pos_y = pos_y or 0;
    
    pos_x = pos_x - WINDOW_WIDTH / 2
    pos_y = pos_y - WINDOW_HEIGHT / 2
    
	local id = cpp_create_GFX(screen:GetName(), particlesName, 0, 0, 130)
	cpp_attach_GFX(screen:GetName(), id, zoneName, 1, pos_x, pos_y, false)
	
	cpp_adjust_GFX(screen:GetName(), id, {rect = {-20, -20, 20, 20}})
	
	cpp_set_layer_depth_GFX(screen:GetName(), PARTICLE_ACTIVE_ZONE_ID, zoneName, 1);
	
	if(time) then
        DelayedExec(time, function()
            cpp_script_GFX(screen.name, id, "gActive = false")
            DelayedExec(4, function()
                cpp_remove_GFX(screen.name, id)
            end)
        end)
	end
	
	
	return id;
end

function GetState(par1, par2)
    if(type(par1) == "string" and type(par2) == "string") then
        return cpp_get_state(par1, par2)
    end
    
    return "";
end