Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
HaydenBarca

Registered:
Posts: 198
Reply with quote  #1 
I couldn't find a good answer for this on the forums, so I wanted to ask two related questions:
1) Can you pass data/hooks from Artemis to another scriptable function during a mission? (Out Of Artemis)
2) Can you pass data/hooks from outside to Artemis during a mission and have it affect the mission automatically? (Into Artemis)

For Out Of Artemis, I know you can start videos and the like, but I'm hoping to pass commands into another function, like a Discord Bot, Python program, etc.  The only way I'm aware of is to have the mission write to the log file very carefully and have another program monitor it.

For Into Artemis, I'm not aware of any automated way to do this.  The best I've come up with is to make GM buttons and have the GM manually monitor an outside program for cues, then use the GM buttons to make them happen in the game.
ryleyra

Registered:
Posts: 3,007
Reply with quote  #2 
I'm afraid that although the idea has been discussed, there is currently no way to do it. There is no way for a script to either save or load data. Of course, you can have a Game Master simulate this, but that's not the same thing.

HaydenBarca

Registered:
Posts: 198
Reply with quote  #3 
Thanks.  Has anyone tried Artemis Bridge Tools and a tracing socket?
http://www.armidalesoftware.com/Artemis/AdvancedMissionScripting.htm 

From what I can interpret from the description, you can pass cues Out Of Artemis, but not Into Artemis (though you can use the tool to, at the end of mission A1, modify the script for mission A2, so that when you later run mission A2, it reflects your state at the end of A1).

Otherwise, I'm guess I'm back to manual GMing.
ryleyra

Registered:
Posts: 3,007
Reply with quote  #4 
I think this could work, if you use IAH. You can set up a console that monitors the data stream and saves relevant changes to a save file. I'm pretty sure you can also read that file to "initialize" game state, if it's something that can be changed by the game's API.

You'd have to write the code yourself, though, which could be difficult if you're not an experienced programmer.

Your Artemis Bridge Tools link reminded me that there is a log command, which writes a line of text to a log file. This is primarily intended for debugging, so you can trace the actions of your script and verify what it is doing. However, that feature CAN be used to save data to a file, which Artemis Bridge Tools uses. The problem is that Artemis cannot natively read that data.

I actually don't know what Artemis Bridge Tools is able to store and retrieve in an "initialization" file. That seems like a useful feature. I will note, though, that the ability to read from the log file and play a video is not redundant, since Artemis is natively able to play video files, albeit with a third party video player to activate via command line.

I'll also add that Thom has discussed adding "hooks" to Artemis to allow third party software to interact with it. So we could in theory have a way to trigger an increase in torpedoes on the ship or on one of the bases. That's something we might see in Artemis 3.0.

HaydenBarca

Registered:
Posts: 198
Reply with quote  #5 
The Discordbot that I programmed uses node.js and can read from text files, so I could just make a really verbose log file and read from it periodically.  I'm just not sure it's worth the effort.
NoseyNick

Avatar / Picture

Registered:
Posts: 113
Reply with quote  #6 
https://artemis-nerds.github.io/protocol-docs/ describes the protocols, and at the bottom has links to a number of libraries that can be used to write your own tools.

Some examples of what I already do, for example:
"Artemis Puppy" can be sent to record  a game. At the end of the game it can post results to a Discord channel, for example:

Artemis-Puppy BOT Today at 22:39

Level 4 Double Front game
GAME RESULTS: LEVEL 4 RANK Captain: Game ended because all enemies were defeated.
        TSN ships destroyed   4      Friendly Stations Lost   0
Terran ships destroyed 2 Friendly Ships Lost 2
Kralien ships destroyed 18 Surrendered Ships Killed 0
Arvonian ships destroyed 16 Space Monsters Tagged 0
Torgoth ships destroyed 1 Ships surrendered 3
Skaraan ships destroyed 2 Player beams fired 258
BioMech ships destroyed 5 Player torpedoes fired 24
Successful dock attempts 9
Anomalies collected 8
Mine detonations 26
Mission duration (minutes) 20

I can also send some data INTO Artemis, for example I have scripts that configure up a fleet of standard ship names, types, jump/warp drives, etc, even Shuttle/Fighter types/names:

ShipConf(0, 0, 0, 'TSN-Serenity', # Warp (TSN) LightCruiser
  TSNShuttle('ST. Clair'),
);
ShipConf(0, 11, 0.55, 'TSN-Bluenose III', # Warp (Ximni) XimniBattleship
);
ShipConf(0, 4, 0.65, 'TSN-Vanguard', # Warp (TSN) Dreadnought
  TSNLRShuttle('Lime'),
  TSNMediumFighter('Djinn'),
  TSNMediumFighter('Tonic'),
);

... which really does exactly the same as if you'd used a real client to jump on each ship's helm and do a lot of typing/clicking:
CustomShips.png 

If you wanted to "pass data/hooks from outside to Artemis during a mission and have it affect the mission automatically", you can certainly simulate "press GM buttons" from unofficial client scripts/code "on the outside", which can trigger XML-scripted mission events right? Artemis's mission-file-docs.txt describes:

