local Time 	= Game.Time;
local Delay 	= 1; -- game seconds
local Ready	= Time();

function Create()
	Ready = Time()
	Delay = 1
end

function tableSize(T)
    if T == nil then return 0; end
    local count = 0;
    for _ in pairs(T) do count = count + 1; end
    return count;
end

function CreatePaper() --creating paper for printer
	if roll(30) == true then
                local paper = Object.Spawn("MessyPapers", this.Pos.x, this.Pos.y);
		Object.ApplyVelocity(paper,math.random(-1,1),math.random(-1,1),math.random(-1,1))
    		Object.SetProperty(paper, "iX", this.Pos.x);
    		Object.SetProperty(paper, "iY", this.Pos.y);
		end
	end

function Update()
	if Time() > Ready then
		PerformUpdate( Delay )
		Ready = Ready + Delay
	end
end

function PerformUpdate( elapsedTime )
	CreatePaper()
	end

function roll(chance)
    local randomPercent = math.random(0, 500);
    if randomPercent <= chance then return true; end
    return false;
end


