Remember which deck cards came from...

Greetings

Currently my module allows you to click on one of the (24) Trade Decks, select Deck Global Key Command “Trade” and it will send all cards in that deck to the player’s Trade Hand.

I want to have a button somewhere that will send all cards in the player’s Trade Hand back to the original Trade deck.

All I really need to do is set a global property to a numeric value 1-24 when using the deck’s “Trade” DGKC, however I can’t seem to figure out how to do this without forcing the user to make two clicks on the deck (“Trade” and “Set Active Trade” for instance).

Is it even possible for a DGKC to set a global property, or does it just apply the KC to everything in that deck?

Thanks

So while waiting on hopefully a more elegant solution I decided to instead give the label (hidden piece) next to the deck the GKC, which triggers the variable and the send-to-hand commands.

Next issue though… there doesn’t appear to be a variable Return To Deck. ie Trade Deck $nActiveTradeDeck$. Am I going to have to specify a region for each of these decks too?

Try using Return to Deck on the cards in a prototype

Sorry Tim. I don’t follow. :confused:

Return to deck has me specify from a list of decks, I wish for the destination to be a dynamic property.

I believe you can use a SendToLocation trait instead of ReturnToDeck to send cards to a deck - if you send it to the same coords as the deck it should go into the deck. SendToLocation does support property expressions, so you could make the deck choice dynamic by having global properties TradeDeckNX and TradeDeckNY (for N = 1 to 24). Then in SendToLocation, use expressions like …

{GetProperty("TradeDeck" + nActiveTradeDeck + "X")}
{GetProperty("TradeDeck" + nActiveTradeDeck + "Y")}

… for the coords.

Thanks Foobarius

I figured I would have to do something like that.

I’m having a new problem now.

Originally my deck GKC would send CTRL R to all cards in the deck. CTRL R was a send to location trait on the Cargo prototype, sending them to the active player’s Trade Hand.

I decided instead though I needed the DGKC to do two things:

  1. Set the global property (so the cards know which deck to return to later)
  2. send the cards

So for each Trade Deck, I want an invisible piece. Where I want the following process:

Player selects “Trade” DGKC on Trade Deck 1
Trade sends out GKC: SHIFT A
Basic Piece: Trade Counter 1 triggers on SHIFT A, sending out ALT A and ALT CTRL SHIFT R
Trade Counter 1 has GKC: ALT CTRL SHIFT R → CTRL R (where DeckName = “Trade Deck 1”)
Trade Counter 1 sets global property nTrade, ALT A → 1

Any Cards in Trade Deck 1 get send to location on CTRL R, sending them to current player’s trade hand (this already worked previously)

Problem is… when I select “Trade” on Trading Deck 1, nothing happens. The cards in that deck no longer receive the CTRL R command. Can a GKC not talk to cards in a deck?

I even tried to make the GKC trigger a DGKC, but nope.

Is it the case that the DGKC only ever applies to the contents of the deck?

This is indeed the case, I’m afraid. You could add a GKC to the pieces in the deck, which forwards the command on to the Trade Counter 1 piece (I’ve done something like this myself in the past). But in your case, since all you need to do is set a global property, I think you can avoid the need for the Trade Counter 1 piece entirely.

I think you can just use a couple of Trigger Actions on the cards in the deck to set the property then move the card:

Trigger Action 1:

  • Keyboard command: SHIFT A
  • Perform these keystrokes:
    ensureNTrade1
    CTRL R

Trigger Action 2:

  • Trigger when properties match: {nTrade != 1}
  • Keyboard command: ensureNTrade1
  • Perform these keystrokes:
    ALT A

The second Trigger isn’t strictly necessary, since you could just put ALT A in the first Trigger. But setting a global property causes data to be sent to other players and/or the log file, so having both Triggers saves a bit of bandwidth/filesize.

Incidentally, an often overlooked VASSAL feature is ‘named keystrokes’ (like ensureNTrade1 in the example above). When you need to enter a keystroke, you can just type in a string of characters instead of a ‘real’ keystroke. The user can’t perform these keystrokes in the actual game, so they’re useful for internal things that the user shouldn’t know about.

Yep, i figured the DGKC might have been the issue, I got it working.

I kept the counter (each deck has a label showing the name of the deck and card count, so used this), gave it a trigger command “Trade” which triggered a Set Global Property nTrade to 1 (edited this number 1-24 for each instance of the counter), then do the send to location (player trade hand) for matching properties DeckName = Trade Deck $nTrade$

Made an irregular grid, defined a region for each deck with the same coordinates as the respective deck, turned off snapping, named them TradePost1, TradePost2 etc

Added a button to the player trade hand which triggers to all pieces in the current map, hitting a send to location (region) with region name TradePost$nTrade$ on the cargo card prototype.

Works like a charm, just have to click the deck label instead of the deck, no biggie, its a big label.

That custom string for a hotkey one is good to know. I do find myself often messing up which hotkey was which. Do they apply to all key commands? I notice some traits specify “hot” while others dont.

Hotkeys and key-commands are actually two separate things - hotkeys are sent to toolbar buttons, whereas key-commands are sent to pieces. (That’s why there’s both a Global Hotkey trait and a Global Key Command trait.) Both of them support named keystrokes.

Nice. Thanks Foo.