Executing script on button press
by Andrew Nare · in Torque Game Engine · 07/15/2008 (8:36 pm) · 8 replies
I have implemented this resource and have been trying to figure out how to execute the included fireball script when clicking the right mouse button. I have searched but I have found nothing.
Any help would be great. And sorry if this is obvious but I have only recently started coding in TorqueScript.
Thanks
Any help would be great. And sorry if this is obvious but I have only recently started coding in TorqueScript.
Thanks
About the author
Leadwerks
#2
EDIT: I looked in C:\Torque\TGE_1_5_2\example\starter.fps\client but defaults.cs doesn't have any functions. Is there a specific place I should look?
07/15/2008 (9:51 pm)
Thanks for the reply! Going to try it now.EDIT: I looked in C:\Torque\TGE_1_5_2\example\starter.fps\client but defaults.cs doesn't have any functions. Is there a specific place I should look?
#3
07/16/2008 (11:45 am)
Look in Scripts (under the client folder) and you will see a default.bind.cs file.
#4
EDIT: It doesn't seem to be there.
default.bind.cs mouse functions:
Infact "btn" isn't even in the script.
07/16/2008 (12:13 pm)
Ok, thanks for the help.EDIT: It doesn't seem to be there.
default.bind.cs mouse functions:
function mouseFire(%val)
{
$mvTriggerCount0++;
}
function altTrigger(%val)
{
$mvTriggerCount1++;
}
moveMap.bind( mouse, button0, mouseFire );
//moveMap.bind( mouse, button1, altTrigger );Infact "btn" isn't even in the script.
#5
moveMap.bind(mouse, button1, mouse_btn1);
If that doesn't work then you need to do a bit of reading on how to create an action map in Torque.
07/16/2008 (12:49 pm)
Ok then paste that entire function in there and also this line (I'm assuming the name is movemap)moveMap.bind(mouse, button1, mouse_btn1);
If that doesn't work then you need to do a bit of reading on how to create an action map in Torque.
#6
07/16/2008 (1:16 pm)
I figured out a different way to do it, but thanks for the help.
#7
05/12/2010 (7:55 pm)
Can you share how you got it to work? I am trying to implement something similar on left click but have only been successful at finding mouse input for objects.
#8
05/12/2010 (9:12 pm)
What problems are you having? The script identified above in default.bind.cs is where you need to go to specify scripts to run based on user input.
Torque Owner Steve D
Look in your game directory, go the client folder and open up default.cs. In there look for a function called
function mouse_btn1(%val)
{
}
In there put
if (%val)
{
InitSpells();
}
so it should look like
function mouse_btn1(%val)
{
if (%val)
{
InitSpells();
}
}