Page 1 of 3
Key input?
Posted: February 18th, 2006, 1:15 am
by Pedsdude
Is it possible to press keys in a certain order to say open a door? For example, would it be possible to create a script so that if you press "a, b, c, d" a door opens?
It's a long-shot, but I hope someone knows how to do it...
Posted: February 18th, 2006, 1:29 am
by hambones
Posted: February 18th, 2006, 1:35 am
by JammY
spose you could do a thing like marshalls house of pain door at the start but have 5 or so scripts for each door?
Posted: February 18th, 2006, 2:01 am
by Drofder2004
You can only detect input for 3 keys.
UseButtonPressed();
MeleeButtonPressed();
AttackButtonPressed();
you can use these together for eaxmple..
if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
Open door.
Basically the script says...
if the user is touching the trigger and they press their use button and their melee button, then the door will open.
Very complicated but it works
(Do not listen to hambones, never go to modsonline, that way I have no use here

)
Posted: February 18th, 2006, 2:33 am
by Pedsdude
Ah k, will try it out after I have created all of my hurt triggers.
Drofder2004 wrote:(Do not listen to hambones, never go to modsonline, that way I have no use here

)
I knew there wasn't a chance in hell of me finding it on modsonline

Do you just know all of this information or do you search for it? lol
[
Posted: February 18th, 2006, 5:01 pm
by Pedsdude
Code: Select all
main()
{
thread secretdoor();
}
secretdoor()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");
while(1)
{
trigger waittill ("trigger");
if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
{
secretdoor moveZ (112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait(2);
secretdoor moveZ (-112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait 0.5;
}
else
{
wait 0.5;
}
}
}
Above is the code I used, below is the error I got.

Posted: February 18th, 2006, 8:03 pm
by Drofder2004
Ok, you cannot just put that code anywhere

It needs adapted.
First off, what sort of trigger is it? [Multiple/Hurt/Use]
Also you have not said what "self" is. Self does not directly relate to a player, it can be a trigger if you wanted it to
This may or may not work (I am unsure what the error means)
Code: Select all
main()
{
thread secretdoor();
}
secretdoor()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");
while(1)
{
trigger waittill ("trigger",player);
if(player isTouching(trigger) && player useButtonPressed() && player meleeButtonPressed())
{
secretdoor moveZ (112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait(2);
secretdoor moveZ (-112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait 0.5;
}
else
{
wait 0.5;
}
}
}
The thing with the code is, I do not think it will work with 2 people both trying to use the trigger, as the trigger is waiting for 1 person to trigger it and only that 1 person can also open the door.
This is a second idea for it.
Code: Select all
main()
{
thread secretdoor();
}
secretdoor()
{
players = getEntArray("player", "classname");
for(i=0; i<players.size; i++)
players[i] thread door_think();
}
door_think()
{
secretdoor = getent ("secretdoor","targetname");
trigger = getent ("secretdoortrig","targetname");
while(1)
{
trigger waittill ("trigger",self);
if(self isTouching(trigger) && self useButtonPressed() && self meleeButtonPressed())
{
secretdoor moveZ (112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait(2);
secretdoor moveZ (-112,1,0.5,0.5);
secretdoor waittill ("movedone");
wait 0.5;
}
else
{
wait 0.5;
}
}
}
Again, this is all semi off the top of my head, so it may not work. Trial and error

Posted: February 18th, 2006, 10:30 pm
by Pedsdude
The trigger is a use (I guessed that use would be the one to use). I'll try both ideas and will get back to you

Posted: February 18th, 2006, 11:17 pm
by Pedsdude
The first code worked fine, although it seemed to interfere with the save mod. When I try and load a position it causes the game to stop with a script runtime error:

Posted: February 19th, 2006, 3:22 am
by Drofder2004
I recommend whatever your trying to do, use switchs or triggers as what your currently trying to achieve is very complex for a single map

Posted: February 19th, 2006, 4:28 pm
by Pedsdude
lol
Is there actually any way I can avoid it interfering with the save mod or is that unavoidable?
Posted: February 19th, 2006, 5:00 pm
by Luke
Pedsdude wrote:The first code worked fine, although it seemed to interfere with the save mod. When I try and load a position it causes the game to stop with a script runtime error:

Its probably because you had it on developer mode - speaking from experience

Posted: February 19th, 2006, 6:03 pm
by Pedsdude
It's funny how the most complicated scripting bits are actually secret bits that only I plan to use

lmao
Posted: February 19th, 2006, 9:09 pm
by Drofder2004
Pedsdude wrote:It's funny how the most complicated scripting bits are actually secret bits that only I plan to use

lmao
Give me 3 minutes on your new map and I will have found your secrets

Posted: February 19th, 2006, 11:41 pm
by Pedsdude
Give it your best shot
