local xml = [[
Play with checkpoints on?
",admin,300,60,200,100,0,0xDADADA,0.5,true) ui.addTextArea(2,"",admin,305,115,90,40,0,0,0.5,true) ui.addTextArea(3,"",admin,405,115,90,40,0,0,0.5,true) saveCode = {} saveCode_size = 6 -- ui start ---------------- --- colors --- colors = { green = true, orange = true, red = true, lightblue = true, pink = true, yellow = true, } --- colors --- -- sounds ------------------------------------------------- chekpoint_sounds = {"cite18/baguette0.mp3", "cite18/baguette1.mp3", "cite18/baguette2.mp3"} -- textAreaIds: 500 - invisible button -- 500 - sounds on / 501 - sounds off soundButtonsImageIDs = {500, 501} soundButtons_png = {"192dff43fc5.png", "192dff5e5c3.png"} defaultSoundVolume = 70 -- sounds ------------------------------------------------- -- music ------------------------------------------------- names_musics = {"cite18/musique/volcan1.mp3", "cite18/musique/volcan2.mp3"} -- textAreaIds: 600 - invisible button -- 600 - music on / 601 - music off musicButtonsImageIDs = {600, 601} musicButtons_png = {"192dff45759.png", "192dff5fd34.png"} defaultMusicVolume = 70 musicRarity = 100 musicCooldown = 240 -- music ------------------------------------------------- -- settings ------------------------------------------------- settings_png = "19020ddfd1c.png" -- textAreaIds: 404 - invisible button / 405 - textArea with save code textAreaIDs_settings = {404, 405} id_image_settings = -1 -- settings ------------------------------------------------- -- checkpoints ------------------------------------------------- checkpointsX = {213, 636, 1763, 3480, 3322, 1715, 520, 1505, 1580, 3100} checkpointsY = {88, 485, 505, 85, 596, 845, 1820, 1527, 1689, 1726} -- (500) (501) (600) (601) (602) -- number, number, number, bool bool number number number number number -- id_teleport, id_image_object_ActivatedCheckpoint, id_ActivatedCheckpoint, checkpoint_withCheese, mice_withCheeseNow, id_imageSound, soundVolume, id_imageMusic, musicVolume, musicElapsedSeconds players_info = {} indexPlayerLeft = 100 -- players_info[100] -> .isPlayerLeft (bool) images_id = {"192dff64388.png", "192dff65afb.png"} checkpointCount = #checkpointsX id_image_objects_unactivatedCheckpoints = {} -- checkpoints ------------------------------------------------- gameIsRunning = false isCheckpointEnabled = false function runMaze(loadFromSave) if loadFromSave == false then for i = 1, saveCode_size do saveCode[i] = 0 end end gameIsRunning = true tfm.exec.disableAutoNewGame(true) tfm.exec.disableAfkDeath(true) tfm.exec.disableAutoShaman(true) tfm.exec.disableAutoTimeLeft(true) tfm.exec.disablePhysicalConsumables(true) tfm.exec.newGame(xml) createTargetsImages() for name,v in next, tfm.get.room.playerList do eventNewPlayer(name) end end function updateSingleImage(id_image, name) if isCheckpointEnabled then if id_image == 1 then return tfm.exec.addImage(images_id[1], "_434", 213, 88, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 2 then return tfm.exec.addImage(images_id[1], "_434", 636, 485, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 3 then return tfm.exec.addImage(images_id[1], "_434", 1763, 505, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 4 then return tfm.exec.addImage(images_id[1], "_434", 3480, 85, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 5 then return tfm.exec.addImage(images_id[1], "_434", 3322, 596, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 6 then return tfm.exec.addImage(images_id[1], "_434", 1715, 845, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 7 then return tfm.exec.addImage(images_id[1], "_434", 520, 1820, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 8 then return tfm.exec.addImage(images_id[1], "_434", 1505, 1527, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 9 then return tfm.exec.addImage(images_id[1], "_434", 1580, 1689, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 10 then return tfm.exec.addImage(images_id[1], "_434", 3100, 1726, nil, 0.5, 0.5, 0, 1, 0.5, 0.5) -------- Activated checkpoints -------- elseif id_image == 11 then return tfm.exec.addImage(images_id[2], "_480", 213, 88, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 12 then return tfm.exec.addImage(images_id[2], "_480", 636, 485, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 13 then return tfm.exec.addImage(images_id[2], "_480", 1763, 505, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 14 then return tfm.exec.addImage(images_id[2], "_480", 3480, 85, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 15 then return tfm.exec.addImage(images_id[2], "_480", 3322, 596, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 16 then return tfm.exec.addImage(images_id[2], "_480", 1715, 845, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 17 then return tfm.exec.addImage(images_id[2], "_480", 520, 1820, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 18 then return tfm.exec.addImage(images_id[2], "_480", 1505, 1527, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 19 then return tfm.exec.addImage(images_id[2], "_480", 1580, 1689, name, 0.5, 0.5, 0, 1, 0.5, 0.5) elseif id_image == 20 then return tfm.exec.addImage(images_id[2], "_480", 3100, 1726, name, 0.5, 0.5, 0, 1, 0.5, 0.5) end end ----------- settings ----------- if id_image == textAreaIDs_settings[1] then t = tfm.exec.addImage(settings_png, "~1", 780, 45, nil, 1, 1, 0, 0.7, 0.5, 0.5) ui.removeTextArea(textAreaIDs_settings[1],nil) ui.addTextArea(textAreaIDs_settings[1],"",nil,762,22, 40,40, 0,0,1,true) return t ----------- sounds ----------- elseif id_image == soundButtonsImageIDs[1] then t = tfm.exec.addImage(soundButtons_png[1], "~1", 745, 43, name, 0.3, 0.3, 0, 0.7, 0.5, 0.5) ui.removeTextArea(soundButtonsImageIDs[1],name) ui.addTextArea(soundButtonsImageIDs[1],"",name,727,20, 40,40, 0,0,1,true) return t elseif id_image == soundButtonsImageIDs[2] then t = tfm.exec.addImage(soundButtons_png[2], "~1", 745, 43, name, 0.3, 0.3, 0, 0.7, 0.5, 0.5) ui.removeTextArea(soundButtonsImageIDs[1],name) ui.addTextArea(soundButtonsImageIDs[1],"",name,727,20, 40,40, 0,0,1,true) return t ----------- music ----------- elseif id_image == musicButtonsImageIDs[1] then t = tfm.exec.addImage(musicButtons_png[1], "~1", 709, 42, name, 0.3, 0.3, 0, 0.7, 0.5, 0.5) ui.removeTextArea(musicButtonsImageIDs[1],name) ui.addTextArea(musicButtonsImageIDs[1],"",name,691,19, 40,40, 0,0,1,true) return t elseif id_image == musicButtonsImageIDs[2] then t = tfm.exec.addImage(musicButtons_png[2], "~1", 709, 42, name, 0.3, 0.3, 0, 0.7, 0.5, 0.5) ui.removeTextArea(musicButtonsImageIDs[1],name) ui.addTextArea(musicButtonsImageIDs[1],"",name,691,19, 40,40, 0,0,1,true) return t end end function createTargetsImages() id_image_settings = updateSingleImage(textAreaIDs_settings[1], nil) if isCheckpointEnabled then for i = 1, checkpointCount do table.insert(id_image_objects_unactivatedCheckpoints, updateSingleImage(i, nil)) end end end function updateTargetsImages(name) if id_image_settings ~= nil then tfm.exec.removeImage(id_image_settings) end id_image_settings = updateSingleImage(textAreaIDs_settings[1], nil) if isCheckpointEnabled then for i = 1, checkpointCount do cp = id_image_objects_unactivatedCheckpoints[i] if cp ~= nil then tfm.exec.removeImage(cp) end id_image_objects_unactivatedCheckpoints[i] = updateSingleImage(i, nil) end for name,v in next, tfm.get.room.playerList do if players_info[name] ~= nil then if players_info[name][2] ~= -1 then tfm.exec.removeImage(players_info[name][2]) end if players_info[name][3] ~= -1 then players_info[name][2] = updateSingleImage(players_info[name][3], name) end end end end end function setCheckpoint(id_activatedCheckpoint, name, hasCheese) if players_info[name][2] == -1 then players_info[name][2] = updateSingleImage(id_activatedCheckpoint, name) players_info[name][3] = id_activatedCheckpoint players_info[name][4] = hasCheese tfm.exec.playSound(chekpoint_sounds[math.random(#chekpoint_sounds)], players_info[name][soundButtonsImageIDs[2]], nil, nil, name) else if players_info[name][3] == id_activatedCheckpoint then if players_info[name][2] ~= nil then tfm.exec.removeImage(players_info[name][2]) end players_info[name][2] = -1 players_info[name][3] = -1 players_info[name][4] = false else if players_info[name][2] ~= nil then tfm.exec.removeImage(players_info[name][2]) end players_info[name][2] = updateSingleImage(id_activatedCheckpoint, name) players_info[name][3] = id_activatedCheckpoint players_info[name][4] = hasCheese tfm.exec.playSound(chekpoint_sounds[math.random(#chekpoint_sounds)], players_info[name][soundButtonsImageIDs[2]], nil, nil, name) end end end function updateSaveCode(deleting) if deleting == false then for name,v in next, tfm.get.room.playerList do ui.updateTextArea (textAreaIDs_settings[2], "Save code:
" .. "" .. table.concat(saveCode) .. "
", name) end else for name,v in next, tfm.get.room.playerList do ui.removeTextArea(textAreaIDs_settings[2], name) end end end function eventPlayerDied(name) tfm.exec.respawnPlayer(name) if players_info[name] ~= nil and players_info[name][1] ~= 0 then if players_info[name][1] == 1 then players_info[name][1] = 0 tfm.exec.movePlayer(name,3910,905,false,0,3,false) else players_info[name][1] = 0 tfm.exec.movePlayer(name,1860,630,false,0,3,false) end if players_info[name][5] == true then tfm.exec.giveCheese(name) end else local isWith_cp = false if gameIsRunning and isCheckpointEnabled then if players_info[name] ~= nil and players_info[name][2] ~= -1 then isWith_cp = true if (checkpointsX[players_info[name][3]-checkpointCount]) ~= nil and (checkpointsY[players_info[name][3]-checkpointCount]) ~= nil then tfm.exec.movePlayer(name, checkpointsX[players_info[name][3]-checkpointCount], checkpointsY[players_info[name][3]-checkpointCount], false, 0, 0, false) end if players_info[name][4] == true then tfm.exec.giveCheese(name) end end end if isWith_cp == false then tfm.exec.movePlayer(name,1851,127,false,0,3,false) end end end function eventNewPlayer(name) tfm.exec.respawnPlayer(name) if gameIsRunning then eventPlayerDied(name) ---- tp buttons: blue and purple ---- tfm.exec.removePhysicObject(16) tfm.exec.removePhysicObject(17) tfm.exec.removePhysicObject(18) tfm.exec.removePhysicObject(19) tfm.exec.addPhysicObject(16,3910,905,{type=13,color=6357156,restitution=0.2,friction=0.3,width=20,height=20,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(17,150,1250,{type=13,color=6357156,restitution=0.2,friction=0.3,width=20,height=20,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(18,890,845,{type=13,color=2815,restitution=0.2,friction=0.3,width=20,height=20,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(19,1860,630,{type=13,color=2815,restitution=0.2,friction=0.3,width=20,height=20,groundCollision=true,miceCollision=false}) ---- tp buttons: blue and purple ---- if colors.green == true then tfm.exec.removePhysicObject(1) tfm.exec.removePhysicObject(2) tfm.exec.removePhysicObject(3) tfm.exec.addPhysicObject(1,3114,644,{type=12,color=4128512,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(2,2461,1676,{type=12,color=4128512,restitution=0.2,friction=0.3,width=110,height=10,groundCollision=true}) tfm.exec.addPhysicObject(3,400,1580,{type=12,color=4128512,restitution=0.2,friction=0.3,width=190,height=10,groundCollision=true}) end if colors.red == true then tfm.exec.removePhysicObject(11) tfm.exec.removePhysicObject(12) tfm.exec.removePhysicObject(13) tfm.exec.addPhysicObject(11,1130,105,{type=12,color=16712960,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(12,400,1200,{type=12,color=16712960,restitution=0.2,friction=0.3,width=190,height=10,groundCollision=true}) tfm.exec.addPhysicObject(13,818,299,{type=12,color=16712960,restitution=0.2,friction=0.3,width=10,height=70,groundCollision=true}) end if colors.pink == true then tfm.exec.removePhysicObject(9) tfm.exec.removePhysicObject(10) tfm.exec.addPhysicObject(9,3805,182,{type=12,color=16744183,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(10,2465,330,{type=12,color=16744183,restitution=0.2,friction=0.3,width=10,height=112,groundCollision=true}) end if colors.yellow == true then tfm.exec.removePhysicObject(14) tfm.exec.removePhysicObject(15) tfm.exec.addPhysicObject(14,260,200,{type=12,color=16774400,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(15,1690,952,{type=12,color=16774400,restitution=0.2,friction=0.3,width=10,height=94,groundCollision=true}) end if colors.lightblue == true then tfm.exec.removePhysicObject(6) tfm.exec.removePhysicObject(7) tfm.exec.removePhysicObject(8) tfm.exec.addPhysicObject(6,3470,1240,{type=12,color=64255,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(7,3290,840,{type=12,color=64255,restitution=0.2,friction=0.3,width=10,height=70,groundCollision=true}) tfm.exec.addPhysicObject(8,937,500,{type=12,color=64255,restitution=0.2,friction=0.3,width=182,height=10,groundCollision=true}) end if colors.orange == true then tfm.exec.removePhysicObject(4) tfm.exec.removePhysicObject(5) tfm.exec.addPhysicObject(4,3915,445,{type=12,color=16743680,angle=45,restitution=0.2,friction=0.3,width=30,height=30,groundCollision=true,miceCollision=false}) tfm.exec.addPhysicObject(5,1580,1520,{type=12,color=16743680,restitution=0.2,friction=0.3,width=10,height=70,groundCollision=true}) end tfm.exec.bindKeyboard(name, 40, true, true) tfm.exec.bindKeyboard(name, 83, true, true) tfm.exec.bindKeyboard(name, 98, true, true) if players_info[name] == nil then players_info[name] = {0, -1, -1, false, false} players_info[name][indexPlayerLeft] = false -- [100] players_info[name][soundButtonsImageIDs[1]] = -1 -- [500] players_info[name][soundButtonsImageIDs[2]] = defaultSoundVolume -- [501] players_info[name][musicButtonsImageIDs[1]] = -1 -- [600] players_info[name][musicButtonsImageIDs[2]] = defaultMusicVolume -- [601] players_info[name][musicButtonsImageIDs[2] + 1] = 0 -- [602] end players_info[name][indexPlayerLeft] = false if isCheckpointEnabled then if players_info[name][2] ~= -1 then if (checkpointsX[players_info[name][3]-checkpointCount]) ~= nil and (checkpointsY[players_info[name][3]-checkpointCount]) ~= nil then tfm.exec.movePlayer(name, checkpointsX[players_info[name][3]-checkpointCount], checkpointsY[players_info[name][3]-checkpointCount], false, 0, 0, false) end if players_info[name][4] == true then tfm.exec.giveCheese(name) end end end updateTargetsImages(name) end end function eventKeyboard(name, keyCode, down, xPlayerPosition,yPlayerPosition) if gameIsRunning then if keyCode==40 or keyCode==83 or keyCode==98 then if xPlayerPosition >= 3099 and xPlayerPosition <= 3129 and yPlayerPosition >= 629 and yPlayerPosition <= 659 then colors.green = false tfm.exec.removePhysicObject(1) tfm.exec.removePhysicObject(2) tfm.exec.removePhysicObject(3) saveCode[1] = "1" elseif xPlayerPosition >= 3900 and xPlayerPosition <= 3930 and yPlayerPosition >= 430 and yPlayerPosition <= 460 then colors.orange = false tfm.exec.removePhysicObject(4) tfm.exec.removePhysicObject(5) saveCode[2] = "1" elseif xPlayerPosition >= 3455 and xPlayerPosition <= 3485 and yPlayerPosition >= 1225 and yPlayerPosition <= 1255 then colors.lightblue = false tfm.exec.removePhysicObject(6) tfm.exec.removePhysicObject(7) tfm.exec.removePhysicObject(8) saveCode[4] = "1" elseif xPlayerPosition >= 3790 and xPlayerPosition <= 3820 and yPlayerPosition >= 167 and yPlayerPosition <= 197 then colors.pink = false tfm.exec.removePhysicObject(9) tfm.exec.removePhysicObject(10) saveCode[5] = "1" elseif xPlayerPosition >= 1115 and xPlayerPosition <= 1145 and yPlayerPosition >= 90 and yPlayerPosition <= 120 then colors.red = false tfm.exec.removePhysicObject(11) tfm.exec.removePhysicObject(12) tfm.exec.removePhysicObject(13) saveCode[3] = "1" elseif xPlayerPosition >= 245 and xPlayerPosition <= 275 and yPlayerPosition >= 185 and yPlayerPosition <= 215 then colors.yellow = false tfm.exec.removePhysicObject(14) tfm.exec.removePhysicObject(15) saveCode[6] = "1" -- purple tp button -- elseif xPlayerPosition >= 135 and xPlayerPosition <= 165 and yPlayerPosition >= 1235 and yPlayerPosition <= 1265 then players_info[name][1] = 1 players_info[name][5] = (tfm.get.room.playerList[name].hasCheese == true) tfm.exec.movePlayer(name,3910,905,false,0,0,true) elseif xPlayerPosition >= 3895 and xPlayerPosition <= 3925 and yPlayerPosition >= 890 and yPlayerPosition <= 920 then tfm.exec.movePlayer(name,150,1250,false,0,0,true) -- purple tp button -- -- blue tp button -- elseif xPlayerPosition >= 875 and xPlayerPosition <= 905 and yPlayerPosition >= 830 and yPlayerPosition <= 860 then players_info[name][1] = 2 players_info[name][5] = (tfm.get.room.playerList[name].hasCheese == true) tfm.exec.movePlayer(name,1860,630,false,0,0,true) elseif xPlayerPosition >= 1845 and xPlayerPosition <= 1875 and yPlayerPosition >= 615 and yPlayerPosition <= 645 then tfm.exec.movePlayer(name,890,845,false,0,0,true) end -- blue tp button -- if isCheckpointEnabled then ------------- checkpoints ------------- if xPlayerPosition >= 198 and xPlayerPosition <= 228 and yPlayerPosition >= 73 and yPlayerPosition <= 103 then setCheckpoint(1+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 621 and xPlayerPosition <= 651 and yPlayerPosition >= 470 and yPlayerPosition <= 500 then setCheckpoint(2+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 1748 and xPlayerPosition <= 1778 and yPlayerPosition >= 490 and yPlayerPosition <= 520 then setCheckpoint(3+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 3465 and xPlayerPosition <= 3495 and yPlayerPosition >= 70 and yPlayerPosition <= 100 then setCheckpoint(4+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 3307 and xPlayerPosition <= 3337 and yPlayerPosition >= 581 and yPlayerPosition <= 611 then setCheckpoint(5+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 1700 and xPlayerPosition <= 1730 and yPlayerPosition >= 830 and yPlayerPosition <= 860 then setCheckpoint(6+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 505 and xPlayerPosition <= 535 and yPlayerPosition >= 1805 and yPlayerPosition <= 1835 then setCheckpoint(7+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 1490 and xPlayerPosition <= 1520 and yPlayerPosition >= 1512 and yPlayerPosition <= 1542 then setCheckpoint(8+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 1565 and xPlayerPosition <= 1595 and yPlayerPosition >= 1674 and yPlayerPosition <= 1704 then setCheckpoint(9+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) elseif xPlayerPosition >= 3085 and xPlayerPosition <= 3115 and yPlayerPosition >= 1711 and yPlayerPosition <= 1741 then setCheckpoint(10+checkpointCount, name, tfm.get.room.playerList[name].hasCheese == true) end end ------------- checkpoints ------------- updateSaveCode(false) end end end function eventTextAreaCallback(textAreaID, playerName, callback) if gameIsRunning then if players_info[playerName] ~= nil then if textAreaID == textAreaIDs_settings[1] then if players_info[playerName][soundButtonsImageIDs[1]] == -1 then ui.addTextArea(textAreaIDs_settings[2],"Save code:
" .. "" .. table.concat(saveCode) .. "
", playerName, 600, 70, 190, 50, 0, 0xDADADA, 0.5, true) if players_info[playerName][soundButtonsImageIDs[2]] ~= 0 then players_info[playerName][soundButtonsImageIDs[1]] = updateSingleImage(soundButtonsImageIDs[1], playerName) else players_info[playerName][soundButtonsImageIDs[1]] = updateSingleImage(soundButtonsImageIDs[2], playerName) end if players_info[playerName][musicButtonsImageIDs[2]] ~= 0 then players_info[playerName][musicButtonsImageIDs[1]] = updateSingleImage(musicButtonsImageIDs[1], playerName) else players_info[playerName][musicButtonsImageIDs[1]] = updateSingleImage(musicButtonsImageIDs[2], playerName) end else if players_info[playerName][soundButtonsImageIDs[1]] ~= nil then tfm.exec.removeImage(players_info[playerName][soundButtonsImageIDs[1]]) end if players_info[playerName][musicButtonsImageIDs[1]] ~= nil then tfm.exec.removeImage(players_info[playerName][musicButtonsImageIDs[1]]) end ui.removeTextArea(soundButtonsImageIDs[1], playerName) ui.removeTextArea(musicButtonsImageIDs[1], playerName) ui.removeTextArea(textAreaIDs_settings[2], playerName) ui.removeTextArea(indexPlayerLeft, playerName) players_info[playerName][soundButtonsImageIDs[1]] = -1 players_info[playerName][musicButtonsImageIDs[1]] = -1 end elseif textAreaID == textAreaIDs_settings[2] then if tfm.get.room.isTribeHouse == false then tfm.exec.chatMessage("Save code: " .. "" .. table.concat(saveCode) .. "", playerName) end ui.removeTextArea(textAreaIDs_settings[2], playerName) print("Save code: " .. table.concat(saveCode)) elseif textAreaID == soundButtonsImageIDs[1] then tfm.exec.removeImage(players_info[playerName][soundButtonsImageIDs[1]]) if players_info[playerName][soundButtonsImageIDs[2]] ~= 0 then players_info[playerName][soundButtonsImageIDs[2]] = 0 players_info[playerName][soundButtonsImageIDs[1]] = updateSingleImage(soundButtonsImageIDs[2], playerName) else players_info[playerName][soundButtonsImageIDs[2]] = defaultSoundVolume players_info[playerName][soundButtonsImageIDs[1]] = updateSingleImage(soundButtonsImageIDs[1], playerName) end elseif textAreaID == musicButtonsImageIDs[1] then tfm.exec.removeImage(players_info[playerName][musicButtonsImageIDs[1]]) if players_info[playerName][musicButtonsImageIDs[2]] ~= 0 then players_info[playerName][musicButtonsImageIDs[2]] = 0 players_info[playerName][musicButtonsImageIDs[1]] = updateSingleImage(musicButtonsImageIDs[2], playerName) ui.addTextArea(indexPlayerLeft,"From this moment on, the music will no longer start automatically.
",playerName,215,30,370,40,0,0xDADADA,0.5,true) else players_info[playerName][musicButtonsImageIDs[2]] = defaultMusicVolume players_info[playerName][musicButtonsImageIDs[1]] = updateSingleImage(musicButtonsImageIDs[1], playerName) ui.removeTextArea(indexPlayerLeft, playerName) end elseif textAreaID == indexPlayerLeft then ui.removeTextArea(indexPlayerLeft, playerName) end end else ui.removeTextArea(4, playerName) ui.removeTextArea(4, playerName) ui.addTextArea(4,"",admin,20,190,200,30,0,0xDADADA,0.5,true) ui.addTextArea(5,"",admin,20,230,200,30,0,0xDADADA,0.5,true) if textAreaID == 5 then ui.addPopup (0, 2, "Load Level from Code
", admin, 20, 300, 200, true) elseif textAreaID == 4 then ui.removeTextArea(1, playerName) ui.removeTextArea(2, playerName) ui.removeTextArea(3, playerName) ui.removeTextArea(4, playerName) ui.removeTextArea(5, playerName) runMaze(false) elseif textAreaID == 2 then isCheckpointEnabled = true ui.removeTextArea(2, playerName) ui.addTextArea(2,"",admin,305,115,90,40,0,0x71B82B,0.5,true) ui.removeTextArea(3, playerName) ui.addTextArea(3,"",admin,405,115,90,40,0,0,0.5,true) elseif textAreaID == 3 then isCheckpointEnabled = false ui.removeTextArea(3, playerName) ui.addTextArea(3,"",admin,405,115,90,40,0,0xDD3C3C,0.5,true) ui.removeTextArea(2, playerName) ui.addTextArea(2,"",admin,305,115,90,40,0,0,0.5,true) end end end function eventPopupAnswer (popupId, playerName, answer) if gameIsRunning == false then isCode = true for i = 1, #answer do saveCode[i] = string.sub(answer, i, i) if saveCode[i] < "0" or saveCode[i] > "1" then isCode = false end end if #answer ~= saveCode_size or isCode == false then ui.addPopup (0, 2, "Load Level from Code
", admin, 20, 300, 200, true) saveCode = {} else if saveCode[1] == "1" then colors.green = false end if saveCode[2] == "1" then colors.orange = false end if saveCode[3] == "1" then colors.red = false end if saveCode[4] == "1" then colors.lightblue = false end if saveCode[5] == "1" then colors.pink = false end if saveCode[6] == "1" then colors.yellow = false end ui.removeTextArea(1, playerName) ui.removeTextArea(2, playerName) ui.removeTextArea(3, playerName) ui.removeTextArea(4, playerName) ui.removeTextArea(5, playerName) runMaze(true) end end end function eventLoop(elapsedTime, remainingTime) for name,v in next, tfm.get.room.playerList do if (players_info[name] ~= nil) and (players_info[name][indexPlayerLeft] == false) then local t = musicButtonsImageIDs[2]+1 if ((players_info[name][t] > musicCooldown) or (players_info[name][t] == 0)) and (players_info[name][t-1] ~= 0) then a = math.random(musicRarity) if a == musicRarity then players_info[name][t] = 0.5 tfm.exec.playSound(names_musics[math.random(#names_musics)], players_info[name][t-1], nil, nil, name) end elseif players_info[name][t-1] ~= 0 then players_info[name][t] = players_info[name][t] + 0.5 end end end end function eventPlayerLeft(playerName) players_info[playerName][indexPlayerLeft] = true end