Portal 2

Portal 2

31 ratings
How-To: Lens Cubes Respawning + Initial Orientation
By Bisqwit
An initial orientation for a cube AND have it automatically respawned when fizzled? Possible! With regular puzzlemaker, without installing extra stuff.
   
Award
Favorite
Favorited
Unfavorite
Introduction
One of the biggest annoyances in the PeTI editor for me so far has been, that if you want your Discouragement Redirection Cube to have an initial orientation, you can’t have it respawn. And if you want it to respawn, you can’t have an initial orientation for the cube.

V.S.

Now, as outlined in my guide (see below), it is really difficult to make sure that your cube can never be destroyed and/or made impossible to retrieve.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=155812535

Yet, sometimes, particularly when making lessons, where you want the player to see that something special happens when the cube is oriented a certain way, you must have an initial orientation for the cube.

This problem has necessited ugly compromises in map at times, such as caged cubes. But there is a solution! It is explained below.
Making Them Signal You When They Die
The first part of the problem is this: If your cube fizzles, you have no way of knowing it. The solution involves making the cubes provide a signal when they fizzle.

This is surprisingly simple!

Just navigate to your Portal 2 directory, and go to portal2_dlc2\scripts and edit a file called editoritems.txt.

Find the line that says: "Type" "ITEM_CUBE".
Scroll down, until you find the first line after that, that says "TargetName".

Below that line, copypaste the following lines:

// ADDED BY BISQWIT "Outputs" { "CONNECTION_STANDARD" { "Activate" "instance:cube;OnFizzled" "Deactivate" "instance:cube;OnFizzled" } } // ADDED BY BISQWIT "ConnectionPoints" { // left "Point" { "Dir" "1 0 0" "Pos" "1 3 0" "SignageOffset" "0 2 0" "Priority" "0" } "Point" { "Dir" "1 0 0" "Pos" "1 4 0" "SignageOffset" "0 5 0" "Priority" "0" } // right "Point" { "Dir" "-1 0 0" "Pos" "6 3 0" "SignageOffset" "7 2 0" "Priority" "0" } "Point" { "Dir" "-1 0 0" "Pos" "6 4 0" "SignageOffset" "7 5 0" "Priority" "0" } // up "Point" { "Dir" "0 1 0" "Pos" "3 1 0" "SignageOffset" "2 0 0" "Priority" "0" } "Point" { "Dir" "0 1 0" "Pos" "4 1 0" "SignageOffset" "5 0 0" "Priority" "0" } // down "Point" { "Dir" "0 -1 0" "Pos" "3 6 0" "SignageOffset" "2 7 0" "Priority" "0" } "Point" { "Dir" "0 -1 0" "Pos" "4 6 0" "SignageOffset" "5 7 0" "Priority" "0" } }

Be careful to not omit any of the { and } characters, and to not add any extra newlines. Failure to copy the text precisely will result in problems using the puzzle editor.

Note: If you are using FGEMOD, you need to apply this procedure to science/cube.test, and rerun fgemod.exe.
Note: If you are using StylesMod, you need to repeat this procedure for all editoritems files within the scripts directory, and rerun StyleChanger.exe.

Save the file, and restart Portal 2.

Now you can draw a signal line from a cube into any element that you wish to activate when the cube is fizzled. First rightclick the cube, select "Connect to", and select the target element. The order of clicking is important.


In this example picture, the piston platform will receive a signal when the cube is destroyed.

Signage points are provided, but you will probably want to hide them, because they do not really make sense with a cube that can be picked up and moved. The signage will not move, even though the cube can be moved.

Now, if you want your cube to be respawned, follow these instructions:
  • Create a cube without dropper. Orient it as you want.
  • Create a dropper that does not drop the first cube automatically.
  • Connect the cube into the dropper.

You can now even respawn the cube somewhere completely other than where it first appeared. Or you can create a puzzle where the door opens when the cube is fizzled. The possibilities are endless.

Note: When the cube is fizzled, the signal is activated and immediately deactivated. This is enough to drop a cube from a dropper, but it will not keep a door open, a flip panel turned, a funnel enabled, and so on. It will not turn a laser on except for a blink of eye. If you want the signal to be kept on, you must either create a logic latch that sustains the signal, or remove the "Deactivate" line above.

On the right you can see an example of a latch mechanism implemented with lasers. The exit door is opened, and remains open, when the cube is dropped into the goo. Studying how the mechanism works is left as an exercise to the reader.

Note: I am not encouraging anyone to create this kind of puzzle. It is counterintuitive. This image was only provided for illustration of the latch concept.
Adding Remote Detonation
The second part of making cubes fail-proof is to add a manual respawn button.

Normally, you would have a pedestal button which is connected to the cube dropper. This causes any cube dropped by the dropper to fizzle, and the dropper to drop a new one. This is a good idea, because sometimes the player may lose their cube without fizzling it.
However, this button will not fizzle the initial cube, that has no dropper, resulting in a duplicate cube. What can we do?

There is a way to add remote fizzling into cubes, but this is significantly more difficult than the previous step. Do not worry; this guide will teach you step by step what to do.

First, open the editoritems.txt file again, and add the following lines exactly where you added the previous lines:
"Inputs" { "CONNECTION_STANDARD" { "Activate" "instance:cube;FireUser1" } }
Just copy & paste the text, and you will get it right. Attempting to copy it by typing may result in problems, because of e.g. line wrapping.


Now, navigate to Portal 2\sdk_content\maps\instances\p2editor, and find all files where the filename begins with "cube".

