Members | Sign In
All Forums > Mission Scripting
avatar

Custom key polling from clients

posted Jan 08, 2013 20:03:16 by CaptainZach
After some experimenting, I've discovered how to use a new feature in the game, as of 1.7: custom key polling from client stations! Here is what you do:

First the server has to start listening, to do this use the <start_getting_keypresses_from> command, like so:

<start_getting_keypresses_from consoles="S" />

Now the server will start listening for keys, but another command is needed: if_client_key, which has a similar syntax to if_gm_key:

<if_client_key keyText="X" />

In this example, I've started polling from the science console (S), listening for key "X". Something will happen when the player at Science presses the X key. To stop polling, use the <end_getting_keypresses_from> command:

<end_getting_keypresses_from consoles="S" />


So an example use in your script might look like:

<event>
<if_timer_finished name="something" />
<if_variable name="prompted" comparator="=" value="0" />
<warning_popup_message message="Press the X key now" consoles="S" />
<start_getting_keypresses_from consoles="S" />
<set_variable name="prompted" value="1" />
</event>

<event>
<if_client_key keyText="X" />
<warning_popup_message message="You pressed the X key! Huzzah!" consoles="SH" />
<end_getting_keypresses_from consoles="S" />
</event>


You can use this for triggering any custom event, including something that couldn't be done before without some wierdness. Now, you can have the captain's map "beam over an away team", or have use different keys for different responses to an NPC conversation over comms. Since we can now add and subtract variables in the scripting system, I'm looking forward to integrating some kind of trading with neutral NPCs in my mission scripts.
page   1
12 replies
avatar
SteveWohlwend said Jan 08, 2013 23:39:58
Thank goodness, I wasted like an hour on this.

May I ask how you figured this out? The ref doc is a bit unpolished at the moment.

Edit: Am I reading this right - it's impossible to have, say, the X button do one thing for Comms and another thing from Science? Furthermore, anyone I'm getting custom input from shares all custom inputs with everyone else I want to get custom input from? That's extremely disappointing.
[Last edited Jan 08, 2013 23:43:46]
avatar
Mike_Substelny said Jan 09, 2013 02:14:11
I'm not sure, but I think the keypress listening ties up the network/server a lot. It's not a good idea to be listening all the time. I think it is intended to be briefly turned on during the right circumstances of your mission. In the Away Team example, you might set conditions of:

Away Team is aboard Artemis.
Range to ship being boarded < 1,000.
Artemis shields are down.
Artemis is moving at sublight speed.
Artemis has enough energy for transporters.

Under those circumstances start listening for the X key from the Captain's Map. Have a similar set of circumstances for beaming the Away Team back.

If you want the X key on Science to do something else, say launch a probe into the giant Space Ameoba, then set different conditions, preferably conditions that exclude the Away Team conditions.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
Mike_Substelny said Jan 14, 2013 14:30:40
I experimented with this over the weekend and it works fine. Note that the keypolling does not happen constantly through every main loop. The delay is very short, almost unnoticeable, but it does mean that the keys should be used for toggle actions, not keypress duration actions.

In other words, suppose your mission script implements a tractor beam when the Engineer presses T. The Engineer pressing T to activate/deactivate Tractor will work fine. But having the Engineer hold T down to tractor and release T to release tractor will be unreliable. The tractor will flicker on and off constantly.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
ThomRobertson said Jan 21, 2013 16:03:39
I'm sorry I didn't update the mission docs as I should have for the 1.70 release. I'm about to release 1.701, and I'll update the docs then.

CaptZach and Mike Substelny have this right.

I think the keypress listening ties up the network/server a lot.


It shouldn't. start_getting_keypresses_from sends a message to the selected clients, telling them that they are ALLOWED to send key messages. after that, every time a key is pressed and released on that client, a key message will be sent. So unless you slap the keyboard like a monkey, those messages SHOULDN'T cause network congestion. Theoretically.
Creator of Artemis
avatar
Mike_Substelny said Jan 22, 2013 18:11:55
So unless you slap the keyboard like a monkey, those messages SHOULDN'T cause network congestion.

I'm glad to hear that.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
ChrisHayes said Feb 28, 2013 06:21:00
Hmm...I seem to be having difficulty with this very issue. I'm trying to offer the crew a "dialogue choice" (press "y" for yes and "n" for no), but I can't seem to get the server to read any keypresses. A dialogue tree isn't quite the same as a random mission, but I'm thinking it should be possible. (it should be noted that I'm no expert at coding and am feeling my way through the Artemis Mission Editor).
avatar
RussJudge said Feb 28, 2013 14:00:07
You must use upper case. Lower case is not recognized by the server.
Russ
Author of Artemis Mod Loader.

Sign up for a free Dropbox account.
avatar
CaptainZach said Feb 28, 2013 15:49:32
Chris, can you post the code for the dialogue? A dialogue tree is totally possible, but your code might have a syntax problem.
avatar
ChrisHayes said Feb 28, 2013 17:20:26
Thanks for the tip RussJudge. Changing the statement in the editor to upper case solved the issue.
avatar
lucas99801 said Mar 02, 2013 02:49:04
would this allow us to set keys for the Main Screen / Captain to control the main screen view.

Say an event like:
Action:
start listening on Main Screen

Cond:
Main Screen keypress: Numpad 8

Action:
SET MAIN_SCREEN_FRONT
Hosting a Mumble (Murmur) server @ tsnfenrir.no-ip.org
Having trouble connecting to the TeamSpeak channel: http://tsnfenrir.no-ip.org/ts3
Helm Script for Numerical heading input: https://dl.dropbox.com/u/10193809/ArtemisHelmFSW.zip
Twitter: @lucas99801
Facebook: /lucastarnold
avatar
Mike_Substelny said Mar 02, 2013 16:32:38
I don't think so. I wish the scripting language could control the main screen since many Captain keep the main screen on Long Range Scan all of the time and so the crew never gets to see generic objects, skybox changes, and other special effects.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
john said Mar 21, 2013 19:03:27
Excellent! This should be added to the unofficial wiki: artemiswiki.pbworks.com
Login below to reply: