-- write out that we loaded sucessfully (mor or less, anyway)
io.write("Starting oo-script for Level 3 of S23-IvoryTower in BlinkenLUA / ",_VERSION,"!\n")

-- Register my init call
bs.callback.engine.init("myInit");


function myInit ()
	
	bs.include("_firetile.inc.bsl");	

	Firetile:new(41, 7);

	for i=2,14 do
	    Firetile:new(i, 31);
	end
	for i=23,35 do
	    Firetile:new(i, 24);
	end
	for i=44,48 do
	    Firetile:new(i, 28);
	end



	bs.include("_tropflava.inc.bsl");
	TropfLava:new(1330, 896, 0, 15);
	TropfLava:new(1728, 896, 10, 15);
	TropfLava:new(1280, 416, 20, 15);



	
	TIMER_FREEMOVEMENT_1 = -1;
	bs.callback.engine.physics("scriptPhysics");
end



-- Required function: Physics-loop for scripting part
function scriptPhysics ()
    local katex = bs.player.x();
    local katey = bs.player.y();
    if katex > 1000 and katex < 1200 and katey > 900 and katey < 960 then
        bs.level.freemovement(bs.yes);
        TIMER_FREEMOVEMENT_1 = 25;
    end
    if TIMER_FREEMOVEMENT_1 >= 0 then
        TIMER_FREEMOVEMENT_1 = TIMER_FREEMOVEMENT_1 - 1;
    end
    if TIMER_FREEMOVEMENT_1 == 0 then
        bs.level.freemovement(bs.no);
    end
end