COMMAND: set_gm_button (adds a button to the current GM console)
        ATTRIBUTE: text
COMMAND: set_comms_button (adds a button to all relavent comms consoles)
        ATTRIBUTE: text
CONDITION: if_gm_button (triggers when a button from the current GM console is clicked)
        ATTRIBUTE: text
CONDITION: if_comms_button (triggers when a special button from a comms console is clicked)
        ATTRIBUTE: text

... which can then be clicked by an unofficial custom client sending this packet described in the protocol:
https://artemis-nerds.github.io/protocol-docs/#buttonclickpacket

... or there's these mission scripting commands:
COMMAND: start_getting_keypresses_from (sets a client console to key-active; it sends key press messages to the server)
        ATTRIBUTE: consoles
COMMAND: end_getting_keypresses_from (sets a client console to NOT key-active)
        ATTRIBUTE: consoles
                        VALID: text, a collection of the letters MHWESCO, defining which console(s) we want
CONDITION: if_client_key (triggers when a key is pressed on a key-activated console)
        ATTRIBUTE: keyText
                        VALID: text, single letter (usually upper case)

... which basically expect these from a client:
https://artemis-nerds.github.io/protocol-docs/#keystrokepacket

If you wanted other "data/hooks from Artemis to another scriptable function during a mission" you could definitely, for example, trigger something based on Intel or Comms messages from Artemis scripts to an outside protocol-parser:

objectText(1797,3,UTF16("Intel: The captain has no living family, and is bombastic.")); # 3=scan_desc
commText(16,UTF16("DS1").UTF16("We've produced another Beacon.  We now have 1."));
idleText(UTF16("TSN-Hopper").UTF16("All I ask is a tall ship, and a star to steer her by!"));

... so assuming your XML Mission scripts can send any of the above, possibly not even seen by "real players", those could trigger something "on the outside" for sure?

The above are all TOTALLY unofficial and unsupported, however. Other approaches I've seen WITHOUT reverse-engineering the TCP protocol(s) would involve logging to the mission log, and then having a script on the outside "watching the log" (MISS_BLAH/MISS_BLAH_LOG.txt) for particular messages to trigger events. Artemis's mission-file-docs.txt describes:

COMMAND: log (sends text to the mission's log file)
        ATTRIBUTE: text

There's the DMX stuff I s'pose, which is kinda a special RS232 serial output. I'm not sure mission scripts can trigger DMX events directly though?

I'm unaware of any official way of getting outside data INTO a mission apart from the mission file itself - I've seen discussions of using one MISS_BLAH_LOG.txt output, fed through something in between missions, to create the next MISS_BLAH2.xml with some initial settings changed to match results of the previous mission, for some sort of "continuity" between subsequent missions... but not after a mission has already started running as far as I can tell.

I suppose you could use a real USB keyboard / HID device, or keystroke injection onto a real official console with the start_getting_keypresses_from / if_client_key above?


ryleyra

Registered:
Posts: 3,007
Reply with quote  #7 
Yeah, basically if you have any script that responds to GM keys/buttons, you should be able to use the Artemis network protocols to trigger those events and make changes to the game in progress. Unfortunately, you can't change any of the non-scripting modes, but presumably that would be what Thom's "hooks" would allow you to do.

I would definitely recommend looking into the networking if you want to get into advanced programming of an Artemis interface. I mentioned IAH, but there are lots of options.
Dave Thaler

Registered:
Posts: 503
Reply with quote  #8 
Quote:
Originally Posted by HaydenBarca

1) Can you pass data/hooks from Artemis to another scriptable function during a mission? (Out Of Artemis)


Yes.  There are three ways to do this.

1) Use the spawn_external_program mission scripting command to launch the Python program or whatever.  You can pass data via the command line arguments, e.g., by using variables that your script sets.   This is the easiest way to get what you want.

2) As you and ryleyra mentioned, you can use the log mission scripting command to write data to the log file, and have another program monitor it.   You can also combine this with technique 1 to log large data and then spawn an external program to read it, rather than trying to fit everything on the command line.

3) If the script is willing to require that Artemis Bridge Tools be installed, then you can use a tracing socket that an external program can monitor, as you mentioned.

Quote:
Originally Posted by HaydenBarca

2) Can you pass data/hooks from outside to Artemis during a mission and have it affect the mission automatically? (Into Artemis)


This is much more difficult, but there are a couple ways to do it.

1) You can have the external program implement a custom Artemis client, as NoseyNick mentioned.  The downside is that you have to write more code to do it.  There's only so much you can do that you can use to affect the script, but I've done it myself for a current mission script I have (alluded to in post #6 in this thread).

2) You can have an external program that generates a brand new mission script.  The downside is that you can only affect a mission before it's launched, not during the mission.

3) You can use Artemis Bridge Tools to do the work of #2 for you, with the same downside.  There's a walkthrough here.

HaydenBarca

Registered:
Posts: 198
Reply with quote  #9 
Wow, thanks guys.  That'll keep me busy for a while.
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.