Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Mahak on August 11, 2010, 09:54:37 pm

Title: Using mouse buttons as $KeyPress
Post by: Mahak on August 11, 2010, 09:54:37 pm
Does anyone know why I can't substitute a keyboard keypress with (MOUSE_LEFT_BUTTON) in script?  Am I using wrong syntax?

Example:

$KeyPress: t
$On Key Pressed:
[
 Blah blah blah scripty scripty etc. etc.

That works fine.  But if I replace 't' (or any other keyboard key) with MOUSE_LEFT_BUTTON it won't work.

Tried a few different combinations of syntax to no avail.

Anyone have any clues?  I'm guessing I may have to call up some kinda mouse state or something, but I'm a plebe with that kinda thing...

M.
Title: Re: Using mouse buttons as $KeyPress
Post by: FUBAR-BDHR on August 11, 2010, 11:02:27 pm
Did you make sure that the mouse button wasn't already assigned?  I believe that is a default secondary input. 
Title: Re: Using mouse buttons as $KeyPress
Post by: The E on August 12, 2010, 03:14:18 am
What's wrong with using io.isMouseButtonDown(MOUSE_LEFT_BUTTON) in an On Frame hook?
Title: Re: Using mouse buttons as $KeyPress
Post by: Mahak on August 12, 2010, 04:44:42 am
Reckon I have to just teach myself a little more scripting.  I'm just trying to mash up stuff with existing scripts, but I think I just have to write my own from the ground up.  Thats ok - it's something I've been putting off for ages, but I need to know how to do it.

I'll read some tutorials & faqs and stuff before I start whining again!

Cheers all.

M.
Title: Re: Using mouse buttons as $KeyPress
Post by: The E on August 12, 2010, 04:54:54 am
One handy tip is to use the "Output scripting to scripting.html" switch in the Launcher's Dev Tool feature list. This will create a file called scripting.html in your FS2 folder, which contains all lua API functions the engine supports.
Title: Re: Using mouse buttons as $KeyPress
Post by: Mahak on August 13, 2010, 01:20:46 am
Well thats just made my day.  A cheat sheet!  Awesome.

Once again, hardlight community forums ftw!