For each of these five files, repeat the following procedure:
  • Find "OnFizzled". If the line above or below it does not contain "Dissolve", duplicate that line, and change the following things on the copy of the line: "Fizzled" into "User1", "proxy" into "!self", and "ProxyRelay" into "Dissolve".
  • Find "func_instance_io_proxy". If you do not see a section named "connections" about three lines below that, add one. It reads like follows, BUT you must replace all * with the ESC character. For each *, remove it and copypaste the ESC character (which may look like an arrow, or an inverse bracket, or a square) from the "OnFizzled" line you found earlier in the file:
    connections { "OnProxyRelay" "cube*FireUser1**0*-1" }
See the screenshots below for an example of the expected outcome. Click to zoom the picture.


Note: If you use StylesMod, you will need to repeat this procedure for similarly named files in all the other p2editor_* folders (p2editor_old, etc.) as well.

Once you have done this, restart Portal 2. Now you will be able to direct a signal into a dropperless cube. This signal will command the cube to self-destruct. On the right you can see a design in which pressing the button will cause the companion cube to self-destruct.
Note: Again, it is strongly recommended that you hide the connection between the component and the cube. The antline is affixed into the architecture, and will not follow when you move the cube.

Now, the construction of a fully fool-proof mechanism for an initially-oriented cube is as follows:

  • Create a cube without dropper. Point it where you like.
  • Create a dropper. Uncheck the "Auto-drop first cube" option.
  • Create a pedestal button.
  • Create an OR logic gate. If you have normal Portal 2 without any mods, follow these instructions:
    • Create two laser emitters. They are the inputs of the OR gate.
    • Create a laser relay. This is the output of the OR gate.
    • Point the two emitters into the same laser relay.
  • Connect button into cube.
  • Connect button into the OR gate. (One of its laser emitters.)
  • Connect cube into the OR gate. (The other laser emitter.)
  • Connect the OR gate into the dropper. (The laser relay into the dropper.)
  • Set the Connection Visibility for the cube to "Hide".
Remember to do the connections in right order. First click the element that you are connecting; choose "Connect to...", and then click the target element that you are connecting into.

Below, you can see two screenshots of the expected outcome. They both accomplish the same. On the left, is the laser relay method. On the right, an actual OR logic gate from BEEMOD was used.



Because the dropper must activate when either the pedestal button is pressed, or the first cube fizzles, they cannot be both directly connected to the dropper. The OR gate must be used. If they were directly connected to the dropper, they would need to be simultaneously activated in order for the dropper to activate. With the OR gate, activation of either one is enough.

Finally, make some cosmetic changes, in order to make the scene intuitive for the player:
  • Set the Connection Visibility for the dropper to "Hide".
  • Hide the OR gate from the player, but place them in such way that it appears that the antline going into the OR gate actually goes into the dropper.
    • The best mod-less way to do this that I found, was to put the laser contraption in a tiny box somewhere outside the normal map, and hide all connections. Then, put a decoy element (such as a flip panel) in the ceiling right next to the dropper, indent it by two blocks, and seal the hole with an angled panel. Then connect the button into the decoy element.
Below, you can see screenshots of how the BEEMOD version appears both in the editor and in game. The third one is a screenshot of the no-mods version.



Done! Now it is safe to design puzzles where you can provide an initial orientation for a Discouragement Redirection Cube and risk the player losing their cube. Congratulations!
Final Notes
A supplemental list of warnings and miscellaneous information is listed here.
  • If you want to revert all these modifications to your game files, just select "Verify Integrity of Game Cache" in your game properties in Steam. This will restore all the files into their factory defaults.
  • If you edit and save your puzzle on a computer that does not have these modifications, the connections from/to your cubes will be lost and must be created again.
  • If your cube fizzles, the new cube that is spawned is pointed randomly. This guide does not currently offer a solution for assigning a predetermined orientation for the respawned cubes.
14 Comments
LittleNinja 9 Aug, 2020 @ 9:19am 
So... hack the game?
Redbreaker47 10 Nov, 2014 @ 8:12am 
guys
Stoic⁧⁧Sirius 13 Mar, 2014 @ 10:12am 
I didn't found "type""ITEM_CUBE"
i am a BEE2 user
TechNick 12 Mar, 2014 @ 5:19pm 
Thanks for the guide,but im afraid i do not mess with complicated things like this. i am 8,this would be hard for me,sorry.
Bisqwit  [author] 12 Aug, 2013 @ 4:18am 
piripiago: The cubes generated by the dropper are autowired to signal the dropper when they fizzle, by the means of a box template within the dropper, that refers to the dropper. I don't see an easy way to make a consistent and usable edit to it without using Hammer. I can see what you might be aiming for though.
piripiago 11 Aug, 2013 @ 9:13pm 
I can get a dropperless cube to trigger a dropper, but is it possible to get cubes from a dropper to trigger another dropper? Instead of a dropper auto-respawning, I was trying to daisy chain two droppers into each other so that fizzling the cube from one would trigger the other, and vice versa. ... The answer is probably hammer. ;-)
Bisqwit  [author] 11 Aug, 2013 @ 3:01pm 
With BEE2 you would have to edit portal2_dlc2\BEE2\items\*.beec and apply the same instructions for the most part. Run the BEE2 exe afterwards.
AnarchyPaladin 11 Aug, 2013 @ 2:03pm 
How would you do this if you have the BEE2 mod?
Daniboy 12 Jul, 2013 @ 7:33am 
nice
Bisqwit  [author] 7 Jul, 2013 @ 2:31pm 
That would be quite weird > ESC character appearing when you copypasted from the web page, considering there is no ESC character on this page. Thanks for commenting!