Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Idea: Would it be possible to get it to handle more than one secure shell? I'm thinking like doors. That way we could make it network and have like terminal-dungeons. :D

(9 edits)

You could do this in one of two ways.

The simplest is to chain the Terminals together. So, each Terminal can Secure Shell to the next one.

The more complicated way requires some scripting but I’ll walk you through it. This way also requires using Foundry V12+, since it uses Regions. This will create a one-to-many relationship of Terminals. You’ll need to create a new Region. Keep the Region in an area players can’t get to, it will only be used for scripting. Then create a “Run Script” Behavior. For an example see the screenshot below. I created 2 Run Script Behaviors and renamed them to “Open Terminal 1” and “Open Terminal 2”. I have the code later which you’ll want to enter for each Behavior.

You’ll want to have each of your behaviors use a separate “Subscribed Event”. For mine I used “Token Enters” & “Token Exits”.

Now we need to link these Event Behaviors to the parent Terminal. Open the tile config for your main Terminal tile. Then open the Trigger Regions window (see screenshot below of the opened window). Add the new Region. You’ll want to add it multiple times (since I’m only linking two Terminals, I’ll add that same Region twice).

Then to finish the link, we need to edit the “Simulated Event” field to match, one to one, with those Behaviors we created. So, for me that’s the “Token Enters” & “Token Exits” events.

I know this gets a pretty complicated and likely confusing. Try and match what I have in the screenshots as best you can to just get it working.

What this does is every Region that’s added here will become a button in the main Terminal. The button will simulate your chosen Region event. This trigger all Behaviors that are subscribed to that event (in our case it’s one-to-one). Since the Behaviors are script Behaviors this runs the code you have in the Run Script field.

Now, that everything is linked let’s go back to your “Run Script” Behavior. You need to actually define the code to run. Copy this code into a notepad:

const TILE_UUID = "PUT_YOUR_TARGET_TILE_UUID_HERE"

const terminalOpen = Array.from(foundry.applications.instances.values()).find(a => 
  TILE_UUID === a.context?.tuid
)

if (!terminalOpen) {
  new Terminal(TILE_UUID).render(true)
}

Replace the TILE_UUID variable with any one of the target child Terminal’s UUID. Then enter your edited code into the Behavior’s Script field. That finishes one Behavior’s “Run Script” but we have multiple. For each child Terminal you want to link, update the TILE_UUID each time and paste your code into a different “Run Script” Behavior.

That should be it. There are only a few extra considerations. This bypasses validation on your Terminal settings. This bypasses the initial Item and Skill checks (password should still work).

Eventually I’m sure Foundry will support running Macros with arguments from Regions and this will be simpler but that isn’t happening anytime soon.