Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → key trapping
key trapping
2005-07-10, 4:03 PM #1
I've had an idea that is so simple that half of you have probably already thought of it :p

Many people are using key trapping lines in their cogs these days, but all of that code can get tedious (sp).

I suggest that we write a cog that finds out when a key is pressed (really easy in MOTS, but in JK you have to check player movement) and when a key is pressed/held, this cog sends a trigger out on the local computer to all cogs. Then, when an editor wants to use key trapping, he'll include this cog and check for the trigger/message.

This could also allow for multiple cogs to "capture" a thing. Have a global cog capture it, then send triggers/messages whenever they are recieved. I've never really had a problem with this before, but it would make key trapping a simpler process.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-07-10, 9:23 PM #2
you can find whatever thing you damn well please with a for statement cycling through, lets say 1000, to identify every thing in the level, after that, use if statements to do whatever dirty work is left. you could probably put it in a pulse as well
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-07-10, 9:33 PM #3
for(i=0;i<GetThingCount();i=i+1) //loop through all things in the level

I love for-loops :D

I had to do a keytrapper thingie not too long ago... if it sprouts any ideas, here is the base
Code:
vec = GetThingThrust(player);
x = VectorX(vec);
y = Vectory(vec);
z = Vectorz(vec);
vec2 = GetThingRotVel(player);
r = VectorY(vec2);
if(x > 0) //right strafe key
else if(x < 0) //left strafe key
if(y > 0) //forward key
else if(y < 0) //backward key
if(z > 0) //jumping
if(IsThingCrouching(player)) //crouched
if(r > 0) //turning right
else if(r < 0) //turning left
Granted, it only captures movement... hotkeys are a different story b/c, obviously, there's no foolproof definite way to check for hotkey activation
May the mass times acceleration be with you.
2005-07-10, 11:31 PM #4
I thought GetThingCount() does only return the number of things defined in the level's jkl, but I might be wrong.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-07-11, 8:13 AM #5
GetThingCount() returns the world thing count (e.g. 640), not the placed thing count. Learned this from LKOH_SniperWolf on Lord Kaje's manual sequencer thread a while back :)
May the mass times acceleration be with you.

↑ Up to the top!