Coop Transition Script and Level Choosers
by ChickenMobile · Uploaded Apr 03, 2012
File Size: 0.37 MB
Downloads: 257
Rating: (4 votes)
Description
This Transition script and custom level choosers can be used to transition to different maps and courses through a hub map (like Valves). The level choosers can choose from any map in the course and it can display what map you are choosing with a message appearing on the screen. You can have 'infinite' courses inside your script, however both players need the same maps in order for the map to transition to it. If anyone wants to make a coop mass mack-pack (from everyone's coop maps), go ahead. It is definitely possible. Refer to the README.txt included with the download for installation instructions and common problems with fixes. If you have a problem and you cannot find an answer to it: put a post in this thread or PM me so we can get it working. One thing I don't know how to do (yet) is to save a player's progress and make the courses 'unlockable', even if the player has ended the game and then goes back to it (with the same or different partner). If anyone can tell me how to read and write to a file, I would gladly edit this and put this function in. If you are to use my instances/script/materials make sure you credit me within your map download or in your credits! Anyway, enjoy! ChickenMobile EDIT: From a very nice person I found out that there are a few errors with this: - The map doesn't transition without a point_servercommand called @command in your map - I forgot a major script that opens the chooser panel - Updated the Readme file to account for a new problem found - You don't have to use my coop spawner instance (your welcome to use your own) Guaranteed all things are now fixed! EDIT: Sorry guys for uploading the wrong file. Fixed in double time.
Comments
Sign in to comment.
chickenmobile wrote:
Remember that you have to use my coop spawner and end_room otherwise the script will not transition to the next map.
Do I have to use your coop spawner? I can't find any differences between your spawner and the one I am using. And I have my own custom end room. So I guess I have to change the changelevel script to the one you've made. Is that all I have to do in Hammer?
Thank you!
Hey, I have a problem with downloading. I can only download the Credits Script, instead of the Transition Script, maybe you have updated something wrong?
EDIT: This could also be a bug, because they both have the same filename.
This contains the same file as the credits instance you recently uploaded. Please upload the right instance, I think this could be really really awesome! 
Jepp wrote:
This contains the same file as the credits instance you recently uploaded. Please upload the right instance, I think this could be really really awesome!
Oooops. Archives were named the same thing...
Uploading again...
I would like to post a quick note here:
This is meant for multiple maps to work with a level chooser, NOT for a series of maps you could transition to normally one after the other IF YOU DON'T WANT A LEVEL CHOOSER.
If you want a simple transition, look at this page on how: https://developer.valvesoftware.com/wiki/Level_Transition_(Portal_2)
Quick note 2: If you are to use this; make sure you replace any paths for scripts I included (as well as the paths in the instances) so then it doesn't replace other people's transition script downloaded here.
Do ineed all of my maps done in order for transistion to work? I have the hub done and a testchamber In-Progress, But theres more chambers after that in my script. But when I go to test the transstion, It just loads and loads and oads and loads and loads!
Check the console to see if you have put the scripts in correct folder. If you go into the disassembler and in the console you are getting a 'The index 'functionname' does not exist', then your script is not in the right location.
You will have to edit all the logic_scripts and make it point towards the relevant path if you decided to create your own custom folder for your scripts.
And you do not need all your maps done before you can use the transition: technically you can transition to a map without any of my custom instances inside your map from your hub with the level chooser, however it is necessary if you want to transition to multiple maps in one course (one coop map to the other).
Refer to the examples provided to see how it works. Also make sure to compile and test them as well (if nothing happens its purely a script location problem).
I didnt make a custom folder or nothing. I followed the FAQ and made sure everything in my hub matched your hub, except the rotation. could it be that the first map dosen't have a dissasembler?
Also I cant run yours case therye not connected in the script. I replaced your maps (except course 2, 1 course map at the moment) with mine. I also edit the constants and the hubmap in the script
The hub map will have to use the hub disassembler instance.
EDIT: have you added your map names into the script?
I just want to imply that if you use packrat you can put a new hubmap as your last chamber of the first "chapter", and packrat in a new transition script (with the same name as before of course) into that new hub, but with another chapter in it. In the new hub you have then "unlocked" the door to the second chapter, giving the illusion of progress
You can set your new hub as starthub in your new script, the only problem is that the players need to be informed about the new hub filename if they want to quit and get back to the correct hub afterwards. Another flaw is that you need to include more than one hub in your release, but it's the only way I've managed to perceive this.
As for your problem, make sure both the dissemblers, the chooser in the hub and all the endlevel instances that are in the same chapter have the same name, that would get you that issue atleast.
Two EDITS: Correcting bad english and typos
Yes I have my maps names in the transistion script, I peeked at the chooser script and didnt see any thing i had to edit, And YES the hub has the hub dissasemblers.
put your transition script in [code] tags so I can squiz at it
EDIT: also what appeared in your consolel (if anything) when you try to transition?
Okay so now I have added the dissembler in my chamber and named it the same as the dissembler and chooser in my hub, but when i try to transition to the chamber from the hub I get the error that my dissembler doesn't have the animation eggbot cradle or whatever. and stuff like cant findcl_thirdperson and cl_mouselook. before i added the dissasembler in my chamber I only got the eggbot one. AND MY CHAMBER STILL WONT TRANSITION!
Heres my transition://--------------------------------------------------------------------------------<br />//====================== CUSTOM COOP TRANSITION SCRIPT ===========================<br />//========================== MADE BY CHICKENMOBILE ===============================<br />//--------------------------------------------------------------------------------<br />//PLEASE REFER TO THE README FILE INCLUDED WITH DOWNLOAD FOR ANY EXTRA INFORMATION<br />// OR LOOK AT THE COMMENTS TO KNOW WHERE TO PLACE EXTRA CODE<br />// REMEMBER TO REMOVE ANY COMMENTS '//' IN FRONT OF LINES TO MAKE THE CODE ACTIVE<br />//--------------------------------------------------------------------------------<br /><br />//================== CONSTANTS ( EDIT THESE ) =====================<br />//-----------------------------------------------------------------<br /><br />// Turn Debug on (1) or off (0)<br />DBG <- 0<br /><br />// Set to false if you don't want text to appear showing the name of the current chosen level on the chooser<br />textPreview <- false<br /><br />// The name of the Hub map. This the map it will transition to when all maps are finished in the current course.<br />// The hubmap will be ignored if tried to transition to if it is in MapPlayOrder[]<br />HUB_MAP <- "mp_coop_history_hub"<br /><br />//--------------------------------------------------------------------------------<br />// Create new START and END maps to calculate a new level chooser for another course.<br />// For eg. "map1ex" is the start level and "map3ex" is the end level of the first course.<br />//--------------------------------------------------------------------------------<br />START_MAP <- [ <br />"mp_coop_map_01", //Course 1 StartMap<br />//"mp_coop_map2ex", //Course 2 StartMap<br />]<br /><br />END_MAP <- [ <br />"mp_coop_map_end", //Course 1 EndMap<br />//"mp_coop_map4ex", //Course 2 EndMap<br />]<br /><br />//============================= MapPlayOrder[] ===================================<br />// This is the order to play the maps. <br />// Add any extra courses as a new START and END level in the arrays above.<br />// Note: both the start map and endmap need to appear in mapplayorder<br />//--------------------------------------------------------------------------------<br />MapPlayOrder<- [<br />"mp_coop_map_01",<br />"mp_coop_map_02",<br />"mp_coop_map_03",<br />"mp_coop_map_04",<br />"mp_coop_map_05",<br />"mp_coop_map_06",<br />"mp_coop_map_07",<br />"mp_coop_map_08",<br />"mp_coop_map_end",<br /><br />//=== EXAMPLE NEXT COURSE === <br />//"mp_coop_map2ex", <br />//"mp_coop_map5ex",<br />//"mp_coop_map6ex", <br />//"mp_coop_map4ex", <br />]<br /><br />//============================= CHAPTER_TITLES ===================================<br />// This is the array that holds the titles. Add a new Chapter title by copying and<br />// pasting a new entry if another chapter exists within another map in the transition. <br />// Ignore this if you don't want names of chapters to appear<br />//--------------------------------------------------------------------------------<br />CHAPTER_TITLES <- <br />[<br /> { map = "mp_coop_map2ex", title_text = "CHAPTER NUMBER", subtitle_text = "CHAPTER NAME", displayOnSpawn = true, displaydelay = 1.0 },<br /> //{ map = START_MAP[1], title_text = "CHAPTER 2", subtitle_text = "EXAMPLE CHAPTER NAME", displayOnSpawn = false, displaydelay = 2.0 },<br />]<br /><br />//================= CONSTANTS AND FUNCTIONS =======================<br />//============= DO NOT EDIT ANY CODE BELOW HERE ===================<br />//-----------------------------------------------------------------<br />nLevels <- 0<br />nCurrentLevel <- 1<br />units <- 1<br />tens <- 0<br />lastunits <- 0<br />lasttens <- 0<br />sNextLevel <- "none"<br />courseStartIndex <- 0<br />courseEndIndex <- 0<br /><br />//======================== TRANSITIONS ============================<br />//-----------------------------------------------------------------<br /><br />//called when level finished and next map is to be played<br />function TransitionFromMap()<br />{<br /> local lastmap = false<br /> <br /> foreach( index, map in END_MAP )<br /> {<br /> if ( END_MAP[index] == GetMapName() ) { lastmap = true }<br /> }<br /> foreach( index, map in MapPlayOrder )<br /> {<br /> if ( MapPlayOrder[index] == GetMapName() )<br /> {<br /> if ( lastmap ) { EntFire( "@command", "command", "changelevel " + HUB_MAP, 0 ) }<br /> else { <br /> sNextLevel = MapPlayOrder[index + 1]<br /> EntFire( "@command", "command", "changelevel " + sNextLevel, 0 ) <br /> }<br /> return<br /> }<br /> }<br /> printl ( "Current map is not in list or has no map following!" )<br />}<br /><br />//Called when disassembled from hub<br />function TransitionFromHub()<br />{<br /> EntFire( "@command", "command", "changelevel " + sNextLevel, 0 )<br />}<br /><br />//Call this when both bots are in disassemblers so right course and level is transitioned<br />function setActiveCourse( nCourse )<br />{<br /> nLevels = NumberOfLevels( nCourse )<br /> sNextLevel = FindCurrentLevel( nCurrentLevel )<br /> if( DBG ) printl( "Changing course to: " + nCourse + " Level: " + nCurrentLevel + " out of: " + nLevels + ". Map: " + sNextLevel )<br />}<br /><br />//==================== LEVEL CHOOSER LOGIC ========================<br />//===================== GENERAL FUNCTIONS =========================<br />//-----------------------------------------------------------------<br />//sets the number of maps for the current course from the array<br />//also use this to prepare constants for the level chosen by the level choosers.<br />function NumberOfLevels( nCourse )<br />{<br /> local counter = 0<br /> local nCourseCompare = nCourse - 1<br /> local levelIndex = 0<br /> local nCurrent = 0<br /><br /> foreach( index, map in MapPlayOrder )<br /> {<br /> //if( DBG ){ printl( "Loop number: " + index + " Current Map: " + MapPlayOrder[index] ) }<br /><br /> if ( MapPlayOrder[index] == START_MAP[nCurrent] )<br /> {<br /> //if( DBG ){ printl ( nCurrent ) }<br /> if ( nCurrent == nCourseCompare )<br /> {<br /> courseStartIndex = index<br /> levelIndex = index<br /> while( levelIndex <= ArrayLength() && MapPlayOrder[levelIndex] != END_MAP[nCourseCompare] )<br /> {<br /> if ( CheckHubMap(levelIndex) ) { counter++ }<br /> levelIndex++<br /> }<br /> //adds 1 as the loop has exited before adding the final map<br /> courseEndIndex = levelIndex<br /> counter++<br /><br /> //if( DBG ){ printl ( "Course: " + nCourse +" Levels: " + counter + ". LastMap: " + MapPlayOrder[courseEndIndex] + " index: " + courseEndIndex + ". FirstMap: " + MapPlayOrder[courseStartIndex] + " index: " + courseStartIndex ) }<br /> return counter<br /> }<br /> nCurrent++ <br /> }<br /> }<br /> printl ( "Could not find any courses! Make sure the START_MAP and END_MAP is inside both their arrays and the MapPlayOrder[] Array!" )<br /> return 0<br />}<br />//Setup of Fake Vgui and buttons on startup<br />function InitButtons( nCourse )<br />{ <br /> if( DBG ){ printl ( "========================== Course " + nCourse + " =======================" ) }<br /> nLevels = NumberOfLevels( nCourse )<br /> if( DBG ){ printl ( "Course: " + nCourse + " Levels: " + nLevels ) }<br /> UpdateButtons()<br /> SetLengthOfSlider()<br />}<br /><br />//Returns false if map in transition is the hub<br />function CheckHubMap( nMap ) {<br /> if ( MapPlayOrder[nMap] == HUB_MAP ) { return false }<br /> else { return true }<br />}<br /><br />//gets the current courses' number based off the instance<br />function getCourse() <br />{<br /> //the course name is set inside the instance's entity group -> [5]<br /> local nCourse = EntityGroup[5].GetName()<br /> <br /> //Finds the last digit of instance, and gets the course number from it<br /> local length = nCourse.len()<br /> length--<br /> nCourse = nCourse[length].tochar().tointeger()<br /><br /> NumberOfLevels( nCourse )<br /> return nCourse<br />}<br /><br />function dumpLevel() { printl ( GetMapName() ) }<br /><br />//Finds length of MapPlayOrder[] array (total maps in transition)<br />function ArrayLength() <br />{<br /> local total = 0<br /> foreach( index, map in MapPlayOrder ) { total++ }<br /> return total<br />}<br />//returns the current chosen map's name<br />function FindCurrentLevel( nCurrentLevel )<br />{<br /> local j = 0<br /> nLevels = NumberOfLevels( getCourse() )<br /> if(DBG){ printl( getCourse() ) }<br /><br /> if ( nCurrentLevel < 1 ) <br /> { <br /> if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on first: " + MapPlayOrder[courseStartIndex] ) } <br /> return MapPlayOrder[courseStartIndex] <br /> }<br /> if ( nCurrentLevel >= ArrayLength() ) <br /> { <br /> if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on last: " + MapPlayOrder[courseEndIndex] ) }<br /> return MapPlayOrder[courseEndIndex] <br /> }<br /><br /> foreach( index, map in MapPlayOrder )<br /> {<br /> if ( MapPlayOrder[index] == MapPlayOrder[courseStartIndex] )<br /> {<br /> j = index<br /><br /> //we need this as we dont want to ovveride the world variable nCurrentLevel<br /> local tempCurrentLevel = nCurrentLevel + index<br /> <br /> //Finds the appropriate level from MapPlayOrder[] from chooser<br /> while ( j < ArrayLength() && MapPlayOrder[j] != MapPlayOrder[courseEndIndex] )<br /> {<br /> if ( !CheckHubMap(j) ) <br /> { <br /> j++ <br /> printl("Skipping Hub Map...") <br /> }<br /> else if( j == tempCurrentLevel - 1 ) <br /> { <br /> if( DBG ){ printl( "#" + nCurrentLevel + " map on chooser is: " + MapPlayOrder[j] ) }<br /> return MapPlayOrder[j]<br /> }<br /> j++<br /> }<br /><br /> if ( MapPlayOrder[j] == MapPlayOrder[courseEndIndex] ) <br /> { <br /> if( DBG ){ printl( "#" + nCurrentLevel + " Chooser on 2last: " + MapPlayOrder[courseEndIndex] ) }<br /> return MapPlayOrder[courseEndIndex] <br /> }<br /> }<br /> }<br /> printl ( "== Current map is not in list! ==" ) <br />}<br /><br />//==================== LEVEL CHOOSER LOGIC ========================<br />//======================== VGUI SCREEN ============================<br />//-----------------------------------------------------------------<br />//Pressing the Right Button<br />function AddLevel( nCourse )<br />{<br /> if ( DBG ) { printl("=================================== Add Button ============================") }<br /> nLevels = NumberOfLevels( nCourse )<br /> local nNewLevel = nCurrentLevel + 1<br /> if ( nNewLevel > nLevels ){ return }<br /> else { nCurrentLevel++ }<br /> <br /> sNextLevel = FindCurrentLevel( nCurrentLevel )<br /> lasttens = tens<br /> lastunits = units<br /> units++<br /><br /> MoveSlider( nCurrentLevel )<br /> UpdateCounter()<br /> UpdateButtons()<br /> if( textPreview ){ DisplayLevelTitle() }<br />}<br /><br />//Pressing the Left button<br />function SubtractLevel( nCourse )<br />{<br /> if ( DBG ) { printl("============================== Subtract Button ===========================") }<br /> nLevels = NumberOfLevels( nCourse )<br /> local nNewLevel = nCurrentLevel - 1<br /> if ( nNewLevel < 1 ){ return }<br /> else { nCurrentLevel-- }<br /><br /> sNextLevel = FindCurrentLevel( nCurrentLevel )<br /> lasttens = tens<br /> lastunits = units<br /> units--<br /><br /> MoveSlider( nCurrentLevel )<br /> UpdateCounter()<br /> UpdateButtons()<br /> if( textPreview ){ DisplayLevelTitle() }<br />}<br /><br />function DisplayLevelTitle()<br />{<br /> EntFire( EntityGroup[6].GetName(), "setText", FindCurrentLevel(nCurrentLevel), 0 )<br /> EntFire( EntityGroup[6].GetName(), "Display", "", 0.1 )<br />}<br /><br />//moves the slider based off the current number and how many maps there are<br />function MoveSlider( nDistance )<br />{<br /> local nSections = 1.0<br /> nSections = nSections / ( nLevels - 1 )<br /> local nMovePercentage = ( nSections * nDistance ) - nSections<br /><br /> //for some reason the input cannot be a 0 from the script.<br /> if ( nMovePercentage <= 0 ){ nMovePercentage = 0.0001 }<br /><br /> if( DBG ){ printl ( "nDistance: " + nDistance + ", nMovePercentage: " + nMovePercentage + ", nSections: " + nSections ) }<br /> EntFire( EntityGroup[2].GetName(), "SetPosition", nMovePercentage, 0 )<br />}<br /><br />//Displays Numbers of current course chosen<br />function UpdateCounter()<br />{<br /> if ( units > 9 ) {<br /> tens++<br /> units = 0<br /> }<br /> if ( units < 0 ) {<br /> tens--<br /> units = 9<br /> }<br /> if ( tens > 9 || tens < 0 ) { tens = 0 }<br /> if ( tens == lasttens ) { lasttens = 9 }<br /><br /> //Enables and disables the correct level numbers<br /> EntFire( EntityGroup[3].GetName() + "" + tens, "Enable", "", 0 )<br /> EntFire( EntityGroup[3].GetName() + "" + lasttens, "Disable", "", 0 )<br /> EntFire( EntityGroup[4].GetName() + "" + units, "Enable", "", 0 )<br /> EntFire( EntityGroup[4].GetName() + "" + lastunits, "Disable", "", 0 )<br />}<br /><br />//Decides what length to set the slider depending on how many levels are in course. More courses will make the slider smaller.<br />function SetLengthOfSlider()<br />{<br /> local nSlider = 0<br /> if ( nLevels == 1) { nSlider = 1 }<br /> if ( nLevels == 2) { nSlider = 2 }<br /> if ( nLevels == 3) { nSlider = 3 }<br /> if ( nLevels == 4) { nSlider = 4 }<br /> if ( nLevels == 5 || nLevels == 6 ) { nSlider = 5 }<br /> if ( nLevels >= 7 && nLevels <= 9 ) { nSlider = 6 }<br /> if ( nLevels >= 10 && nLevels <= 13 ) { nSlider = 7 }<br /> if ( nLevels >= 14 && nLevels <= 20 ) { nSlider = 8 }<br /> if ( nLevels >= 21 ) { nSlider = 9 }<br /><br /> if( DBG ){ printl ( "Slider # is: " + nSlider ) }<br /><br /> for ( local j = 0; j < 10; j++ )<br /> {<br /> if( j == nSlider )<br /> {<br /> EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "targetname " + EntityGroup[2].GetName(), 0)<br /> EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "classname " + EntityGroup[2].GetName(), 0)<br /> } <br /> //removes every other slider except the wanted one when the loop is irated<br /> EntFire( EntityGroup[2].GetName() + j, "Kill", "", 0)<br /> }<br />}<br /><br />//Sets if the buttons are red or dull depending if the last or first map is currently chosen.<br />function UpdateButtons()<br />{<br /> if ( nCurrentLevel <= 1 ) {<br /> // turn off the left light<br /> EntFire( EntityGroup[0].GetName(), "Skin", "1", 0)<br /> }<br /> else {<br /> // turn on the left light<br /> EntFire( EntityGroup[0].GetName(), "Skin", "0", 0)<br /> }<br /> if ( nCurrentLevel >= nLevels ) {<br /> // turn off the right light<br /> EntFire( EntityGroup[1].GetName(), "Skin", "1", 0)<br /> }<br /> else {<br /> // turn on the right light<br /> EntFire( EntityGroup[1].GetName(), "Skin", "0", 0)<br /> }<br />}<br />//=================== CHAPTER TITLE DISPLAY =======================<br />//-----------------------------------------------------------------<br />// Display the chapter title<br />function DisplayChapterTitle()<br />{<br /> foreach (index, level in CHAPTER_TITLES)<br /> {<br /> if (level.map == GetMapName() )<br /> {<br /> EntFire( "@chapter_title_text", "SetTextColor", "210 210 210 128", 0.0 )<br /> EntFire( "@chapter_title_text", "SetTextColor2", "50 90 116 128", 0.0 )<br /> EntFire( "@chapter_title_text", "SetPosY", "0.32", 0.0 )<br /> EntFire( "@chapter_title_text", "SetText", level.title_text, 0.0 )<br /> EntFire( "@chapter_title_text", "display", "", level.displaydelay )<br /> <br /> EntFire( "@chapter_subtitle_text", "SetTextColor", "210 210 210 128", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "SetTextColor2", "50 90 116 128", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "SetPosY", "0.35", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "settext", level.subtitle_text, 0.0 )<br /> EntFire( "@chapter_subtitle_text", "display", "", level.displaydelay )<br /> }<br /> }<br />}<br /><br />// Display the chapter title on spawn if it is flagged to show up on spawn<br />function TryDisplayChapterTitle()<br />{<br /> foreach (index, level in CHAPTER_TITLES)<br /> {<br /> if (level.map == GetMapName() && level.displayOnSpawn )<br /> {<br /> DisplayChapterTitle()<br /> } <br /> }<br />}
And Like I said before, I only have map mp_coop_map_01 and my hub done. In this version there is only one course. Update will give next course
You still haven't given me what your console spits out when you try to transition.
It gives me this:Dynamic prop Chooser 1-orange-cradle_arm: no sequence named:egg_assembly_cradle_arm_anim and then wont transtion.
okay I did that gives me:1<br />#1 map on chooser is: mp_coop_map_01<br />Changing course to: 1 Level: 1 out of: 9. Map: mp_coop_map_01<br />Dynamic prop Chooser 1-orange-cradle_arm: no sequence named:egg_assembly_cradle_arm_
And its totaly silent except for the menu and its not transistioning
Okay guys now every thing is working! except for onr test involving the ping tool.
Thanks for the awesome instance, but will this still work if its SP? :O
Also, the screen's "...order" is spelt wrongly. Its written "oder" there. xP
RectorRocks wrote:
Thanks for the awesome instance, but will this still work if its SP? :O
Also, the screen's "...order" is spelt wrongly. Its written "oder" there. xP
You could always make your own custom texture for the level chooser. Just sayin' - and yes you could probably use it for Single Player if you edit the instances a bit to work for SP instead of COOP bots (get rid of the disassemblers and trigger_playerteam to trigger_multiple etc).
ChickenMobile wrote:
You could always make your own custom texture for the level chooser. Just sayin' - and yes you could probably use it for Single Player if you edit the instances a bit to work for SP instead of COOP bots (get rid of the disassemblers and trigger_playerteam to trigger_multiple etc).
I tried changing the trigger_playerteam to trigger_multiple. Yes, it works but I wonder how do I change the levels without the disassemblers. Point_clientcommand? If so/not, what do I do to make it change to the desired level chosen in the level chooser?
Pretty much the only thing the disassemblers do is find out when both players are inside them so then the level can transition. in the coop_manager you will find the relevant outputs you need to use in SP.
ChickenMobile wrote:
Pretty much the only thing the disassemblers do is find out when both players are inside them so then the level can transition. in the coop_manager you will find the relevant outputs you need to use in SP.
So all I need to do to transition the player to the desired level is to trigger the transition script?
Uhh...help? I can't transition! When I go to the level chooser, the left and right arrows are gray and when I enter the departure elevator, it won't transition to the next map, it disconnects me. Also, when I start my hub map, I appear inside the transition box. D:
In my console, I got these errors:Entity level_chooser-transition_script encountered an error in RunScript()<br /><br />Entity @transition_script encountered an error in RunScript()<br />
The first one got repeated many times in the console, the second one only appeared twice (arrrival and departure elevator). Help? D:
EDIT: Never mind, I solved it.
Okay another problem, I used the Level Chooser and choosed Map 03. But I went to Map 02 instead. How do I fix it? 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:DBG <- 0<br />FORCE_GUN_AND_HALLWAY <- 0<br /><br />FIRST_MAP_WITH_GUN <- "sp_a1_intro4"<br />FIRST_MAP_WITH_UPGRADE_GUN <- "sp_a2_laser_intro"<br />FIRST_MAP_WITH_POTATO_GUN <- "sp_a3_speed_ramp"<br />LAST_PLAYTEST_MAP <- "sp_a4_finale4"<br /><br /><br />CHAPTER_TITLES <- <br />[<br /> { map = "sp_a1_intro1", title_text = "#portal2_Chapter1_Title", subtitle_text = "#portal2_Chapter1_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },<br /> { map = "sp_a2_laser_intro", title_text = "#portal2_Chapter2_Title", subtitle_text = "#portal2_Chapter2_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },<br /> { map = "sp_a2_sphere_peek", title_text = "#portal2_Chapter3_Title", subtitle_text = "#portal2_Chapter3_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },<br /> { map = "sp_a2_column_blocker", title_text = "#portal2_Chapter4_Title", subtitle_text = "#portal2_Chapter4_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },<br /> { map = "sp_a2_bts3", title_text = "#portal2_Chapter5_Title", subtitle_text = "#portal2_Chapter5_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },<br /> { map = "sp_a3_00", title_text = "#portal2_Chapter6_Title", subtitle_text = "#portal2_Chapter6_Subtitle", displayOnSpawn = true, displaydelay = 1.5 },<br /> { map = "sp_a3_speed_ramp", title_text = "#portal2_Chapter7_Title", subtitle_text = "#portal2_Chapter7_Subtitle", displayOnSpawn = true, displaydelay = 1.0 },<br /> { map = "sp_a4_intro", title_text = "#portal2_Chapter8_Title", subtitle_text = "#portal2_Chapter8_Subtitle", displayOnSpawn = true, displaydelay = 2.5 },<br /> { map = "sp_a4_finale1", title_text = "#portal2_Chapter9_Title", subtitle_text = "#portal2_Chapter9_Subtitle", displayOnSpawn = false, displaydelay = 1.0 },<br />]<br /><br />// Display the chapter title<br />function DisplayChapterTitle()<br />{<br /> foreach (index, level in CHAPTER_TITLES)<br /> {<br /> if (level.map == GetMapName() )<br /> {<br /> EntFire( "@chapter_title_text", "SetTextColor", "210 210 210 128", 0.0 )<br /> EntFire( "@chapter_title_text", "SetTextColor2", "50 90 116 128", 0.0 )<br /> EntFire( "@chapter_title_text", "SetPosY", "0.32", 0.0 )<br /> EntFire( "@chapter_title_text", "SetText", level.title_text, 0.0 )<br /> EntFire( "@chapter_title_text", "display", "", level.displaydelay )<br /> <br /> EntFire( "@chapter_subtitle_text", "SetTextColor", "210 210 210 128", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "SetTextColor2", "50 90 116 128", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "SetPosY", "0.35", 0.0 )<br /> EntFire( "@chapter_subtitle_text", "settext", level.subtitle_text, 0.0 )<br /> EntFire( "@chapter_subtitle_text", "display", "", level.displaydelay )<br /> }<br /> }<br />}<br /><br />// Display the chapter title on spawn if it is flagged to show up on spawn<br />function TryDisplayChapterTitle()<br />{<br /> foreach (index, level in CHAPTER_TITLES)<br /> {<br /> if (level.map == GetMapName() && level.displayOnSpawn )<br /> {<br /> DisplayChapterTitle()<br /> } <br /> }<br />}<br /><br />LOOP_TIMER <- 0<br /><br />initialized <- false<br /><br />// This is the order to play the maps<br />MapPlayOrder<- [<br /><br />// ===================================================<br />// ====================== ACT 1 ======================<br />// ===================================================<br /><br />// ---------------------------------------------------<br />// Intro<br />// ---------------------------------------------------<br />"sp_a1_intro1", // motel to box-on-button<br />"sp_a1_intro2", // portal carousel<br />"sp_a1_intro3", // fall-through-floor, dioramas, portal gun<br />"sp_a1_intro4", // box-in-hole for placing on button<br />"sp_a1_intro5", // fling hinting<br />"sp_a1_intro6", // fling training<br />"sp_a1_intro7", // wheatley meetup<br />"sp_a1_wakeup", // glados <br /> "@incinerator",<br /><br />// ===================================================<br />// ====================== ACT 2 ======================<br />// ===================================================<br /><br />"sp_a2_intro", // upgraded portal gun track<br /><br />// ---------------------------------------------------<br />// Lasers<br />// ---------------------------------------------------<br />"sp_a2_laser_intro",<br />"sp_a2_laser_stairs",<br />"sp_a2_dual_lasers",<br />"sp_a2_laser_over_goo",<br /><br />// ---------------------------------------------------<br />// Catapult<br />// ---------------------------------------------------<br />"sp_a2_catapult_intro",<br />"sp_a2_trust_fling",<br /><br />// ---------------------------------------------------<br />// More Lasers<br />// ---------------------------------------------------<br />"sp_a2_pit_flings",<br />"sp_a2_fizzler_intro",<br /><br />// ---------------------------------------------------<br />// Lasers + Catapult<br />// ---------------------------------------------------<br />"sp_a2_sphere_peek",<br />"sp_a2_ricochet",<br /><br />// ---------------------------------------------------<br />// Bridges<br />// ---------------------------------------------------<br />"sp_a2_bridge_intro",<br />"sp_a2_bridge_the_gap",<br /><br />// ---------------------------------------------------<br />// Turrets<br />// ---------------------------------------------------<br />"sp_a2_turret_intro",<br />"sp_a2_laser_relays", // breather<br />"sp_a2_turret_blocker",<br />"sp_a2_laser_vs_turret", // Elevator Glados Chat - Should be removed?<br /><br />// ---------------------------------------------------<br />// Graduation<br />// ---------------------------------------------------<br />"sp_a2_pull_the_rug",<br />"sp_a2_column_blocker", // Elevator_vista<br />"sp_a2_laser_chaining",<br />//"sp_a2_turret_tower",<br />"sp_a2_triple_laser",<br /><br />// ---------------------------------------------------<br />// Sabotage<br />// ---------------------------------------------------<br /><br />"sp_a2_bts1",<br />"sp_a2_bts2",<br />"sp_a2_bts3",<br />"sp_a2_bts4",<br />"sp_a2_bts5",<br />"sp_a2_bts6",<br /><br />// ---------------------------------------------------<br />// Glados Chamber Sequence<br />// ---------------------------------------------------<br />"sp_a2_core",<br /><br /><br />// ===================================================<br />// ====================== ACT 3 ======================<br />// ===================================================<br /><br />// ---------------------------------------------------<br />// Underground<br />// ---------------------------------------------------<br /><br /> "@bottomless_pit",<br />"sp_a3_00",<br />"sp_a3_01",<br />"sp_a3_03",<br /> "@test_dome_lift",<br />"sp_a3_jump_intro",<br /> "@test_dome_lift",<br />"sp_a3_bomb_flings",<br /> "@test_dome_lift",<br />"sp_a3_crazy_box",<br /> "@test_dome_lift",<br />"sp_a3_transition01",<br /> "@test_dome_lift",<br />"sp_a3_speed_ramp",<br /> "@test_dome_lift",<br />"sp_a3_speed_flings",<br /> "@test_dome_lift",<br />"sp_a3_portal_intro",<br /> "@hallway",<br />"sp_a3_end",<br /><br />// ===================================================<br />// ====================== ACT 4 ======================<br />// ===================================================<br /><br />// ---------------------------------------------------<br />// Recapture<br />// ---------------------------------------------------<br />"sp_a4_intro",<br /><br />// ---------------------------------------------------<br />// Tractor beam<br />// ---------------------------------------------------<br />"sp_a4_tb_intro",<br />"sp_a4_tb_trust_drop", <br />// "@hallway",<br />"sp_a4_tb_wall_button",<br />// "@hallway",<br />"sp_a4_tb_polarity",<br />// "@hallway",<br />"sp_a4_tb_catch", // GRAD<br /><br />// ---------------------------------------------------<br />// Crushers<br />// ---------------------------------------------------<br /><br />// ---------------------------------------------------<br />// Graduation Combos<br />// ---------------------------------------------------<br />"sp_a4_stop_the_box", // Grad?<br />// "@hallway",<br />"sp_a4_laser_catapult", // Grad<br />// "@hallway",<br />//"sp_catapult_course"<br />// "@hallway",<br />//"sp_box_over_goo", // Grad<br />// "@hallway",<br />"sp_a4_laser_platform",<br /><br />// ---------------------------------------------------<br />// Tbeam + Paint<br />// ---------------------------------------------------<br />//"sp_paint_jump_tbeam",<br />// "@hallway",<br />"sp_a4_speed_tb_catch",<br />// "@hallway",<br />"sp_a4_jump_polarity", // GRAD<br />// "@hallway",<br />//"sp_paint_portal_tbeams",<br /><br />// ---------------------------------------------------<br />// Wheatley Escape<br />// ---------------------------------------------------<br /><br />"sp_a4_finale1",<br /> "@hallway",<br />"sp_a4_finale2",<br /> "@hallway",<br />"sp_a4_finale3",<br /> "@hallway",<br /><br />// ---------------------------------------------------<br />// FIXME: WHEATLEY BATTLE<br />// ---------------------------------------------------<br /><br />"sp_a4_finale4",<br /><br />// ---------------------------------------------------<br />// Demo files<br />// ---------------------------------------------------<br />"demo_intro",<br />"demo_underground",<br />"demo_paint",<br /><br />// ---------------------------------------------------<br />// Mappack<br />// ---------------------------------------------------<br />"sp_mappack_hub",<br />"sp_security_crisis",<br />"sp_u_repulsive_welcome",<br />"sp_painting_with_gels"<br />]<br /><br />//================== CONSTANTS ( EDIT THESE ) =====================<br />//-----------------------------------------------------------------<br /><br />// Turn Debug on (1) or off (0)<br />DBG <- 0<br /><br />// Set to false if you don't want text to appear showing the name of the current chosen level on the chooser<br />textPreview <- true<br /><br />// The name of the Hub map. This the map it will transition to when all maps are finished in the current course.<br />// The hubmap will be ignored if tried to transition to if it is in MapPlayOrder[]<br />HUB_MAP <- "sp_mappack_hub"<br /><br />//--------------------------------------------------------------------------------<br />// Create new START and END maps to calculate a new level chooser for another course.<br />// For eg. "map1ex" is the start level and "map3ex" is the end level of the first course.<br />//--------------------------------------------------------------------------------<br />START_MAP <- [ <br />"sp_security_crisis", //Course 1 StartMap<br />]<br /><br />END_MAP <- [ <br />"sp_painting_with_gels", //Course 1 EndMap<br />]<br /><br />// --------------------------------------------------------<br />// OnPostTransition - we just transitioned, teleport us to the correct place.<br />// --------------------------------------------------------<br />function OnPostTransition()<br />{<br /> local foundMap = false<br /> <br /> foreach (index, map in MapPlayOrder)<br /> { <br /> if (GetMapName() == MapPlayOrder[index])<br /> {<br /> foundMap = true<br /> <br /> // hook up our entry elevator<br /> if( index - 1 >= 0 )<br /> {<br /> if( MapPlayOrder[index-1].find("@") == null )<br /> {<br /> printl( "Teleporting to default start pos" )<br /> EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 ) <br /> EntFire( "@arrival_teleport", "Teleport", 0, 0 ) <br /> }<br /> else<br /> {<br /> printl( "Trying to teleport to " + MapPlayOrder[index - 1] + "_teleport" )<br /> EntFire( MapPlayOrder[index - 1] + "_entry_teleport", "Teleport", 0, 0.0 ) <br /> }<br /> }<br /> break<br /> }<br /> }<br /> <br /> if (foundMap == false )<br /> {<br /> EntFire( "@elevator_entry_teleport", "Teleport", 0, 0 )<br /> EntFire( "@arrival_teleport", "Teleport", 0, 0 ) <br /> }<br />}<br /><br />// --------------------------------------------------------<br />// EntFire_MapLoopHelper<br />// --------------------------------------------------------<br />function EntFire_MapLoopHelper( classname, suffix, command, param, delay )<br />{<br /> // This calls EntFire on an entity of a given type, named with the given suffix.<br /> // This deals with instance name mangling (though it doesn't guarantee uniqueness)<br /> local suffix_len = suffix.len()<br /> for ( local ent = Entities.FindByClassname( null, classname ); ent != null; ent = Entities.FindByClassname( ent, classname ) )<br /> {<br /> local ent_name = ent.GetName()<br /> local suffix_offset = ent_name.find( suffix )<br /> if ( ( suffix_offset != null ) && ( suffix_offset == ( ent_name.len() - suffix_len ) ) )<br /> {<br /> EntFire( ent_name, command, param, delay )<br /> return<br /> }<br /> }<br /> printl( "MAPLOOP: ---- ERROR! Failed to find entity " + suffix + " while initiating map transition" );<br />}<br /><br />// --------------------------------------------------------<br />// Think<br />// --------------------------------------------------------<br />function Think()<br />{ <br /> // Start the game loop if the cvar is set<br /> if ( initialized && LoopSinglePlayerMaps() )<br /> {<br /> // initialize the timer<br /> if( LOOP_TIMER == 0 )<br /> {<br /> LOOP_TIMER = Time() + 10 // restart time in seconds<br /> }<br /> <br /> // transition to the next map if the timer has expired<br /> if ( LOOP_TIMER < Time() )<br /> {<br /> // reset loop timer<br /> LOOP_TIMER = 0<br /><br /> printl( "\nMAPLOOP: timer expired, moving on..." )<br /><br /> // Ensure point_viewcontrollers are disabled<br /> EntFire( "point_viewcontrol", "disable", 0, 0 )<br /> <br /> // Change the level (this sequence was originally in the 'transition_without_survey' logic_relay)<br /> EntFire_MapLoopHelper( "trigger_once", "survey_trigger", "Disable", "", 0.0 )<br /> EntFire_MapLoopHelper( "env_fade", "exit_fade", "Fade", "", 0.0 )<br /> EntFire_MapLoopHelper( "point_teleport", "exit_teleport", "Teleport", "", 0.3 )<br /> EntFire_MapLoopHelper( "logic_script", "transition_script", "RunScriptCode", "TransitionFromMap()", 0.4 )<br /> }<br /> }<br /> <br /> <br /> if (initialized)<br /> {<br /> return<br /> }<br /> initialized = true<br /><br /> // position fixup for sp_a3_01, in case player has fallen outside map<br /><br /> if (GetMapName() == "sp_a3_01")<br /> {<br /> printl( "--------------- FIXING PLAYER POSITION FOR sp_a3_01" )<br /><br /> local destination_name = "knockout-teleport" // targetname of the destination entity<br /> <br /> local player_ent = null<br /><br /> local destination_ent = null<br /><br /> // find the player<br /> player_ent = Entities.FindByClassname( player_ent, "player" ) <br /><br /> if ( player_ent == null )<br /> {<br /> printl("*** Cannot find player. Aborting!")<br /> return;<br /> }<br /><br /> // find the destination entity<br /> destination_ent = Entities.FindByName( destination_ent, destination_name ) <br /><br /> if ( destination_ent == null )<br /> {<br /> printl("*** Cannot find destination entity " + destination_name + ". Aborting!")<br /> return;<br /> }<br /> <br /> // move the player to the destination<br /> player.SetOrigin( destination_ent.GetOrigin() ) <br /> }<br /><br /> DumpMapList()<br /><br /> local portalGunCommand = ""<br /> local portalGunSecondCommand = ""<br /> local foundMap = false<br /> <br /> foreach (index, map in MapPlayOrder)<br /> {<br /> if (MapPlayOrder[index] == FIRST_MAP_WITH_GUN)<br /> {<br /> portalGunCommand = "give_portalgun"<br /> } <br /> else if (MapPlayOrder[index] == FIRST_MAP_WITH_UPGRADE_GUN)<br /> {<br /> portalGunSecondCommand = "upgrade_portalgun"<br /> }<br /> else if (MapPlayOrder[index] == FIRST_MAP_WITH_POTATO_GUN)<br /> {<br /> portalGunSecondCommand = "upgrade_potatogun"<br /> }<br /> <br /> if (GetMapName() == MapPlayOrder[index])<br /> {<br /> break<br /> }<br /> }<br /><br /> TryDisplayChapterTitle()<br /> <br /> if (portalGunCommand != "" && GetMapName() != "sp_a2_intro" && GetMapName() != "sp_a3_01" )<br /> {<br /> printl( "=======================Trying to run " + portalGunCommand )<br /> EntFire( "command", "Command", portalGunCommand, 0.0 )<br /> EntFire( "@command", "Command", portalGunCommand, 0.0 )<br /> }<br /><br /> if (portalGunSecondCommand != "")<br /> {<br /> printl( "=======================Trying to run " + portalGunSecondCommand )<br /> EntFire( "command", "Command", portalGunSecondCommand, 0.1 )<br /> EntFire( "@command", "Command", portalGunSecondCommand, 0.1 )<br /> }<br /> <br />}<br /><br />// --------------------------------------------------------<br />// TransitionFromMap<br />// --------------------------------------------------------<br />function DumpMapList()<br />{<br /> if(DBG)<br /> {<br /> local mapcount = 0<br /> <br /> printl("================DUMPING MAP PLAY ORDER")<br /> <br /> foreach( index, map in MapPlayOrder )<br /> {<br /> // weed out our transitions<br /> if( MapPlayOrder[index].find("@") == null )<br /> {<br /> if( GetMapName() == MapPlayOrder[index] )<br /> {<br /> printl( mapcount + " " + MapPlayOrder[index] + " <--- You Are Here" )<br /> }<br /> else<br /> {<br /> printl( mapcount + " " + MapPlayOrder[index] )<br /> }<br /> mapcount++<br /> }<br /> <br /> }<br /> printl( mapcount + " maps total." )<br /> <br /> printl("================END DUMP")<br /> }<br />}<br /><br />// --------------------------------------------------------<br />// TransitionFromMap<br />// --------------------------------------------------------<br />function TransitionFromMap()<br />{<br /> local next_map = null<br /> foreach( index, map in MapPlayOrder )<br /> {<br /> if( GetMapName() == MapPlayOrder[index] )<br /> {<br /> // make good<br /> local skipIndex = index<br /> for(local i=0;i<2;i+=1)<br /> {<br /> if( skipIndex + 1 < MapPlayOrder.len() )<br /> {<br /> if( MapPlayOrder[skipIndex + 1].find("@") != null )<br /> {<br /> skipIndex++<br /> }<br /> else<br /> {<br /> break<br /> }<br /> }<br /> } <br /> <br /> if( ( skipIndex + 1 < MapPlayOrder.len() ) &&<br /> ( GetMapName() != LAST_PLAYTEST_MAP ) )<br /> {<br /> next_map = MapPlayOrder[ skipIndex + 1 ]<br /> if(DBG) printl( "Map " + GetMapName() + " connects to " + next_map )<br /><br /> if ( Entities.FindByName( null, "@changelevel" ) == null )<br /> {<br /> if(DBG) printl( "('@changelevel' entity missing, using 'map' command instead)" )<br /> SendToConsole( "map " + next_map );<br /> }<br /> else<br /> {<br /> EntFire( "@changelevel", "Changelevel", next_map, 0.0 ) <br /> }<br /> }<br /> }<br /> }<br /> <br /> if ( next_map == null )<br /> {<br /> if(DBG) printl( "Map " + GetMapName() + " is the last map" )<br /> EntFire( "end_of_playtest_text", "display", 0 )<br /> EntFire( "@end_of_playtest_text", "display", 0 )<br /><br /> // If we are in the map loop and at the end of the list, start over at the beginning<br /> if ( LoopSinglePlayerMaps() )<br /> {<br /> printl( "MAPLOOP: No more maps, restarting loop." )<br /> next_map = MapPlayOrder[0]<br /> if ( Entities.FindByName( null, "@changelevel" ) == null )<br /> {<br /> SendToConsole( "map " + next_map );<br /> }<br /> else<br /> {<br /> EntFire( "@changelevel", "Changelevel", next_map, 0.0 ) <br /> }<br /> }<br /> }<br /><br /> printl( "" )<br />}<br /><br />//================= CONSTANTS AND FUNCTIONS =======================<br />//============= DO NOT EDIT ANY CODE BELOW HERE ===================<br />//-----------------------------------------------------------------<br />nLevels <- 0<br />nCurrentLevel <- 1<br />units <- 1<br />tens <- 0<br />lastunits <- 0<br />lasttens <- 0<br />sNextLevel <- "none"<br />courseStartIndex <- 0<br />courseEndIndex <- 0<br /><br />//==================== LEVEL CHOOSER LOGIC ========================<br />//===================== GENERAL FUNCTIONS =========================<br />//-----------------------------------------------------------------<br />//sets the number of maps for the current course from the array<br />//also use this to prepare constants for the level chosen by the level choosers.<br />function NumberOfLevels( nCourse )<br />{<br /> local counter = 0<br /> local nCourseCompare = nCourse - 1<br /> local levelIndex = 0<br /> local nCurrent = 0<br /><br /> foreach( index, map in MapPlayOrder )<br /> {<br /> //if( DBG ){ printl( "Loop number: " + index + " Current Map: " + MapPlayOrder[index] ) }<br /><br /> if ( MapPlayOrder[index] == START_MAP[nCurrent] )<br /> {<br /> //if( DBG ){ printl ( nCurrent ) }<br /> if ( nCurrent == nCourseCompare )<br /> {<br /> courseStartIndex = index<br /> levelIndex = index<br /> while( levelIndex <= ArrayLength() && MapPlayOrder[levelIndex] != END_MAP[nCourseCompare] )<br /> {<br /> if ( CheckHubMap(levelIndex) ) { counter++ }<br /> levelIndex++<br /> }<br /> //adds 1 as the loop has exited before adding the final map<br /> courseEndIndex = levelIndex<br /> counter++<br /><br /> //if( DBG ){ printl ( "Course: " + nCourse +" Levels: " + counter + ". LastMap: " + MapPlayOrder[courseEndIndex] + " index: " + courseEndIndex + ". FirstMap: " + MapPlayOrder[courseStartIndex] + " index: " + courseStartIndex ) }<br /> return counter<br /> }<br /> nCurrent++ <br /> }<br /> }<br /> printl ( "Could not find any courses! Make sure the START_MAP and END_MAP is inside both their arrays and the MapPlayOrder[] Array!" )<br /> return 0<br />}<br />//Setup of Fake Vgui and buttons on startup<br />function InitButtons( nCourse )<br />{ <br /> if( DBG ){ printl ( "========================== Course " + nCourse + " =======================" ) }<br /> nLevels = NumberOfLevels( nCourse )<br /> if( DBG ){ printl ( "Course: " + nCourse + " Levels: " + nLevels ) }<br /> UpdateButtons()<br /> SetLengthOfSlider()<br />}<br /><br />//Returns false if map in transition is the hub<br />function CheckHubMap( nMap ) {<br /> if ( MapPlayOrder[nMap] == HUB_MAP ) { return false }<br /> else { return true }<br />}<br /><br />//gets the current courses' number based off the instance<br />function getCourse() <br />{<br /> //the course name is set inside the instance's entity group -> [5]<br /> local nCourse = EntityGroup[5].GetName()<br /> <br /> //Finds the last digit of instance, and gets the course number from it<br /> local length = nCourse.len()<br /> length--<br /> nCourse = nCourse[length].tochar().tointeger()<br /><br /> NumberOfLevels( nCourse )<br /> return nCourse<br />}<br /><br />function dumpLevel() { printl ( GetMapName() ) }<br /><br />//Finds length of MapPlayOrder[] array (total maps in transition)<br />function ArrayLength() <br />{<br /> local total = 0<br /> foreach( index, map in MapPlayOrder ) { total++ }<br /> return total<br />}<br />//returns the current chosen map's name<br />function FindCurrentLevel( nCurrentLevel )<br />{<br /> local j = 0<br /> nLevels = NumberOfLevels( getCourse() )<br /> if(DBG){ printl( getCourse() ) }<br /><br /> if ( nCurrentLevel < 1 ) <br /> { <br /> if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on first: " + MapPlayOrder[courseStartIndex] ) } <br /> return MapPlayOrder[courseStartIndex] <br /> }<br /> if ( nCurrentLevel >= ArrayLength() ) <br /> { <br /> if( DBG ) { printl( "#" + nCurrentLevel + " Chooser on last: " + MapPlayOrder[courseEndIndex] ) }<br /> return MapPlayOrder[courseEndIndex] <br /> }<br /><br /> foreach( index, map in MapPlayOrder )<br /> {<br /> if ( MapPlayOrder[index] == MapPlayOrder[courseStartIndex] )<br /> {<br /> j = index<br /><br /> //we need this as we dont want to ovveride the world variable nCurrentLevel<br /> local tempCurrentLevel = nCurrentLevel + index<br /> <br /> //Finds the appropriate level from MapPlayOrder[] from chooser<br /> while ( j < ArrayLength() && MapPlayOrder[j] != MapPlayOrder[courseEndIndex] )<br /> {<br /> if ( !CheckHubMap(j) ) <br /> { <br /> j++ <br /> printl("Skipping Hub Map...") <br /> }<br /> else if( j == tempCurrentLevel - 1 ) <br /> { <br /> if( DBG ){ printl( "#" + nCurrentLevel + " map on chooser is: " + MapPlayOrder[j] ) }<br /> return MapPlayOrder[j]<br /> }<br /> j++<br /> }<br /><br /> if ( MapPlayOrder[j] == MapPlayOrder[courseEndIndex] ) <br /> { <br /> if( DBG ){ printl( "#" + nCurrentLevel + " Chooser on 2last: " + MapPlayOrder[courseEndIndex] ) }<br /> return MapPlayOrder[courseEndIndex] <br /> }<br /> }<br /> }<br /> printl ( "== Current map is not in list! ==" ) <br />}<br /><br />//==================== LEVEL CHOOSER LOGIC ========================<br />//======================== VGUI SCREEN ============================<br />//-----------------------------------------------------------------<br />//Pressing the Right Button<br />function AddLevel( nCourse )<br />{<br /> if ( DBG ) { printl("=================================== Add Button ============================") }<br /> nLevels = NumberOfLevels( nCourse )<br /> local nNewLevel = nCurrentLevel + 1<br /> if ( nNewLevel > nLevels ){ return }<br /> else { nCurrentLevel++ }<br /> <br /> sNextLevel = FindCurrentLevel( nCurrentLevel )<br /> lasttens = tens<br /> lastunits = units<br /> units++<br /><br /> MoveSlider( nCurrentLevel )<br /> UpdateCounter()<br /> UpdateButtons()<br /> if( textPreview ){ DisplayLevelTitle() }<br />}<br /><br />//Pressing the Left button<br />function SubtractLevel( nCourse )<br />{<br /> if ( DBG ) { printl("============================== Subtract Button ===========================") }<br /> nLevels = NumberOfLevels( nCourse )<br /> local nNewLevel = nCurrentLevel - 1<br /> if ( nNewLevel < 1 ){ return }<br /> else { nCurrentLevel-- }<br /><br /> sNextLevel = FindCurrentLevel( nCurrentLevel )<br /> lasttens = tens<br /> lastunits = units<br /> units--<br /><br /> MoveSlider( nCurrentLevel )<br /> UpdateCounter()<br /> UpdateButtons()<br /> if( textPreview ){ DisplayLevelTitle() }<br />}<br /><br />function DisplayLevelTitle()<br />{<br /> EntFire( EntityGroup[6].GetName(), "setText", FindCurrentLevel(nCurrentLevel), 0 )<br /> EntFire( EntityGroup[6].GetName(), "Display", "", 0.1 )<br />}<br /><br />//moves the slider based off the current number and how many maps there are<br />function MoveSlider( nDistance )<br />{<br /> local nSections = 1.0<br /> nSections = nSections / ( nLevels - 1 )<br /> local nMovePercentage = ( nSections * nDistance ) - nSections<br /><br /> //for some reason the input cannot be a 0 from the script.<br /> if ( nMovePercentage <= 0 ){ nMovePercentage = 0.0001 }<br /><br /> if( DBG ){ printl ( "nDistance: " + nDistance + ", nMovePercentage: " + nMovePercentage + ", nSections: " + nSections ) }<br /> EntFire( EntityGroup[2].GetName(), "SetPosition", nMovePercentage, 0 )<br />}<br /><br />//Displays Numbers of current course chosen<br />function UpdateCounter()<br />{<br /> if ( units > 9 ) {<br /> tens++<br /> units = 0<br /> }<br /> if ( units < 0 ) {<br /> tens--<br /> units = 9<br /> }<br /> if ( tens > 9 || tens < 0 ) { tens = 0 }<br /> if ( tens == lasttens ) { lasttens = 9 }<br /><br /> //Enables and disables the correct level numbers<br /> EntFire( EntityGroup[3].GetName() + "" + tens, "Enable", "", 0 )<br /> EntFire( EntityGroup[3].GetName() + "" + lasttens, "Disable", "", 0 )<br /> EntFire( EntityGroup[4].GetName() + "" + units, "Enable", "", 0 )<br /> EntFire( EntityGroup[4].GetName() + "" + lastunits, "Disable", "", 0 )<br />}<br /><br />//Decides what length to set the slider depending on how many levels are in course. More courses will make the slider smaller.<br />function SetLengthOfSlider()<br />{<br /> local nSlider = 0<br /> if ( nLevels == 1) { nSlider = 1 }<br /> if ( nLevels == 2) { nSlider = 2 }<br /> if ( nLevels == 3) { nSlider = 3 }<br /> if ( nLevels == 4) { nSlider = 4 }<br /> if ( nLevels == 5 || nLevels == 6 ) { nSlider = 5 }<br /> if ( nLevels >= 7 && nLevels <= 9 ) { nSlider = 6 }<br /> if ( nLevels >= 10 && nLevels <= 13 ) { nSlider = 7 }<br /> if ( nLevels >= 14 && nLevels <= 20 ) { nSlider = 8 }<br /> if ( nLevels >= 21 ) { nSlider = 9 }<br /><br /> if( DBG ){ printl ( "Slider # is: " + nSlider ) }<br /><br /> for ( local j = 0; j < 10; j++ )<br /> {<br /> if( j == nSlider )<br /> {<br /> EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "targetname " + EntityGroup[2].GetName(), 0)<br /> EntFire( EntityGroup[2].GetName() + nSlider, "addoutput", "classname " + EntityGroup[2].GetName(), 0)<br /> } <br /> //removes every other slider except the wanted one when the loop is irated<br /> EntFire( EntityGroup[2].GetName() + j, "Kill", "", 0)<br /> }<br />}<br /><br />//Sets if the buttons are red or dull depending if the last or first map is currently chosen.<br />function UpdateButtons()<br />{<br /> if ( nCurrentLevel <= 1 ) {<br /> // turn off the left light<br /> EntFire( EntityGroup[0].GetName(), "Skin", "1", 0)<br /> }<br /> else {<br /> // turn on the left light<br /> EntFire( EntityGroup[0].GetName(), "Skin", "0", 0)<br /> }<br /> if ( nCurrentLevel >= nLevels ) {<br /> // turn off the right light<br /> EntFire( EntityGroup[1].GetName(), "Skin", "1", 0)<br /> }<br /> else {<br /> // turn on the right light<br /> EntFire( EntityGroup[1].GetName(), "Skin", "0", 0)<br /> }<br />}<br /><br />// --------------------------------------------------------<br />// MakeBatFile - dumps the map list in a formatted way, for easy recompilin'<br />// --------------------------------------------------------<br />function MakeBatFile()<br />{<br /> local mapcount = 0<br /> <br /> printl("================DUMPING maps formatted for batch file")<br /> <br /> foreach( index, map in MapPlayOrder )<br /> {<br /> printl( "call build " + MapPlayOrder[index] ) <br /> }<br /> <br /> foreach( index, map in MapPlayOrder )<br /> {<br /> printl( "call p2_buildcubemaps " + MapPlayOrder[index] ) <br /> }<br />}<br /><br />// this lets the elevator know that we are ready to transition.<br />function TransitionReady()<br />{<br /> ::TransitionReady <- 1 <br />}<br />
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:
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.
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
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.7z
ChickenMobile 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.7z
Thanks!
I did 1. and 2. , but how do I do 3. ?
That's the instance that transitions the player from SP. You can edit this to your liking, but generally it should do the same thing.
I can now transition successfully using the transition_hub.vmf but I can't transition if I used the arrival_departure_transition_ents.vmf. D: I want it to transition using an elevator so I used the arrival_departure_transition_ents.vmf. Any solution?
Don't put the arrival departure ents in.
Edit your elevator so it doesn't call any script when you hit a certain spot in the map, but let the player touch the trigger in the instance I gave you.
With the starting elevator you will have to either put a teleporting thing in, or put the info_player_start inside the elevator.
Thanks! It worked but I can't seem to trigger the elevator videos.
EDIT: Fixed it! Thanks! It works perfectly now. 
This Transition script and custom level choosers can be used to transition to different maps and courses through a hub map (like Valves).
The level choosers can choose from any map in the course and it can display what map you are choosing with a message appearing on the screen.
You can have 'infinite' courses inside your script, however both players need the same maps in order for the map to transition to it.
If anyone wants to make a coop mass mack-pack (from everyone's coop maps), go ahead. It is definitely possible.
Refer to the README.txt included with the download for installation instructions and common problems with fixes. If you have a problem and you cannot find an answer to it: put a post in this thread or PM me so we can get it working.
One thing I don't know how to do (yet) is to save a player's progress and make the courses 'unlockable', even if the player has ended the game and then goes back to it (with the same or different partner).
If anyone can tell me how to read and write to a file, I would gladly edit this and put this function in.
If you are to use my instances/script/materials make sure you credit me within your map download or in your credits!
Anyway, enjoy!
ChickenMobile
EDIT: From a very nice person I found out that there are a few errors with this:
- The map doesn't transition without a point_servercommand called @command in your map
- I forgot a major script that opens the chooser panel
- Updated the Readme file to account for a new problem found
- You don't have to use my coop spawner instance (your welcome to use your own)
Guaranteed all things are now fixed!
EDIT: Sorry guys for uploading the wrong file. Fixed in double time.
File Name: portal 2s.7z
File Size: 380.24 KiB
Click here to download Coop Transition Script and Level Choosers