print("_LevelHub_CaveController") currentCave = nil lockplayer = object("_LockPlayer") caveTransitionInProgress = false caveFunctions = {} caveFunctions.movePlayers = function (destp1,destp2) local player1 = player_obj(0) local player2 = player_obj(1) print(player1,player2) print( destp1.position() ) if player1 then player1.position( destp1.position() ) player1.rotation( destp1.rotation() ) end if player2 then player2.position( destp2.position() ) player2.rotation( destp2.rotation() ) end end caveFunctions.fanCave = {} caveFunctions.fanCave.state1 = function() print("fanCave.state1") caveTransitionInProgress = true lockplayer.trigger.send(1) caveExit = object("Ruins_Teleporters_waypoint_1") caveExitp2 = object("Ruins_Teleporters_waypoint_1p2") object("CaveFan").setAlpha(1) if fanDestroyed and not butterflyInfo.FanCave.picked and object("Ruins_Special_Collectible_FanCave") then print("placing FanCave butterfly",fanDestroyed,butterflyInfo.FanCave.picked) object("Ruins_Special_Collectible_FanCave").position( object("Ruins_Special_Collectible_CaveDest").position() ) else print("not placing FanCave butterfly",fanDestroyed,butterflyInfo.FanCave.picked) end end caveFunctions.fanCave.state2 = function() print("fanCave.state2") caveFunctions.movePlayers( object("Ruins_Teleporters_waypoint_FanHole") , object("Ruins_Teleporters_waypoint_FanHole_p2") ) cameras.trigger.send(1,"RuinsCamWaterCaveCam") end caveFunctions.fanCave.state3 = function () print("fanCave.state3") end caveFunctions.fanCave.state4 = function () print("fanCave.state4") lockplayer.trigger.send(2) caveTransitionInProgress = false currentCave = caveFunctions.fanCave.exit end caveFunctions.robotCave = {} caveFunctions.robotCave.state1 = function () print("robotCave.state1") caveTransitionInProgress = true lockplayer.trigger.send(1) object("CaveFan").setAlpha(0) if not butterflyInfo.RobotCave.picked and object("Ruins_Special_Collectible_RobotCave") then print("placing RobotCave butterfly",butterflyInfo.RobotCave.picked) object("Ruins_Special_Collectible_RobotCave").position( object("Ruins_Special_Collectible_CaveDest2").position() ) else print("not placing RobotCave butterfly",butterflyInfo.RobotCave.picked) end caveExit = object("Ruins_Teleporters_waypoint_2") caveExitp2 = object("Ruins_Teleporters_waypoint_2p2") end caveFunctions.robotCave.state2 = function () print("robotCave.state2") caveFunctions.movePlayers( object("Ruins_Teleporters_waypoint_4") , object("Ruins_Teleporters_waypoint_4_p2") ) cameras.trigger.send(1,"RuinsCamWaterCaveCam") end caveFunctions.robotCave.state3 = function () print("robotCave.state3") end caveFunctions.robotCave.state4 = function () print("robotCave.state4") caveTransitionInProgress = false lockplayer.trigger.send(2) currentCave = caveFunctions.fanCave.exit end caveFunctions.exitCave = {} caveFunctions.exitCave.state1 = function () print("exitCave.state1") caveTransitionInProgress = true lockplayer.trigger.send(1) end caveFunctions.exitCave.state2 = function () print("exitCave.state2") caveFunctions.movePlayers( caveExit , caveExitp2 ) cameras.trigger.send(1,"RuinsCam17") end caveFunctions.exitCave.state3 = function () print("fanCave.state3") for k,v in pairs({"FanCave","RobotCave"}) do if butterflyInfo[v]["obj"] and butterflyInfo[v]["obj"].alive then print("hiding cave butterfly",v) butterflyInfo[v]["obj"].position( object("Ruins_Special_Collectible_CaveHideDest").position() ) end end object("CaveFan").setAlpha(0) end caveFunctions.exitCave.state4 = function() print("exitCave.state4") caveTransitionInProgress = false lockplayer.trigger.send(2) currentCave = nil end function caveTick() if trigger.received(1,"FanDestroyed") then print("FanDestroyed") object("fx_hole_dust_01").delete() object("env_steam_1_").trigger.send(2) object("env_steam_1_").delete() fanDestroyed = true global_variable_set_bool("Ruins_fanDestroyed",true) SaveGameProgress() end if trigger.received(1,"enterFanCave") then print("enterFanCave") currentCave = caveFunctions.fanCave trigger.send(1,"ftCave") end if trigger.received(1,"enterRobotDoor") then print("enterRobotDoor") currentCave = caveFunctions.robotCave trigger.send(1,"ftCave") end if trigger.received(1,"exitCave") then print("exitCave trigger" , caveTransitionInProgress ) if not caveTransitionInProgress then currentCave = caveFunctions.exitCave trigger.send(1,"ftCave") else print("skipping exitCave") end end if trigger.received(1,"caveMovementState1") then print("caveMovementState1") if currentCave then currentCave.state1() else print("currentCave not valid") end end if trigger.received(1,"caveMovementState2") then print("caveMovementState2") if currentCave then currentCave.state2() else print("currentCave not valid") end end if trigger.received(1,"caveMovementState3") then print("caveMovementState3") if currentCave then currentCave.state3() else print("currentCave not valid") end end if trigger.received(1,"caveMovementState4") then print("caveMovementState4") if currentCave then currentCave.state4() else print("currentCave not valid") end end end