A way to bind an LUA Function to a key?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
SleepKiller
Corporal
Corporal
Posts: 143
Joined: Thu Mar 03, 2011 5:08 pm
xbox live or psn: N/A

A way to bind an LUA Function to a key?

Post by SleepKiller »

Hello GameToast,

I am currently searching for away to bind an LUA Function so it activates when a key is pressed. I know LUA doesn't have this function built in, but I was wondering if anyone had found a function in SWBFII that yielded the same results.

I did use the search function and got, either something to do with combos or No Suitable Matches Were Found.

Any help would be much appreciated. (I am starting to suspect it is impossible myself. I just thought I would ask to be sure.)
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: A way to bind an LUA Function to a key?

Post by [RDH]Zerted »

There's two ways to sort-of do it. The first is use the command keys. Those are the F keys you use to give the AI commands. See the scripting guide in the mod tool's documentation for the functions that let you use them (I don't have that doc on this laptop, so I can't give you any more details right now).

The second way is to put a transparent IFScreen (window) over the entire display. I don't think that's what you want. You can add keyboard commands to any window (map screen, pause menu, etc...). If you're using v1.3 it would be easiest to add in custom FakeConsole commands. Would that work for what you have planned? You didn't say what you wanted the key bindings to do.
SleepKiller
Corporal
Corporal
Posts: 143
Joined: Thu Mar 03, 2011 5:08 pm
xbox live or psn: N/A

Re: A way to bind an LUA Function to a key?

Post by SleepKiller »

[RDH]Zerted wrote:There's two ways to sort-of do it. The first is use the command keys.
The second way is to put a transparent IFScreen (window) over the entire display. I don't think that's what you want. You can add keyboard commands to any window (map screen, pause menu, etc...). If you're using v1.3 it would be easiest to add in custom FakeConsole commands. Would that work for what you have planned? You didn't say what you wanted the key bindings to do.
Yes I suppose I should explain in as much detail as possible what I want them to do.

I want it so that while you are playing when you press 1, 2, 3, 4, etc It runs this command.

ReadDataFileIngame("");

To load up a new set of textures to change i.e. a clone legion on the fly. (It works I have tested it.)

So how exactly does one go about making an invisible screen? Then how to you go about adding the bindings?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: A way to bind an LUA Function to a key?

Post by [RDH]Zerted »

Try getting it working with the F keys first. The scripting guide that comes with the mod tool's documentation has a section on it (the AI commands). You program it just like an OnEnterRegion
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: A way to bind an LUA Function to a key?

Post by Teancum »

Specifically you can find info on this in /BF2 Tools/Documentation/Battlefront2_scripting_system.doc under the section "CharacterIssueAICommand". :thumbs:
Post Reply