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 → How do you know a key was pressed?
How do you know a key was pressed?
2002-11-15, 10:21 AM #1
I'm trying to make a cog to move a mouse bot like a romote control. I'm not quite sure how you can tell if a key is pressed though. If someone could tell me the command it would be a great help.
2002-11-15, 4:02 PM #2
JK or MotS?
And when the moment is right, I'm gonna fly a kite.
2002-11-16, 5:38 AM #3
jk
2002-11-16, 6:37 AM #4
Wee.

Code:
# Mousie-vision.
#
# 11/2002 GBK
Symbols
Message Startup
Message Activated
Message Pulse
Message Timer
Message Damaged
Thing Player				Local
Thing Bot
Surface Switch
Flex Time
Flex Ac=1			#How fast?
Sound Beep
Template G			#Ghost, prefferably.
Thing Gh=-1				Local
End
Code
Startup:
Player = JKgetlocalplayer();
Setwallcel(Switch, 0);
Stop;

Activated:
If(Getwallcel(Switch) != 0) Stop;
Setwallcel(Switch, 1);
Playsoundpos(Beep, Surfacecenter(Switch), 1, 0, 10, 0);
Setcamerafocus(0, Bot);
Setcamerafocus(1, Bot);
Setpulse(0.01);
Settimerex(Time, 0, 0, 0);
Stop;

Pulse:
If(Getdebugmodeflags() == 0x400) Setpulse(0.0005); 	
Else Setpulse(0.01); 			//Slowmo detection.
Gh = Fireprojectile(Player, G, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
If(Gh == -1) { Print("Lookvector ghost creation failure."); Stop; } 
Setthinglook(Bot, Vectorset(Vectorx(Getthinglvec(Gh)), Vectory(Getthinglvec(Gh)), 0)); Destroything(Gh); Gh = -1;
If(Isthingcrouching(Player) == 1)
Setthingvel(Bot, Vectorscale(Getthinglvec(Bot), Ac));	//Bot navigation.
Stop;

Timer:
Setpulse(0);
Setcamerafocus(0, Player);
Setcamerafocus(1, Player);
Setwallcel(Switch, 0);
Stop;

Damaged:
Setpulse(0);
Killtimerex(0);
Setcamerafocus(0, Player);
Setcamerafocus(1, Player);
Setwallcel(Switch, 0);
Stop;
End


I think you should be able to figure out the neccessary commands...

Oh, BTW, this cog does work. Attach it to the relevent items (The mousbot will have to be stripped of its AI first) and ingame, activate the switch, and press the crouch key...
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!