Combination locks, indicator lights, and possible scripting
Quote from Keeve on August 18, 2011, 9:42 pmI'm fairly new to mapping, but I'm guessing this question is somewhat advanced and my problem is somewhat ambitious.
What I would like to do is create a combination lock, which when solved correctly will open a door or trigger some other task. Here is how I envision doing this:
I would like to use the indicator_lights_wall texture to create digital numbers kind of like a digital watch or clock that uses LED to form a figure-eight, but depending on which lights are lit up, can represent any number. So if I lay out my textures like this (ignore the periods, I had to use them because spaces wouldn't work):
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.oas 7 separate textures, 3 horizontal, and 4 vertical, I could represent any number I wanted by lighting them up, for instance (the blue "o"s represent the lights that are lit):
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.oo.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.oo.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.oThe patterns above would represent 1,2,and 3 respectively. Of course the same figure-eight (again consisting of 3 horizontal rows and 4 vertical rows) could represent any digit 0-9 depending on which lights are lit up.
So as I imagine it, you could walk into a room with a closed door, 3 sets of figure-eight lights, and 3 corresponding pillar buttons (each button controlling one set of figure-eight lights). Each time you press a pillar button, it would cycle it's corresponding light digits through 0,1,2,3,4, etc.
Now imagine elsewhere in the map are clues to the combination, for argument's sake let's say our combination is 739. When you get to our light room, you would click the first pillar button 7 times to get a 7 pattern on the first set of lights, the second pillar button 3 times, and 9 clicks for the last pillar button.
I know enough about mapping to realize how problematic this can be, for instance the pillar button has a 0 or 1 only output, but I was wondering if multiple env_testuretoggle entities and maybe some scripting could help solve this (or maybe a different kind of button or input).
I don't know how to do the scripting at all (and in fact my second question is: Where do I find a decent Portal 2 / Hammer tutorial. I don't know Vscript, but I do know C# which I understand is very similar). And of course my first question is: Is my concept at all doable, and can anyone help me get started on this project, and perhaps even collaborate with me on it?
I'm fairly new to mapping, but I'm guessing this question is somewhat advanced and my problem is somewhat ambitious.
What I would like to do is create a combination lock, which when solved correctly will open a door or trigger some other task. Here is how I envision doing this:
I would like to use the indicator_lights_wall texture to create digital numbers kind of like a digital watch or clock that uses LED to form a figure-eight, but depending on which lights are lit up, can represent any number. So if I lay out my textures like this (ignore the periods, I had to use them because spaces wouldn't work):
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
as 7 separate textures, 3 horizontal, and 4 vertical, I could represent any number I wanted by lighting them up, for instance (the blue "o"s represent the lights that are lit):
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
o.......o
o.......o
o.......o
o.o.o.o
The patterns above would represent 1,2,and 3 respectively. Of course the same figure-eight (again consisting of 3 horizontal rows and 4 vertical rows) could represent any digit 0-9 depending on which lights are lit up.
So as I imagine it, you could walk into a room with a closed door, 3 sets of figure-eight lights, and 3 corresponding pillar buttons (each button controlling one set of figure-eight lights). Each time you press a pillar button, it would cycle it's corresponding light digits through 0,1,2,3,4, etc.
Now imagine elsewhere in the map are clues to the combination, for argument's sake let's say our combination is 739. When you get to our light room, you would click the first pillar button 7 times to get a 7 pattern on the first set of lights, the second pillar button 3 times, and 9 clicks for the last pillar button.
I know enough about mapping to realize how problematic this can be, for instance the pillar button has a 0 or 1 only output, but I was wondering if multiple env_testuretoggle entities and maybe some scripting could help solve this (or maybe a different kind of button or input).
I don't know how to do the scripting at all (and in fact my second question is: Where do I find a decent Portal 2 / Hammer tutorial. I don't know Vscript, but I do know C# which I understand is very similar). And of course my first question is: Is my concept at all doable, and can anyone help me get started on this project, and perhaps even collaborate with me on it?
Quote from Omnicoder on August 18, 2011, 10:29 pmThis is somewhat similar to the vscript keyboard I made for grox the other day. It used a point_template to spawn keys and had a texture with frames for every key character. The various EntityGroup entities were the template, keyboard origin, etc. Here's the source:
- Code: Select all
// --------------------------------------------------------
// In-game keyboard
// Written by Omnicoder
// --------------------------------------------------------KEYS <- [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_" ];
TMPORIG <- null;
TEXT_CONTENT <- "";
KEY_OFFSET <- 6;function CreateVBoard() {
/*
printl("Creating VBoard...");
printl(" VBoard marker at " + EntityGroup[0].GetOrigin());
printl(" VBoard textbox at " + EntityGroup[2].GetOrigin());
printl(" Creating keys...");
*/
TMPORIG = EntityGroup[1].GetOrigin();
EntFire(self.GetName(), "RunScriptCode", "CreateKey(0)", 0, self);
}function CreateKey(idx) {
//printl(" Creating " + KEYS[idx]);
EntFire(self.GetName(), "RunScriptCode", "SetOriginOfTemplate(" + idx + ")", 0, self);
EntFire("@vboard_template_key", "ForceSpawn", "", 0.1, self);
if (idx < (KEYS.len() - 1)) {
EntFire(self.GetName(), "RunScriptCode", "CreateKey(" + (idx + 1) + ")", 0.2, self);
}
else {
EntFire(self.GetName(), "RunScriptCode", "SetupKeys()", 1, self);
}
}function SetOriginOfTemplate(idx) {
local ny = idx * KEY_OFFSET;
local nz = 0;
if (idx >= 26) {
nz += KEY_OFFSET;
ny -= KEY_OFFSET * (KEYS.len()-30);
}
if (idx > (KEYS.len() / 2)) {
nz += KEY_OFFSET*2;
ny -= ((KEYS.len()/2)+1)*KEY_OFFSET;
}
else if (idx > (KEYS.len() / 4)) {
nz += KEY_OFFSET;
ny -= ((KEYS.len()/4)+1)*KEY_OFFSET;
}
EntityGroup[1].SetOrigin( Vector(TMPORIG.x - ny, TMPORIG.y/* - ny*/, TMPORIG.z - nz) );
}function SetupKeys() {
local i = 0;
for (local ent = Entities.FindByName(null,"vboard_key_button*"); ent != null; ent = Entities.FindByName(ent, "vboard_key_button*")) {
EntFireByHandle(ent, "Addoutput", "OnPressed @vboard_script:RunScriptCode:KeyPressed("" + KEYS[i++] + ""):0:-1>", 0, self, self);
}
i = 0;
for (local ent = Entities.FindByName(null,"vboard_key_texturetoggle*"); ent != null; ent = Entities.FindByName(ent, "vboard_key_texturetoggle*")) {
EntFireByHandle(ent, "SetTextureIndex", "" + i++ + "" , 0, self, self);
}
}function KeyPressed(key) {
TEXT_CONTENT += key;
UpdateText();
}function UpdateText() {
EntityGroup[3].__KeyValueFromString("message", TEXT_CONTENT);
if (TEXT_CONTENT == "burn") {
EntFire("player", "Ignite", "", 0, self);
}
}function Backspace() {
printl("BKSP");
if (TEXT_CONTENT.len() != 0) {
TEXT_CONTENT = TEXT_CONTENT.slice(0, TEXT_CONTENT.len()-1);
UpdateText();
}
}function TestEnter() {
SendToConsole("echo "You entered: " + TEXT_CONTENT + """);
}If you already know C# hopefully that will be enough for you to adapt a spawner that can shape out 8's and connect outputs. (or to use a texture with frames for each state of the display and switch between them)
This is somewhat similar to the vscript keyboard I made for grox the other day. It used a point_template to spawn keys and had a texture with frames for every key character. The various EntityGroup entities were the template, keyboard origin, etc. Here's the source:
- Code: Select all
// --------------------------------------------------------
// In-game keyboard
// Written by Omnicoder
// --------------------------------------------------------KEYS <- [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_" ];
TMPORIG <- null;
TEXT_CONTENT <- "";
KEY_OFFSET <- 6;function CreateVBoard() {
/*
printl("Creating VBoard...");
printl(" VBoard marker at " + EntityGroup[0].GetOrigin());
printl(" VBoard textbox at " + EntityGroup[2].GetOrigin());
printl(" Creating keys...");
*/
TMPORIG = EntityGroup[1].GetOrigin();
EntFire(self.GetName(), "RunScriptCode", "CreateKey(0)", 0, self);
}function CreateKey(idx) {
//printl(" Creating " + KEYS[idx]);
EntFire(self.GetName(), "RunScriptCode", "SetOriginOfTemplate(" + idx + ")", 0, self);
EntFire("@vboard_template_key", "ForceSpawn", "", 0.1, self);
if (idx < (KEYS.len() - 1)) {
EntFire(self.GetName(), "RunScriptCode", "CreateKey(" + (idx + 1) + ")", 0.2, self);
}
else {
EntFire(self.GetName(), "RunScriptCode", "SetupKeys()", 1, self);
}
}function SetOriginOfTemplate(idx) {
local ny = idx * KEY_OFFSET;
local nz = 0;
if (idx >= 26) {
nz += KEY_OFFSET;
ny -= KEY_OFFSET * (KEYS.len()-30);
}
if (idx > (KEYS.len() / 2)) {
nz += KEY_OFFSET*2;
ny -= ((KEYS.len()/2)+1)*KEY_OFFSET;
}
else if (idx > (KEYS.len() / 4)) {
nz += KEY_OFFSET;
ny -= ((KEYS.len()/4)+1)*KEY_OFFSET;
}
EntityGroup[1].SetOrigin( Vector(TMPORIG.x - ny, TMPORIG.y/* - ny*/, TMPORIG.z - nz) );
}function SetupKeys() {
local i = 0;
for (local ent = Entities.FindByName(null,"vboard_key_button*"); ent != null; ent = Entities.FindByName(ent, "vboard_key_button*")) {
EntFireByHandle(ent, "Addoutput", "OnPressed @vboard_script:RunScriptCode:KeyPressed("" + KEYS[i++] + ""):0:-1>", 0, self, self);
}
i = 0;
for (local ent = Entities.FindByName(null,"vboard_key_texturetoggle*"); ent != null; ent = Entities.FindByName(ent, "vboard_key_texturetoggle*")) {
EntFireByHandle(ent, "SetTextureIndex", "" + i++ + "" , 0, self, self);
}
}function KeyPressed(key) {
TEXT_CONTENT += key;
UpdateText();
}function UpdateText() {
EntityGroup[3].__KeyValueFromString("message", TEXT_CONTENT);
if (TEXT_CONTENT == "burn") {
EntFire("player", "Ignite", "", 0, self);
}
}function Backspace() {
printl("BKSP");
if (TEXT_CONTENT.len() != 0) {
TEXT_CONTENT = TEXT_CONTENT.slice(0, TEXT_CONTENT.len()-1);
UpdateText();
}
}function TestEnter() {
SendToConsole("echo "You entered: " + TEXT_CONTENT + """);
}
If you already know C# hopefully that will be enough for you to adapt a spawner that can shape out 8's and connect outputs. (or to use a texture with frames for each state of the display and switch between them)
Quote from Vordwann on August 19, 2011, 9:38 amTopHATTWaffle also did a combination lock tutorial on his youtube channel, Rocketrascal34.
TopHATTWaffle also did a combination lock tutorial on his youtube channel, Rocketrascal34.
[spoiler][SP] Alternate[/spoiler]
Quote from GreyHound on August 25, 2011, 9:47 amI've done this recently. I guess that's exactly what you are trying to do.
It's all one instance, no scripting etc.The vmf isn't completely ready but you can set all numbers from 0-9 in blue and orange. I can post the vmf if you need it. I planned to complete it and make it realy comfortable to use, but if you're in a hurry.
http://forums.thinking.withportals.com/mapping-help/need-help-creating-led-panels-t4329.html
I've done this recently. I guess that's exactly what you are trying to do.
It's all one instance, no scripting etc.
The vmf isn't completely ready but you can set all numbers from 0-9 in blue and orange. I can post the vmf if you need it. I planned to complete it and make it realy comfortable to use, but if you're in a hurry.
http://forums.thinking.withportals.com/mapping-help/need-help-creating-led-panels-t4329.html
Quote from Vordwann on August 25, 2011, 12:49 pmTopHATTWaffle's tutorial: http://www.youtube.com/watch?v=mAeBdw-oay8
TopHATTWaffle's tutorial: http://www.youtube.com/watch?v=mAeBdw-oay8
[spoiler][SP] Alternate[/spoiler]
