1 2local cubes = {} 3for index = 0, 9 do 4 cubes[index] = getModelsTable()[first_cube.index + index] 5end 6 7-- ----------------------------------------------------------------- 8-- Init 9-- ----------------------------------------------------------------- 10local function prog_init() 11 initModels() 12 sound_playMusic("music/rybky07.ogg") 13 local pokus = getRestartCount() 14 15 16 -- ------------------------------------------------------------- 17 local function prog_init_room() 18 local pom1, pom2, pomb1, pomb2 = 0, 0, false, false 19 20 room.zacatek = 0 21 room.pocitadlo = 300 + random(400 + pokus * 500) 22 room.konec = 0 23 24 return function() 25 if no_dialog() and isReady(small) and isReady(big) then 26 if room.pocitadlo > 1 then 27 room.pocitadlo = room.pocitadlo - 1 28 end 29 if room.zacatek == 0 then 30 addm(9 + random(35), "tet-m-vypadala") 31 if pokus < 5 or random(100) < 50 then 32 addv(5, "tet-v-ucta") 33 addm(9, "tet-m-usudek") 34 end 35 room.zacatek = 1 36 elseif room.pocitadlo == 0 then 37 room.pocitadlo = -1 38 addv(9, "tet-v-myslim") 39 if random(100) < 50 then 40 addm(9, "tet-m-ano") 41 end 42 addv(9, "tet-v-lepsi") 43 if random(100) < 50 then 44 addm(16, "tet-m-jaklepsi") 45 addv(6, "tet-v-hybat") 46 end 47 if random(100) < 70 then 48 addm(16, "tet-m-predmety") 49 end 50 addv(16, "tet-v-uprava") 51 addm(6, "tet-m-program") 52 if random(100) < 50 then 53 addm(60, "tet-m-pozor") 54 end 55 elseif room.konec == 0 and trubka.X == 29 and trubka.dir == dir_no then 56 room.konec = 1 57 pom2 = 100 58 for key, cube in pairs(cubes) do 59 if cube.Y < pom2 then 60 pom2 = cube.Y 61 end 62 end 63 if pom2 < 17 then 64 addv(9, "tet-v-kostky") 65 if random(100) > 10 * (pokus - 3) or random(100) < 50 then 66 addm(15 + random(7), "tet-m-lepe") 67 end 68 end 69 end 70 end 71 end 72 end 73 74 -- -------------------- 75 local update_table = {} 76 local subinit 77 subinit = prog_init_room() 78 if subinit then 79 table.insert(update_table, subinit) 80 end 81 return update_table 82end 83local update_table = prog_init() 84 85 86-- ----------------------------------------------------------------- 87-- Update 88-- ----------------------------------------------------------------- 89function prog_update() 90 for key, subupdate in pairs(update_table) do 91 subupdate() 92 end 93end 94 95