help with adding keys...

Posted By: Blink

help with adding keys... - 02/25/10 23:47

ok, I have a flashlight script that uses two button to trigger it. the f key on a pc keyboard and the x-box 360 controller button joy_5. it works fine.
Code:
while (energy > 0 && key_f + joy_5== 1)


I want to do the same for other codes i have with no success. i want to use the keyboard and the the 360 controller to trigger these other things as well. when i try to add the other keys, I get errors. what can i do? i want to have the option to use either the mouse and keyboard or the 360 controller buttons.
Posted By: Superku

Re: help with adding keys... - 02/26/10 01:18

var input[2];
#define key_jump 0
#define key_shoot 1

function handle_input() {
if(use_xbox) {
input[key_jump] = scan code from joy_5, see "key mapping";
input[key_shoot] ...
}
else {
set input[] key_board scan codes
}

Then in your functions:
if(key_pressed(input[key_shoot]) && ...) { }
Posted By: Blink

Re: help with adding keys... - 02/26/10 03:03

thanks for the response superku, seems like a lot of work. cant i simply just add something like my example to the existing code? i just dont want to ruin the code i have by adding too much. the code i am trying to change works perfectly when i switch and use either mouse/keyboard combo or 480, but gives me errors when i add both to the script. its either on_k or joy_10, as an example. why doesnt this work?

on_mouse_right && joy_10=gravitation_gun;
Posted By: Superku

Re: help with adding keys... - 02/26/10 14:21

This "on_mouse_right && joy_10=gravitation_gun;" is wrong syntax.
Try
on_mouse_right =gravitation_gun;
on_joy_10=gravitation_gun;
Posted By: Blink

Re: help with adding keys... - 02/26/10 17:13

i actually tried that and i got an error on joy_10.
thats why i need help.
Posted By: Blink

Re: help with adding keys... - 02/26/10 17:17

truthfully, i dont mind using the graviton gun as is, is my other weapons. i want them to be able t be used with either te keyboard or360 buttons.

update: ok, I was able to add a key to one weapon script, let's see if I can figure the rest out. for some reason it didnt work before. maybe i did something wrong.
Posted By: Blink

Re: help with adding keys... - 02/26/10 17:47

ok, this is at the end of my script on one of the weapons. i tried adding a key to it and i got a "too many variables" error.

on_joy3 = create_boomerang;

I changed it to :
on_joy3 + on_b = create_boomerang;
and tried:
on_joy3 + on_key_b = create_boomerang;
got errors.


Posted By: Widi

Re: help with adding keys... - 02/26/10 18:55

as Superku say: don`t use && or + in on_x.

Use only one key or joy for one on_xxx

on_joy3 = create_boomerang;
on_b = create_boomerang;

Edit: joy_10 is wrong, use joy10 (USE THE MANUAL !!!)
Posted By: Blink

Re: help with adding keys... - 02/26/10 21:59

I know Widi, I am not a newb, I just forgot how to do some things, yelling USE THE MANUAL!!! doesnt really help..
Posted By: Superku

Re: help with adding keys... - 02/27/10 14:21

Problem solved?
Posted By: Blink

Re: help with adding keys... - 02/27/10 15:48

yes, I figured it out after all. I had some distractions in my life that has caused me not to think clearly, so I didnt see the obvious solutions. Thanks for asking, Superku.
Posted By: Widi

Re: help with adding keys... - 02/27/10 17:28

Want to know it too...
Posted By: mikaldinho

Re: help with adding keys... - 02/27/10 17:29

@ widi- that was a useless post- i keep getting moaned at about posting them.
Posted By: Widi

Re: help with adding keys... - 02/27/10 17:34

Why useless? I give a solution and want to know it helps.
Posted By: mikaldinho

Re: help with adding keys... - 02/27/10 17:41

Originally Posted By: Widi
Want to know it too...
doesnt make much sense and is a small message. whenever i post like that i get moaned at by mods.
Posted By: Superku

Re: help with adding keys... - 02/27/10 18:13

No, you don't understand. Widi wrote "Want to know it too..." because Blink had solved the problem but he did not write the solution.
Posted By: mikaldinho

Re: help with adding keys... - 02/27/10 18:16

i'll just be quiet on this topic only.

bye bye
Posted By: Blink

Re: help with adding keys... - 02/27/10 22:29

ok, ad widi posted is what i figured out.

on_joy3 = create_boomerang;
on_b = create_boomerang;

that solved the problem.
Posted By: Widi

Re: help with adding keys... - 02/28/10 15:26

Great. Have a nice day.
© 2024 lite-C Forums