Coop Transition Script and Level Choosers
Quote from ChickenMobile on August 11, 2012, 9:37 amHrmmmmmmmm...
Is text preview on for the level chooser?
Hrmmmmmmmm...
Is text preview on for the level chooser?
Quote from RectorRocks on August 11, 2012, 9:39 amYepp, sorry I went to Map 01 instead.
Yepp, sorry I went to Map 01 instead.
Quote from ChickenMobile on August 11, 2012, 9:43 amRectorRocks wrote:Yepp, sorry I went to Map 01 instead.So it's ok?
So it's ok?
Quote from RectorRocks on August 11, 2012, 9:45 amNo...? I choosed Map 03 in the Level Chooser, but I went to Map 01.
No...? I choosed Map 03 in the Level Chooser, but I went to Map 01.
Quote from ChickenMobile on August 11, 2012, 9:51 amstrange...
Do you mind sending your script and test maps so I can have a look?
strange...
Do you mind sending your script and test maps so I can have a look?
Quote from RectorRocks on August 11, 2012, 9:57 amI need to mention something first, I copy and paste the sp_transition_list.nut and renamed it. Then, I copied some of the things inside your transition.nut and pasted in the modified sp_transition list.nut. I did that because I kept getting the error in the previous post if I used your transition.nut. D:
This is what I have in my modified sp_transition_list.nut:
- Code: Select all
DBG <- 0
FORCE_GUN_AND_HALLWAY <- 0FIRST_MAP_WITH_GUN <- "sp_a1_intro4"
FIRST_MAP_WITH_UPGRADE_GUN <- "sp_a2_laser_intro"
FIRST_MAP_WITH_POTATO_GUN <- "sp_a3_speed_ramp"
LAST_PLAYTEST_MAP <- "sp_a4_finale4"CHAPTER_TITLES <-
[
{ map = "sp_a1_intro1", title_text = "#portal2_Chapter1_Title", subtitle_text = "#portal2_Chapter1_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },
{ map = "sp_a2_laser_intro", title_text = "#portal2_Chapter2_Title", subtitle_text = "#portal2_Chapter2_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_sphere_peek", title_text = "#portal2_Chapter3_Title", subtitle_text = "#portal2_Chapter3_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_column_blocker", title_text = "#portal2_Chapter4_Title", subtitle_text = "#portal2_Chapter4_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_bts3", title_text = "#portal2_Chapter5_Title", subtitle_text = "#portal2_Chapter5_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },
{ map = "sp_a3_00", title_text = "#portal2_Chapter6_Title", subtitle_text = "#portal2_Chapter6_Subtitle", displayOnSpawn = true, displaydelay = 1.5 },
{ map = "sp_a3_speed_ramp", title_text = "#portal2_Chapter7_Title", subtitle_text = "#portal2_Chapter7_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },
{ map = "sp_a4_intro", title_text = "#portal2_Chapter8_Title", subtitle_text = "#portal2_Chapter8_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a4_finale1", title_text = "#portal2_Chapter9_Title", subtitle_text = "#portal2_Chapter9_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },
]// Display the chapter title
function DisplayChapterTitle()
{
foreach (index, level in CHAPTER_TITLES)
{
if (level.map == GetMapName() )
{
EntFire( "@chapter_title_text", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@chapter_title_text", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@chapter_title_text", "SetPosY", "0.32", 0.0 )
EntFire( "@chapter_title_text", "SetText", level.title_text, 0.0 )
EntFire( "@chapter_title_text", "display", "", level.displaydelay )
EntFire( "@chapter_subtitle_text", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@chapter_subtitle_text", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@chapter_subtitle_text", "SetPosY", "0.35", 0.0 )
EntFire( "@chapter_subtitle_text", "settext", level.subtitle_text, 0.0 )
EntFire( "@chapter_subtitle_text", "display", "", level.displaydelay )
}
}
}// Display the chapter title on spawn if it is flagged to show up on spawn
function TryDisplayChapterTitle()
{
foreach (index, level in CHAPTER_TITLES)
{
if (level.map == GetMapName() && level.displayOnSpawn )
{
DisplayChapterTitle()
}
}
}LOOP_TIMER <- 0
initialized <- false
// This is the order to play the maps
MapPlayOrder<- [// ===================================================
// ====================== ACT 1 ======================
// ===================================================// ---------------------------------------------------
// Intro
// ---------------------------------------------------
"sp_a1_intro1", // motel to box-on-button
"sp_a1_intro2", // portal carousel
"sp_a1_intro3", // fall-through-floor, dioramas, portal gun
"sp_a1_intro4", // box-in-hole for placing on button
"sp_a1_intro5", // fling hinting
"sp_a1_intro6", // fling training
"sp_a1_intro7", // wheatley meetup
"sp_a1_wakeup", // glados
"@incinerator",// ===================================================
// ====================== ACT 2 ======================
// ==================================================="sp_a2_intro", // upgraded portal gun track
// ---------------------------------------------------
// Lasers
// ---------------------------------------------------
"sp_a2_laser_intro",
"sp_a2_laser_stairs",
"sp_a2_dual_lasers",
"sp_a2_laser_over_goo",// ---------------------------------------------------
// Catapult
// ---------------------------------------------------
"sp_a2_catapult_intro",
"sp_a2_trust_fling",// ---------------------------------------------------
// More Lasers
// ---------------------------------------------------
"sp_a2_pit_flings",
"sp_a2_fizzler_intro",// ---------------------------------------------------
// Lasers + Catapult
// ---------------------------------------------------
"sp_a2_sphere_peek",
"sp_a2_ricochet",// ---------------------------------------------------
// Bridges
// ---------------------------------------------------
"sp_a2_bridge_intro",
"sp_a2_bridge_the_gap",// ---------------------------------------------------
// Turrets
// ---------------------------------------------------
"sp_a2_turret_intro",
"sp_a2_laser_relays", // breather
"sp_a2_turret_blocker",
"sp_a2_laser_vs_turret", // Elevator Glados Chat - Should be removed?// ---------------------------------------------------
// Graduation
// ---------------------------------------------------
"sp_a2_pull_the_rug",
"sp_a2_column_blocker", // Elevator_vista
"sp_a2_laser_chaining",
//"sp_a2_turret_tower",
"sp_a2_triple_laser",// ---------------------------------------------------
// Sabotage
// ---------------------------------------------------"sp_a2_bts1",
"sp_a2_bts2",
"sp_a2_bts3",
"sp_a2_bts4",
"sp_a2_bts5",
"sp_a2_bts6",// ---------------------------------------------------
// Glados Chamber Sequence
// ---------------------------------------------------
"sp_a2_core",// ===================================================
// ====================== ACT 3 ======================
// ===================================================// ---------------------------------------------------
// Underground
// ---------------------------------------------------"@bottomless_pit",
"sp_a3_00",
"sp_a3_01",
"sp_a3_03",
"@test_dome_lift",
"sp_a3_jump_intro",
"@test_dome_lift",
"sp_a3_bomb_flings",
"@test_dome_lift",
"sp_a3_crazy_box",
"@test_dome_lift",
"sp_a3_transition01",
"@test_dome_lift",
"sp_a3_speed_ramp",
"@test_dome_lift",
"sp_a3_speed_flings",
"@test_dome_lift",
"sp_a3_portal_intro",
"@hallway",
"sp_a3_end",// ===================================================
// ====================== ACT 4 ======================
// ===================================================// ---------------------------------------------------
// Recapture
// ---------------------------------------------------
"sp_a4_intro",// ---------------------------------------------------
// Tractor beam
// ---------------------------------------------------
"sp_a4_tb_intro",
"sp_a4_tb_trust_drop",
// "@hallway",
"sp_a4_tb_wall_button",
// "@hallway",
"sp_a4_tb_polarity",
// "@hallway",
"sp_a4_tb_catch", // GRAD// ---------------------------------------------------
// Crushers
// ---------------------------------------------------// ---------------------------------------------------
// Graduation Combos
// ---------------------------------------------------
"sp_a4_stop_the_box", // Grad?
// "@hallway",
"sp_a4_laser_catapult", // Grad
// "@hallway",
//"sp_catapult_course"
// "@hallway",
//"sp_box_over_goo", // Grad
// "@hallway",
"sp_a4_laser_platform",// ---------------------------------------------------
// Tbeam + Paint
// ---------------------------------------------------
//"sp_paint_jump_tbeam",
// "@hallway",
"sp_a4_speed_tb_catch",
// "@hallway",
"sp_a4_jump_polarity", // GRAD
// "@hallway",
//"sp_paint_portal_tbeams",// ---------------------------------------------------
// Wheatley Escape
// ---------------------------------------------------"sp_a4_finale1",
"@hallway",
"sp_a4_finale2",
"@hallway",
"sp_a4_finale3",
"@hallway",// ---------------------------------------------------
// FIXME: WHEATLEY BATTLE
// ---------------------------------------------------"sp_a4_finale4",
// ---------------------------------------------------
// Demo files
// ---------------------------------------------------
"demo_intro",
"demo_underground",
"demo_paint",// ---------------------------------------------------
// Mappack
// ---------------------------------------------------
"sp_mappack_hub",
"sp_security_crisis",
"sp_u_repulsive_welcome",
"sp_painting_with_gels"
]//================== CONSTANTS ( EDIT THESE ) =====================
//-----------------------------------------------------------------// Turn Debug on (1) or off (0)
DBG <- 0// Set to false if you don't want text to appear showing the name of the current chosen level on the chooser
textPreview <- true// The name of the Hub map. This the map it will transition to when all maps are finished in the current course.
// The hubmap will be ignored if tried to transition to if it is in MapPlayOrder[]
HUB_MAP <- "sp_mappack_hub"//--------------------------------------------------------------------------------
// Create new START and END maps to calculate a new level chooser for another course.
// For eg. "map1ex" is the start level and "map3ex" is the end level of the first course.
//--------------------------------------------------------------------------------
START_MAP <- [
"sp_security_crisis", //Course 1 StartMap
]END_MAP <- [
"sp_painting_with_gels", //Course 1 EndMap
]// --------------------------------------------------------
// OnPostTransition - we just transitioned, teleport us to the correct place.
// --------------------------------------------------------
function OnPostTransition()
{
local foundMap = false
foreach (index, map in MapPlayOrder)
{
if (GetMapName() == MapPlayOrder[index])
{
foundMap = true
// hook up our entry elevator
if( index - 1 >= 0 )
{
if( MapPlayOrder[index-1].find("@") == null )
{
printl( "Teleporting to default start pos" )
EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 )
EntFire( "@arrival_teleport", "Teleport", 0, 0 )
}
else
{
printl( "Trying to teleport to " + MapPlayOrder[index - 1] + "_teleport" )
EntFire( MapPlayOrder[index - 1] + "_entry_teleport", "Teleport", 0, 0.0 )
}
}
break
}
}
if (foundMap == false )
{
EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 )
EntFire( "@arrival_teleport", "Teleport", 0, 0 )
}
}// --------------------------------------------------------
// EntFire_MapLoopHelper
// --------------------------------------------------------
function EntFire_MapLoopHelper( classname, suffix, command, param, delay )
{
// This calls EntFire on an entity of a given type, named with the given suffix.
// This deals with instance name mangling (though it doesn't guarantee uniqueness)
local suffix_len = suffix.len()
for ( local ent = Entities.FindByClassname( null, classname ); ent != null; ent = Entities.FindByClassname( ent, classname ) )
{
local ent_name = ent.GetName()
local suffix_offset = ent_name.find( suffix )
if ( ( suffix_offset != null ) && ( suffix_offset == ( ent_name.len() - suffix_len ) ) )
{
EntFire( ent_name, command, param, delay )
return
}
}
printl( "MAPLOOP: ---- ERROR! Failed to find entity " + suffix + " while initiating map transition" );
}// --------------------------------------------------------
// Think
// --------------------------------------------------------
function Think()
{
// Start the game loop if the cvar is set
if ( initialized && LoopSinglePlayerMaps() )
{
// initialize the timer
if( LOOP_TIMER == 0 )
{
LOOP_TIMER = Time() + 10 // restart time in seconds
}
// transition to the next map if the timer has expired
if ( LOOP_TIMER < Time() )
{
// reset loop timer
LOOP_TIMER = 0printl( "nMAPLOOP: timer expired, moving on..." )
// Ensure point_viewcontrollers are disabled
EntFire( "point_viewcontrol", "disable", 0, 0 )
// Change the level (this sequence was originally in the 'transition_without_survey' logic_relay)
EntFire_MapLoopHelper( "trigger_once", "survey_trigger", "Disable", "", 0.0 )
EntFire_MapLoopHelper( "env_fade", "exit_fade", "Fade", "", 0.0 )
EntFire_MapLoopHelper( "point_teleport", "exit_teleport", "Teleport", "", 0.3 )
EntFire_MapLoopHelper( "logic_script", "transition_script", "RunScriptCode", "TransitionFromMap()", 0.4 )
}
}
if (initialized)
{
return
}
initialized = true// position fixup for sp_a3_01, in case player has fallen outside map
if (GetMapName() == "sp_a3_01")
{
printl( "--------------- FIXING PLAYER POSITION FOR sp_a3_01" )local destination_name = "knockout-teleport" // targetname of the destination entity
local player_ent = nulllocal destination_ent = null
// find the player
player_ent = Entities.FindByClassname( player_ent, "player" )if ( player_ent == null )
{
printl("*** Cannot find player. Aborting!")
return;
}// find the destination entity
destination_ent = Entities.FindByName( destination_ent, destination_name )if ( destination_ent == null )
{
printl("*** Cannot find destination entity " + destination_name + ". Aborting!")
return;
}
// move the player to the destination
player.SetOrigin( destination_ent.GetOrigin() )
}DumpMapList()
local portalGunCommand = ""
local portalGunSecondCommand = ""
local foundMap = false
foreach (index, map in MapPlayOrder)
{
if (MapPlayOrder[index] == FIRST_MAP_WITH_GUN)
{
portalGunCommand = "give_portalgun"
}
else if (MapPlayOrder[index] == FIRST_MAP_WITH_UPGRADE_GUN)
{
portalGunSecondCommand = "upgrade_portalgun"
}
else if (MapPlayOrder[index] == FIRST_MAP_WITH_POTATO_GUN)
{
portalGunSecondCommand = "upgrade_potatogun"
}
if (GetMapName() == MapPlayOrder[index])
{
break
}
}TryDisplayChapterTitle()
if (portalGunCommand != "" && GetMapName() != "sp_a2_intro" && GetMapName() != "sp_a3_01" )
{
printl( "=======================Trying to run " + portalGunCommand )
EntFire( "command", "Command", portalGunCommand, 0.0 )
EntFire( "@command", "Command", portalGunCommand, 0.0 )
}if (portalGunSecondCommand != "")
{
printl( "=======================Trying to run " + portalGunSecondCommand )
EntFire( "command", "Command", portalGunSecondCommand, 0.1 )
EntFire( "@command", "Command", portalGunSecondCommand, 0.1 )
}
}// --------------------------------------------------------
// TransitionFromMap
// --------------------------------------------------------
function DumpMapList()
{
if(DBG)
{
local mapcount = 0
printl("================DUMPING MAP PLAY ORDER")
foreach( index, map in MapPlayOrder )
{
// weed out our transitions
if( MapPlayOrder[index].find("@") == null )
{
if( GetMapName() == MapPlayOrder[index] )
{
printl( mapcount + " " + MapPlayOrder[index] + " <--- You Are Here" )
}
else
{
printl( mapcount + " " + MapPlayOrder[index] )
}
mapcount++
}
}
printl( mapcount + " maps total." )
printl("================END DUMP")
}
}// --------------------------------------------------------
// TransitionFromMap
// --------------------------------------------------------
function TransitionFromMap()
{
local next_map = null
foreach( index, map in MapPlayOrder )
{
if( GetMapName() == MapPlayOrder[index] )
{
// make good
local skipIndex = index
for(local i=0;i<2;i+=1)
{
if( skipIndex + 1 < MapPlayOrder.len() )
{
if( MapPlayOrder[skipIndex + 1].find("@") != null )
{
skipIndex++
}
else
{
break
}
}
}
if( ( skipIndex + 1 < MapPlayOrder.len() ) &&
( GetMapName() != LAST_PLAYTEST_MAP ) )
{
next_map = MapPlayOrder[ skipIndex + 1 ]
if(DBG) printl( "Map " + GetMapName() + " connects to " + next_map )if ( Entities.FindByName( null, "@changelevel" ) == null )
{
if(DBG) printl( "('@changelevel' entity missing, using 'map' command instead)" )
SendToConsole( "map " + next_map );
}
else
{
EntFire( "@changelevel", "Changelevel", next_map, 0.0 )
}
}
}
}
if ( next_map == null )
{
if(DBG) printl( "Map " + GetMapName() + " is the last map" )
EntFire( "end_of_playtest_text", "display", 0 )
EntFire( "@end_of_playtest_text", "display", 0 )// If we are in the map loop and at the end of the list, start over at the beginning
if ( LoopSinglePlayerMaps() )
{
printl( "MAPLOOP: No more maps, restarting loop." )
next_map = MapPlayOrder[0]
if ( Entities.FindByName( null, "@changelevel" ) == null )
{
SendToConsole( "map " + next_map );
}
else
{
EntFire( "@changelevel", "Changelevel", next_map, 0.0 )
}
}
}printl( "" )
}//================= CONSTANTS AND FUNCTIONS =======================
//============= DO NOT EDIT ANY CODE BELOW HERE ===================
//-----------------------------------------------------------------
nLevels <- 0
nCurrentLevel <- 1
units <- 1
tens <- 0
lastunits <- 0
lasttens <- 0
sNextLevel <- "none"
courseStartIndex <- 0
courseEndIndex <- 0//==================== LEVEL CHOOSER LOGIC ========================
//===================== GENERAL FUNCTIONS =========================
//-----------------------------------------------------------------
//sets the number of maps for the current course from the array
//also use this to prepare constants for the level chosen by the level choosers.
function NumberOfLevels( nCourse )
{
local counter = 0
local nCourseCompare = nCourse - 1
local levelIndex = 0
local nCurrent = 0foreach( index, map in MapPlayOrder )
{
//if( DBG ){ printl( "Loop number: " + index + " Current Map: " + MapPlayOrder[index] ) }if ( MapPlayOrder[index] == START_MAP[nCurrent] )
{
//if( DBG ){ printl ( nCurrent ) }
if ( nCurrent == nCourseCompare )
{
courseStartIndex = index
levelIndex = index
while( levelIndex <= ArrayLength() && MapPlayOrder[levelIndex] != END_MAP[nCourseCompare] )
{
if ( CheckHubMap(levelIndex) ) { counter++ }
levelIndex++
}
//adds 1 as the loop has exited before adding the final map
courseEndIndex = levelIndex
counter++//if( DBG ){ printl ( "Course: " + nCourse +" Levels: " + counter + ". LastMap: " + MapPlayOrder[courseEndIndex] + " index: " + courseEndIndex + ". FirstMap: " + MapPlayOrder[courseStartIndex] + " index: " + courseStartIndex ) }
return counter
}
nCurrent++
}
}
printl ( "Could not find any courses! Make sure the START_MAP and END_MAP is inside both their arrays and the MapPlayOrder[] Array!" )
return 0
}
//Setup of Fake Vgui and buttons on startup
function InitButtons( nCourse )
{
if( DBG ){ printl ( "========================== Course " + nCourse + " =======================" ) }
nLevels = NumberOfLevels( nCourse )
if( DBG ){ printl ( "Course: " + nCourse + " Levels: " + nLevels ) }
UpdateButtons()
SetLengthOfSlider()
}//Returns false if map in transition is the hub
function CheckHubMap( nMap ) {
if ( MapPlayOrder[nMap] == HUB_MAP ) { return false }
else { return true }
}//gets the current courses' number based off the instance
function getCourse()
{
//the course name is set inside the instance's entity group -> [5]
local nCourse = EntityGroup[5].GetName()
//Finds the last digit of instance, and gets the course number from it
local length = nCourse.len()
length--
nCourse = nCourse[length].tochar().tointeger()NumberOfLevels( nCourse )
return nCourse
}function dumpLevel() { printl ( GetMapName() ) }
//Finds length of MapPlayOrder[] array (total maps in transition)
function ArrayLength()
{
local total = 0
foreach( index, map in MapPlayOrder ) { total++ }
return total
}
//returns the current chosen map's name
function FindCurrentLevel( nCurrentLevel )
{
local j = 0
nLevels = NumberOfLevels( getCourse() )
if(DBG){ printl( getCourse() ) }if ( nCurrentLevel < 1 )
{
if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on first: " + MapPlayOrder[courseStartIndex] ) }
return MapPlayOrder[courseStartIndex]
}
if ( nCurrentLevel >= ArrayLength() )
{
if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on last: " + MapPlayOrder[courseEndIndex] ) }
return MapPlayOrder[courseEndIndex]
}foreach( index, map in MapPlayOrder )
{
if ( MapPlayOrder[index] == MapPlayOrder[courseStartIndex] )
{
j = index//we need this as we dont want to ovveride the world variable nCurrentLevel
local tempCurrentLevel = nCurrentLevel + index
//Finds the appropriate level from MapPlayOrder[] from chooser
while ( j < ArrayLength() && MapPlayOrder[j] != MapPlayOrder[courseEndIndex] )
{
if ( !CheckHubMap(j) )
{
j++
printl("Skipping Hub Map...")
}
else if( j == tempCurrentLevel - 1 )
{
if( DBG ){ printl( "#" + nCurrentLevel + " map on chooser is: " + MapPlayOrder[j] ) }
return MapPlayOrder[j]
}
j++
}if ( MapPlayOrder[j] == MapPlayOrder[courseEndIndex] )
{
if( DBG ){ printl( "#" + nCurrentLevel + " Chooser on 2last: " + MapPlayOrder[courseEndIndex] ) }
return MapPlayOrder[courseEndIndex]
}
}
}
printl ( "== Current map is not in list! ==" )
}//==================== LEVEL CHOOSER LOGIC ========================
//======================== VGUI SCREEN ============================
//-----------------------------------------------------------------
//Pressing the Right Button
function AddLevel( nCourse )
{
if ( DBG ) { printl("=================================== Add Button ============================") }
nLevels = NumberOfLevels( nCourse )
local nNewLevel = nCurrentLevel + 1
if ( nNewLevel > nLevels ){ return }
else { nCurrentLevel++ }
sNextLevel = FindCurrentLevel( nCurrentLevel )
lasttens = tens
lastunits = units
units++MoveSlider( nCurrentLevel )
UpdateCounter()
UpdateButtons()
if( textPreview ){ DisplayLevelTitle() }
}//Pressing the Left button
function SubtractLevel( nCourse )
{
if ( DBG ) { printl("============================== Subtract Button ===========================") }
nLevels = NumberOfLevels( nCourse )
local nNewLevel = nCurrentLevel - 1
if ( nNewLevel < 1 ){ return }
else { nCurrentLevel-- }sNextLevel = FindCurrentLevel( nCurrentLevel )
lasttens = tens
lastunits = units
units--MoveSlider( nCurrentLevel )
UpdateCounter()
UpdateButtons()
if( textPreview ){ DisplayLevelTitle() }
}function DisplayLevelTitle()
{
EntFire( EntityGroup[6].GetName(), "setText", FindCurrentLevel(nCurrentLevel), 0 )
EntFire( EntityGroup[6].GetName(), "Display", "", 0.1 )
}//moves the slider based off the current number and how many maps there are
function MoveSlider( nDistance )
{
local nSections = 1.0
nSections = nSections / ( nLevels - 1 )
local nMovePercentage = ( nSections * nDistance ) - nSections//for some reason the input cannot be a 0 from the script.
if ( nMovePercentage <= 0 ){ nMovePercentage = 0.0001 }if( DBG ){ printl ( "nDistance: " + nDistance + ", nMovePercentage: " + nMovePercentage + ", nSections: " + nSections ) }
EntFire( EntityGroup[2].GetName(), "SetPosition", nMovePercentage, 0 )
}//Displays Numbers of current course chosen
function UpdateCounter()
{
if ( units > 9 ) {
tens++
units = 0
}
if ( units < 0 ) {
tens--
units = 9
}
if ( tens > 9 || tens < 0 ) { tens = 0 }
if ( tens == lasttens ) { lasttens = 9 }//Enables and disables the correct level numbers
EntFire( EntityGroup[3].GetName() + "" + tens, "Enable", "", 0 )
EntFire( EntityGroup[3].GetName() + "" + lasttens, "Disable", "", 0 )
EntFire( EntityGroup[4].GetName() + "" + units, "Enable", "", 0 )
EntFire( EntityGroup[4].GetName() + "" + lastunits, "Disable", "", 0 )
}//Decides what length to set the slider depending on how many levels are in course. More courses will make the slider smaller.
function SetLengthOfSlider()
{
local nSlider = 0
if ( nLevels == 1) { nSlider = 1 }
if ( nLevels == 2) { nSlider = 2 }
if ( nLevels == 3) { nSlider = 3 }
if ( nLevels == 4) { nSlider = 4 }
if ( nLevels == 5 || nLevels == 6 ) { nSlider = 5 }
if ( nLevels >= 7 && nLevels <= 9 ) { nSlider = 6 }
if ( nLevels >= 10 && nLevels <= 13 ) { nSlider = 7 }
if ( nLevels >= 14 && nLevels <= 20 ) { nSlider = 8 }
if ( nLevels >= 21 ) { nSlider = 9 }if( DBG ){ printl ( "Slider # is: " + nSlider ) }
for ( local j = 0; j < 10; j++ )
{
if( j == nSlider )
{
EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "targetname " + EntityGroup[2].GetName(), 0)
EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "classname " + EntityGroup[2].GetName(), 0)
}
//removes every other slider except the wanted one when the loop is irated
EntFire( EntityGroup[2].GetName() + j, "Kill", "", 0)
}
}//Sets if the buttons are red or dull depending if the last or first map is currently chosen.
function UpdateButtons()
{
if ( nCurrentLevel <= 1 ) {
// turn off the left light
EntFire( EntityGroup[0].GetName(), "Skin", "1", 0)
}
else {
// turn on the left light
EntFire( EntityGroup[0].GetName(), "Skin", "0", 0)
}
if ( nCurrentLevel >= nLevels ) {
// turn off the right light
EntFire( EntityGroup[1].GetName(), "Skin", "1", 0)
}
else {
// turn on the right light
EntFire( EntityGroup[1].GetName(), "Skin", "0", 0)
}
}// --------------------------------------------------------
// MakeBatFile - dumps the map list in a formatted way, for easy recompilin'
// --------------------------------------------------------
function MakeBatFile()
{
local mapcount = 0
printl("================DUMPING maps formatted for batch file")
foreach( index, map in MapPlayOrder )
{
printl( "call build " + MapPlayOrder[index] )
}
foreach( index, map in MapPlayOrder )
{
printl( "call p2_buildcubemaps " + MapPlayOrder[index] )
}
}// this lets the elevator know that we are ready to transition.
function TransitionReady()
{
::TransitionReady <- 1
}Do note that the maps are my previously made maps. I'm just testing so that when I make the maps in the mappack, it would be problem free. So uhh...Help? D:
I need to mention something first, I copy and paste the sp_transition_list.nut and renamed it. Then, I copied some of the things inside your transition.nut and pasted in the modified sp_transition list.nut. I did that because I kept getting the error in the previous post if I used your transition.nut. D:
This is what I have in my modified sp_transition_list.nut:
- Code: Select all
DBG <- 0
FORCE_GUN_AND_HALLWAY <- 0FIRST_MAP_WITH_GUN <- "sp_a1_intro4"
FIRST_MAP_WITH_UPGRADE_GUN <- "sp_a2_laser_intro"
FIRST_MAP_WITH_POTATO_GUN <- "sp_a3_speed_ramp"
LAST_PLAYTEST_MAP <- "sp_a4_finale4"CHAPTER_TITLES <-
[
{ map = "sp_a1_intro1", title_text = "#portal2_Chapter1_Title", subtitle_text = "#portal2_Chapter1_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },
{ map = "sp_a2_laser_intro", title_text = "#portal2_Chapter2_Title", subtitle_text = "#portal2_Chapter2_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_sphere_peek", title_text = "#portal2_Chapter3_Title", subtitle_text = "#portal2_Chapter3_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_column_blocker", title_text = "#portal2_Chapter4_Title", subtitle_text = "#portal2_Chapter4_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a2_bts3", title_text = "#portal2_Chapter5_Title", subtitle_text = "#portal2_Chapter5_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },
{ map = "sp_a3_00", title_text = "#portal2_Chapter6_Title", subtitle_text = "#portal2_Chapter6_Subtitle", displayOnSpawn = true, displaydelay = 1.5 },
{ map = "sp_a3_speed_ramp", title_text = "#portal2_Chapter7_Title", subtitle_text = "#portal2_Chapter7_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },
{ map = "sp_a4_intro", title_text = "#portal2_Chapter8_Title", subtitle_text = "#portal2_Chapter8_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },
{ map = "sp_a4_finale1", title_text = "#portal2_Chapter9_Title", subtitle_text = "#portal2_Chapter9_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },
]// Display the chapter title
function DisplayChapterTitle()
{
foreach (index, level in CHAPTER_TITLES)
{
if (level.map == GetMapName() )
{
EntFire( "@chapter_title_text", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@chapter_title_text", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@chapter_title_text", "SetPosY", "0.32", 0.0 )
EntFire( "@chapter_title_text", "SetText", level.title_text, 0.0 )
EntFire( "@chapter_title_text", "display", "", level.displaydelay )
EntFire( "@chapter_subtitle_text", "SetTextColor", "210 210 210 128", 0.0 )
EntFire( "@chapter_subtitle_text", "SetTextColor2", "50 90 116 128", 0.0 )
EntFire( "@chapter_subtitle_text", "SetPosY", "0.35", 0.0 )
EntFire( "@chapter_subtitle_text", "settext", level.subtitle_text, 0.0 )
EntFire( "@chapter_subtitle_text", "display", "", level.displaydelay )
}
}
}// Display the chapter title on spawn if it is flagged to show up on spawn
function TryDisplayChapterTitle()
{
foreach (index, level in CHAPTER_TITLES)
{
if (level.map == GetMapName() && level.displayOnSpawn )
{
DisplayChapterTitle()
}
}
}LOOP_TIMER <- 0
initialized <- false
// This is the order to play the maps
MapPlayOrder<- [// ===================================================
// ====================== ACT 1 ======================
// ===================================================// ---------------------------------------------------
// Intro
// ---------------------------------------------------
"sp_a1_intro1", // motel to box-on-button
"sp_a1_intro2", // portal carousel
"sp_a1_intro3", // fall-through-floor, dioramas, portal gun
"sp_a1_intro4", // box-in-hole for placing on button
"sp_a1_intro5", // fling hinting
"sp_a1_intro6", // fling training
"sp_a1_intro7", // wheatley meetup
"sp_a1_wakeup", // glados
"@incinerator",// ===================================================
// ====================== ACT 2 ======================
// ==================================================="sp_a2_intro", // upgraded portal gun track
// ---------------------------------------------------
// Lasers
// ---------------------------------------------------
"sp_a2_laser_intro",
"sp_a2_laser_stairs",
"sp_a2_dual_lasers",
"sp_a2_laser_over_goo",// ---------------------------------------------------
// Catapult
// ---------------------------------------------------
"sp_a2_catapult_intro",
"sp_a2_trust_fling",// ---------------------------------------------------
// More Lasers
// ---------------------------------------------------
"sp_a2_pit_flings",
"sp_a2_fizzler_intro",// ---------------------------------------------------
// Lasers + Catapult
// ---------------------------------------------------
"sp_a2_sphere_peek",
"sp_a2_ricochet",// ---------------------------------------------------
// Bridges
// ---------------------------------------------------
"sp_a2_bridge_intro",
"sp_a2_bridge_the_gap",// ---------------------------------------------------
// Turrets
// ---------------------------------------------------
"sp_a2_turret_intro",
"sp_a2_laser_relays", // breather
"sp_a2_turret_blocker",
"sp_a2_laser_vs_turret", // Elevator Glados Chat - Should be removed?// ---------------------------------------------------
// Graduation
// ---------------------------------------------------
"sp_a2_pull_the_rug",
"sp_a2_column_blocker", // Elevator_vista
"sp_a2_laser_chaining",
//"sp_a2_turret_tower",
"sp_a2_triple_laser",// ---------------------------------------------------
// Sabotage
// ---------------------------------------------------"sp_a2_bts1",
"sp_a2_bts2",
"sp_a2_bts3",
"sp_a2_bts4",
"sp_a2_bts5",
"sp_a2_bts6",// ---------------------------------------------------
// Glados Chamber Sequence
// ---------------------------------------------------
"sp_a2_core",// ===================================================
// ====================== ACT 3 ======================
// ===================================================// ---------------------------------------------------
// Underground
// ---------------------------------------------------"@bottomless_pit",
"sp_a3_00",
"sp_a3_01",
"sp_a3_03",
"@test_dome_lift",
"sp_a3_jump_intro",
"@test_dome_lift",
"sp_a3_bomb_flings",
"@test_dome_lift",
"sp_a3_crazy_box",
"@test_dome_lift",
"sp_a3_transition01",
"@test_dome_lift",
"sp_a3_speed_ramp",
"@test_dome_lift",
"sp_a3_speed_flings",
"@test_dome_lift",
"sp_a3_portal_intro",
"@hallway",
"sp_a3_end",// ===================================================
// ====================== ACT 4 ======================
// ===================================================// ---------------------------------------------------
// Recapture
// ---------------------------------------------------
"sp_a4_intro",// ---------------------------------------------------
// Tractor beam
// ---------------------------------------------------
"sp_a4_tb_intro",
"sp_a4_tb_trust_drop",
// "@hallway",
"sp_a4_tb_wall_button",
// "@hallway",
"sp_a4_tb_polarity",
// "@hallway",
"sp_a4_tb_catch", // GRAD// ---------------------------------------------------
// Crushers
// ---------------------------------------------------// ---------------------------------------------------
// Graduation Combos
// ---------------------------------------------------
"sp_a4_stop_the_box", // Grad?
// "@hallway",
"sp_a4_laser_catapult", // Grad
// "@hallway",
//"sp_catapult_course"
// "@hallway",
//"sp_box_over_goo", // Grad
// "@hallway",
"sp_a4_laser_platform",// ---------------------------------------------------
// Tbeam + Paint
// ---------------------------------------------------
//"sp_paint_jump_tbeam",
// "@hallway",
"sp_a4_speed_tb_catch",
// "@hallway",
"sp_a4_jump_polarity", // GRAD
// "@hallway",
//"sp_paint_portal_tbeams",// ---------------------------------------------------
// Wheatley Escape
// ---------------------------------------------------"sp_a4_finale1",
"@hallway",
"sp_a4_finale2",
"@hallway",
"sp_a4_finale3",
"@hallway",// ---------------------------------------------------
// FIXME: WHEATLEY BATTLE
// ---------------------------------------------------"sp_a4_finale4",
// ---------------------------------------------------
// Demo files
// ---------------------------------------------------
"demo_intro",
"demo_underground",
"demo_paint",// ---------------------------------------------------
// Mappack
// ---------------------------------------------------
"sp_mappack_hub",
"sp_security_crisis",
"sp_u_repulsive_welcome",
"sp_painting_with_gels"
]//================== CONSTANTS ( EDIT THESE ) =====================
//-----------------------------------------------------------------// Turn Debug on (1) or off (0)
DBG <- 0// Set to false if you don't want text to appear showing the name of the current chosen level on the chooser
textPreview <- true// The name of the Hub map. This the map it will transition to when all maps are finished in the current course.
// The hubmap will be ignored if tried to transition to if it is in MapPlayOrder[]
HUB_MAP <- "sp_mappack_hub"//--------------------------------------------------------------------------------
// Create new START and END maps to calculate a new level chooser for another course.
// For eg. "map1ex" is the start level and "map3ex" is the end level of the first course.
//--------------------------------------------------------------------------------
START_MAP <- [
"sp_security_crisis", //Course 1 StartMap
]END_MAP <- [
"sp_painting_with_gels", //Course 1 EndMap
]// --------------------------------------------------------
// OnPostTransition - we just transitioned, teleport us to the correct place.
// --------------------------------------------------------
function OnPostTransition()
{
local foundMap = false
foreach (index, map in MapPlayOrder)
{
if (GetMapName() == MapPlayOrder[index])
{
foundMap = true
// hook up our entry elevator
if( index - 1 >= 0 )
{
if( MapPlayOrder[index-1].find("@") == null )
{
printl( "Teleporting to default start pos" )
EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 )
EntFire( "@arrival_teleport", "Teleport", 0, 0 )
}
else
{
printl( "Trying to teleport to " + MapPlayOrder[index - 1] + "_teleport" )
EntFire( MapPlayOrder[index - 1] + "_entry_teleport", "Teleport", 0, 0.0 )
}
}
break
}
}
if (foundMap == false )
{
EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 )
EntFire( "@arrival_teleport", "Teleport", 0, 0 )
}
}// --------------------------------------------------------
// EntFire_MapLoopHelper
// --------------------------------------------------------
function EntFire_MapLoopHelper( classname, suffix, command, param, delay )
{
// This calls EntFire on an entity of a given type, named with the given suffix.
// This deals with instance name mangling (though it doesn't guarantee uniqueness)
local suffix_len = suffix.len()
for ( local ent = Entities.FindByClassname( null, classname ); ent != null; ent = Entities.FindByClassname( ent, classname ) )
{
local ent_name = ent.GetName()
local suffix_offset = ent_name.find( suffix )
if ( ( suffix_offset != null ) && ( suffix_offset == ( ent_name.len() - suffix_len ) ) )
{
EntFire( ent_name, command, param, delay )
return
}
}
printl( "MAPLOOP: ---- ERROR! Failed to find entity " + suffix + " while initiating map transition" );
}// --------------------------------------------------------
// Think
// --------------------------------------------------------
function Think()
{
// Start the game loop if the cvar is set
if ( initialized && LoopSinglePlayerMaps() )
{
// initialize the timer
if( LOOP_TIMER == 0 )
{
LOOP_TIMER = Time() + 10 // restart time in seconds
}
// transition to the next map if the timer has expired
if ( LOOP_TIMER < Time() )
{
// reset loop timer
LOOP_TIMER = 0printl( "nMAPLOOP: timer expired, moving on..." )
// Ensure point_viewcontrollers are disabled
EntFire( "point_viewcontrol", "disable", 0, 0 )
// Change the level (this sequence was originally in the 'transition_without_survey' logic_relay)
EntFire_MapLoopHelper( "trigger_once", "survey_trigger", "Disable", "", 0.0 )
EntFire_MapLoopHelper( "env_fade", "exit_fade", "Fade", "", 0.0 )
EntFire_MapLoopHelper( "point_teleport", "exit_teleport", "Teleport", "", 0.3 )
EntFire_MapLoopHelper( "logic_script", "transition_script", "RunScriptCode", "TransitionFromMap()", 0.4 )
}
}
if (initialized)
{
return
}
initialized = true// position fixup for sp_a3_01, in case player has fallen outside map
if (GetMapName() == "sp_a3_01")
{
printl( "--------------- FIXING PLAYER POSITION FOR sp_a3_01" )local destination_name = "knockout-teleport" // targetname of the destination entity
local player_ent = nulllocal destination_ent = null
// find the player
player_ent = Entities.FindByClassname( player_ent, "player" )if ( player_ent == null )
{
printl("*** Cannot find player. Aborting!")
return;
}// find the destination entity
destination_ent = Entities.FindByName( destination_ent, destination_name )if ( destination_ent == null )
{
printl("*** Cannot find destination entity " + destination_name + ". Aborting!")
return;
}
// move the player to the destination
player.SetOrigin( destination_ent.GetOrigin() )
}DumpMapList()
local portalGunCommand = ""
local portalGunSecondCommand = ""
local foundMap = false
foreach (index, map in MapPlayOrder)
{
if (MapPlayOrder[index] == FIRST_MAP_WITH_GUN)
{
portalGunCommand = "give_portalgun"
}
else if (MapPlayOrder[index] == FIRST_MAP_WITH_UPGRADE_GUN)
{
portalGunSecondCommand = "upgrade_portalgun"
}
else if (MapPlayOrder[index] == FIRST_MAP_WITH_POTATO_GUN)
{
portalGunSecondCommand = "upgrade_potatogun"
}
if (GetMapName() == MapPlayOrder[index])
{
break
}
}TryDisplayChapterTitle()
if (portalGunCommand != "" && GetMapName() != "sp_a2_intro" && GetMapName() != "sp_a3_01" )
{
printl( "=======================Trying to run " + portalGunCommand )
EntFire( "command", "Command", portalGunCommand, 0.0 )
EntFire( "@command", "Command", portalGunCommand, 0.0 )
}if (portalGunSecondCommand != "")
{
printl( "=======================Trying to run " + portalGunSecondCommand )
EntFire( "command", "Command", portalGunSecondCommand, 0.1 )
EntFire( "@command", "Command", portalGunSecondCommand, 0.1 )
}
}// --------------------------------------------------------
// TransitionFromMap
// --------------------------------------------------------
function DumpMapList()
{
if(DBG)
{
local mapcount = 0
printl("================DUMPING MAP PLAY ORDER")
foreach( index, map in MapPlayOrder )
{
// weed out our transitions
if( MapPlayOrder[index].find("@") == null )
{
if( GetMapName() == MapPlayOrder[index] )
{
printl( mapcount + " " + MapPlayOrder[index] + " <--- You Are Here" )
}
else
{
printl( mapcount + " " + MapPlayOrder[index] )
}
mapcount++
}
}
printl( mapcount + " maps total." )
printl("================END DUMP")
}
}// --------------------------------------------------------
// TransitionFromMap
// --------------------------------------------------------
function TransitionFromMap()
{
local next_map = null
foreach( index, map in MapPlayOrder )
{
if( GetMapName() == MapPlayOrder[index] )
{
// make good
local skipIndex = index
for(local i=0;i<2;i+=1)
{
if( skipIndex + 1 < MapPlayOrder.len() )
{
if( MapPlayOrder[skipIndex + 1].find("@") != null )
{
skipIndex++
}
else
{
break
}
}
}
if( ( skipIndex + 1 < MapPlayOrder.len() ) &&
( GetMapName() != LAST_PLAYTEST_MAP ) )
{
next_map = MapPlayOrder[ skipIndex + 1 ]
if(DBG) printl( "Map " + GetMapName() + " connects to " + next_map )if ( Entities.FindByName( null, "@changelevel" ) == null )
{
if(DBG) printl( "('@changelevel' entity missing, using 'map' command instead)" )
SendToConsole( "map " + next_map );
}
else
{
EntFire( "@changelevel", "Changelevel", next_map, 0.0 )
}
}
}
}
if ( next_map == null )
{
if(DBG) printl( "Map " + GetMapName() + " is the last map" )
EntFire( "end_of_playtest_text", "display", 0 )
EntFire( "@end_of_playtest_text", "display", 0 )// If we are in the map loop and at the end of the list, start over at the beginning
if ( LoopSinglePlayerMaps() )
{
printl( "MAPLOOP: No more maps, restarting loop." )
next_map = MapPlayOrder[0]
if ( Entities.FindByName( null, "@changelevel" ) == null )
{
SendToConsole( "map " + next_map );
}
else
{
EntFire( "@changelevel", "Changelevel", next_map, 0.0 )
}
}
}printl( "" )
}//================= CONSTANTS AND FUNCTIONS =======================
//============= DO NOT EDIT ANY CODE BELOW HERE ===================
//-----------------------------------------------------------------
nLevels <- 0
nCurrentLevel <- 1
units <- 1
tens <- 0
lastunits <- 0
lasttens <- 0
sNextLevel <- "none"
courseStartIndex <- 0
courseEndIndex <- 0//==================== LEVEL CHOOSER LOGIC ========================
//===================== GENERAL FUNCTIONS =========================
//-----------------------------------------------------------------
//sets the number of maps for the current course from the array
//also use this to prepare constants for the level chosen by the level choosers.
function NumberOfLevels( nCourse )
{
local counter = 0
local nCourseCompare = nCourse - 1
local levelIndex = 0
local nCurrent = 0foreach( index, map in MapPlayOrder )
{
//if( DBG ){ printl( "Loop number: " + index + " Current Map: " + MapPlayOrder[index] ) }if ( MapPlayOrder[index] == START_MAP[nCurrent] )
{
//if( DBG ){ printl ( nCurrent ) }
if ( nCurrent == nCourseCompare )
{
courseStartIndex = index
levelIndex = index
while( levelIndex <= ArrayLength() && MapPlayOrder[levelIndex] != END_MAP[nCourseCompare] )
{
if ( CheckHubMap(levelIndex) ) { counter++ }
levelIndex++
}
//adds 1 as the loop has exited before adding the final map
courseEndIndex = levelIndex
counter++//if( DBG ){ printl ( "Course: " + nCourse +" Levels: " + counter + ". LastMap: " + MapPlayOrder[courseEndIndex] + " index: " + courseEndIndex + ". FirstMap: " + MapPlayOrder[courseStartIndex] + " index: " + courseStartIndex ) }
return counter
}
nCurrent++
}
}
printl ( "Could not find any courses! Make sure the START_MAP and END_MAP is inside both their arrays and the MapPlayOrder[] Array!" )
return 0
}
//Setup of Fake Vgui and buttons on startup
function InitButtons( nCourse )
{
if( DBG ){ printl ( "========================== Course " + nCourse + " =======================" ) }
nLevels = NumberOfLevels( nCourse )
if( DBG ){ printl ( "Course: " + nCourse + " Levels: " + nLevels ) }
UpdateButtons()
SetLengthOfSlider()
}//Returns false if map in transition is the hub
function CheckHubMap( nMap ) {
if ( MapPlayOrder[nMap] == HUB_MAP ) { return false }
else { return true }
}//gets the current courses' number based off the instance
function getCourse()
{
//the course name is set inside the instance's entity group -> [5]
local nCourse = EntityGroup[5].GetName()
//Finds the last digit of instance, and gets the course number from it
local length = nCourse.len()
length--
nCourse = nCourse[length].tochar().tointeger()NumberOfLevels( nCourse )
return nCourse
}function dumpLevel() { printl ( GetMapName() ) }
//Finds length of MapPlayOrder[] array (total maps in transition)
function ArrayLength()
{
local total = 0
foreach( index, map in MapPlayOrder ) { total++ }
return total
}
//returns the current chosen map's name
function FindCurrentLevel( nCurrentLevel )
{
local j = 0
nLevels = NumberOfLevels( getCourse() )
if(DBG){ printl( getCourse() ) }if ( nCurrentLevel < 1 )
{
if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on first: " + MapPlayOrder[courseStartIndex] ) }
return MapPlayOrder[courseStartIndex]
}
if ( nCurrentLevel >= ArrayLength() )
{
if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on last: " + MapPlayOrder[courseEndIndex] ) }
return MapPlayOrder[courseEndIndex]
}foreach( index, map in MapPlayOrder )
{
if ( MapPlayOrder[index] == MapPlayOrder[courseStartIndex] )
{
j = index//we need this as we dont want to ovveride the world variable nCurrentLevel
local tempCurrentLevel = nCurrentLevel + index
//Finds the appropriate level from MapPlayOrder[] from chooser
while ( j < ArrayLength() && MapPlayOrder[j] != MapPlayOrder[courseEndIndex] )
{
if ( !CheckHubMap(j) )
{
j++
printl("Skipping Hub Map...")
}
else if( j == tempCurrentLevel - 1 )
{
if( DBG ){ printl( "#" + nCurrentLevel + " map on chooser is: " + MapPlayOrder[j] ) }
return MapPlayOrder[j]
}
j++
}if ( MapPlayOrder[j] == MapPlayOrder[courseEndIndex] )
{
if( DBG ){ printl( "#" + nCurrentLevel + " Chooser on 2last: " + MapPlayOrder[courseEndIndex] ) }
return MapPlayOrder[courseEndIndex]
}
}
}
printl ( "== Current map is not in list! ==" )
}//==================== LEVEL CHOOSER LOGIC ========================
//======================== VGUI SCREEN ============================
//-----------------------------------------------------------------
//Pressing the Right Button
function AddLevel( nCourse )
{
if ( DBG ) { printl("=================================== Add Button ============================") }
nLevels = NumberOfLevels( nCourse )
local nNewLevel = nCurrentLevel + 1
if ( nNewLevel > nLevels ){ return }
else { nCurrentLevel++ }
sNextLevel = FindCurrentLevel( nCurrentLevel )
lasttens = tens
lastunits = units
units++MoveSlider( nCurrentLevel )
UpdateCounter()
UpdateButtons()
if( textPreview ){ DisplayLevelTitle() }
}//Pressing the Left button
function SubtractLevel( nCourse )
{
if ( DBG ) { printl("============================== Subtract Button ===========================") }
nLevels = NumberOfLevels( nCourse )
local nNewLevel = nCurrentLevel - 1
if ( nNewLevel < 1 ){ return }
else { nCurrentLevel-- }sNextLevel = FindCurrentLevel( nCurrentLevel )
lasttens = tens
lastunits = units
units--MoveSlider( nCurrentLevel )
UpdateCounter()
UpdateButtons()
if( textPreview ){ DisplayLevelTitle() }
}function DisplayLevelTitle()
{
EntFire( EntityGroup[6].GetName(), "setText", FindCurrentLevel(nCurrentLevel), 0 )
EntFire( EntityGroup[6].GetName(), "Display", "", 0.1 )
}//moves the slider based off the current number and how many maps there are
function MoveSlider( nDistance )
{
local nSections = 1.0
nSections = nSections / ( nLevels - 1 )
local nMovePercentage = ( nSections * nDistance ) - nSections//for some reason the input cannot be a 0 from the script.
if ( nMovePercentage <= 0 ){ nMovePercentage = 0.0001 }if( DBG ){ printl ( "nDistance: " + nDistance + ", nMovePercentage: " + nMovePercentage + ", nSections: " + nSections ) }
EntFire( EntityGroup[2].GetName(), "SetPosition", nMovePercentage, 0 )
}//Displays Numbers of current course chosen
function UpdateCounter()
{
if ( units > 9 ) {
tens++
units = 0
}
if ( units < 0 ) {
tens--
units = 9
}
if ( tens > 9 || tens < 0 ) { tens = 0 }
if ( tens == lasttens ) { lasttens = 9 }//Enables and disables the correct level numbers
EntFire( EntityGroup[3].GetName() + "" + tens, "Enable", "", 0 )
EntFire( EntityGroup[3].GetName() + "" + lasttens, "Disable", "", 0 )
EntFire( EntityGroup[4].GetName() + "" + units, "Enable", "", 0 )
EntFire( EntityGroup[4].GetName() + "" + lastunits, "Disable", "", 0 )
}//Decides what length to set the slider depending on how many levels are in course. More courses will make the slider smaller.
function SetLengthOfSlider()
{
local nSlider = 0
if ( nLevels == 1) { nSlider = 1 }
if ( nLevels == 2) { nSlider = 2 }
if ( nLevels == 3) { nSlider = 3 }
if ( nLevels == 4) { nSlider = 4 }
if ( nLevels == 5 || nLevels == 6 ) { nSlider = 5 }
if ( nLevels >= 7 && nLevels <= 9 ) { nSlider = 6 }
if ( nLevels >= 10 && nLevels <= 13 ) { nSlider = 7 }
if ( nLevels >= 14 && nLevels <= 20 ) { nSlider = 8 }
if ( nLevels >= 21 ) { nSlider = 9 }if( DBG ){ printl ( "Slider # is: " + nSlider ) }
for ( local j = 0; j < 10; j++ )
{
if( j == nSlider )
{
EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "targetname " + EntityGroup[2].GetName(), 0)
EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "classname " + EntityGroup[2].GetName(), 0)
}
//removes every other slider except the wanted one when the loop is irated
EntFire( EntityGroup[2].GetName() + j, "Kill", "", 0)
}
}//Sets if the buttons are red or dull depending if the last or first map is currently chosen.
function UpdateButtons()
{
if ( nCurrentLevel <= 1 ) {
// turn off the left light
EntFire( EntityGroup[0].GetName(), "Skin", "1", 0)
}
else {
// turn on the left light
EntFire( EntityGroup[0].GetName(), "Skin", "0", 0)
}
if ( nCurrentLevel >= nLevels ) {
// turn off the right light
EntFire( EntityGroup[1].GetName(), "Skin", "1", 0)
}
else {
// turn on the right light
EntFire( EntityGroup[1].GetName(), "Skin", "0", 0)
}
}// --------------------------------------------------------
// MakeBatFile - dumps the map list in a formatted way, for easy recompilin'
// --------------------------------------------------------
function MakeBatFile()
{
local mapcount = 0
printl("================DUMPING maps formatted for batch file")
foreach( index, map in MapPlayOrder )
{
printl( "call build " + MapPlayOrder[index] )
}
foreach( index, map in MapPlayOrder )
{
printl( "call p2_buildcubemaps " + MapPlayOrder[index] )
}
}// this lets the elevator know that we are ready to transition.
function TransitionReady()
{
::TransitionReady <- 1
}
Do note that the maps are my previously made maps. I'm just testing so that when I make the maps in the mappack, it would be problem free. So uhh...Help? D:
Quote from ChickenMobile on August 11, 2012, 10:09 amHrmmm.. I don't like your modified script idea. Perhaps some values are conflicting names?
/me will test SP transition with choosers
EDIT: works fine for me.
Hrmmm.. I don't like your modified script idea. Perhaps some values are conflicting names?
/me will test SP transition with choosers
EDIT: works fine for me.
Quote from RectorRocks on August 11, 2012, 10:30 amBesides doing this, I really have no idea how to do it. If I use your transition script, I spawn in the transition box and the arrows are gray, and also the error "level_chooser-transition_script encountered an error on RunScript()"...something like that. Oh, are you saying that you're gonna try to figure out how to use the Level Chooser for SP? Yes, please! Thanks! ^^v
Besides doing this, I really have no idea how to do it. If I use your transition script, I spawn in the transition box and the arrows are gray, and also the error "level_chooser-transition_script encountered an error on RunScript()"...something like that. Oh, are you saying that you're gonna try to figure out how to use the Level Chooser for SP? Yes, please! Thanks! ^^v
Quote from ChickenMobile on August 11, 2012, 10:54 amA few things to consider:
1. Name your Hub transition instance the same as your chooser
2. You have to include the start map and end map inside the map order array also (in correct order)
3. You have to call the "setActiveCourse($Course)" function before the "TransitionFromHub()" function.Here's my script and custom instances which work in SP. Note: you have to place the script in scripts/vscripts/chicken_scripts/
chooser.7z
A few things to consider:
1. Name your Hub transition instance the same as your chooser
2. You have to include the start map and end map inside the map order array also (in correct order)
3. You have to call the "setActiveCourse($Course)" function before the "TransitionFromHub()" function.
Here's my script and custom instances which work in SP. Note: you have to place the script in scripts/vscripts/chicken_scripts/
Quote from RectorRocks on August 11, 2012, 11:04 amChickenMobile wrote:A few things to consider:
1. Name your Hub transition instance the same as your chooser
2. You have to include the start map and end map inside the map order array also (in correct order)
3. You have to call the "setActiveCourse($Course)" function before the "TransitionFromHub()" function.Here's my script and custom instances which work in SP. Note: you have to place the script in scripts/vscripts/chicken_scripts/
chooser.7zThanks! I did 1. and 2. , but how do I do 3. ?
1. Name your Hub transition instance the same as your chooser
2. You have to include the start map and end map inside the map order array also (in correct order)
3. You have to call the "setActiveCourse($Course)" function before the "TransitionFromHub()" function.
Here's my script and custom instances which work in SP. Note: you have to place the script in scripts/vscripts/chicken_scripts/
Thanks! I did 1. and 2. , but how do I do 3. ?