Disable a single piece

Ok. New to creating modules and had a question.

I have a “single piece” that I want to have disabled and unable to be moved until a Global Property is a certain level.

For example, I created an At-start stack single piece that is a card in the player’s hand at the beginning of the game. I want this piece to be unmovable and un-selectable to start with. Then when a Global Property reaches a certain level, I want the piece to become active. I have the part of the Global Property and how to change the values. The problem I am having is what property of the piece enables and disables the piece? I found where I can enable/disable a keystroke, but not an entire piece.

Might be easier to try and have a “dummy piece” in your at start stack. The dummy would be the piece in its disabled state. Then when a global property reaches a certain point a Trigger for Activation of the piece could become available which would Replace With Other the dummy piece.
If having an Activation trigger on the piece is no good, you could also add a Global Key Command onto whatever other piece/object increases your Global Property you are tracking. For instance:

-You have a piece with a value called HP that can be increased or decreased with a keystroke
-You have your at start disabled piece, let’s call it a Hospital
-You use a Trigger for increasing and decreasing this dynamic property (the HP)
-The disabled Hospital is actually a dummy piece, all it has is a Replace with Other property
-At the end of the HP changing Trigger could be a Global Key Command that only fires if HP < 10 (or whatever value) and (&&) a global property that is either true/false for if the Hospital piece has been activated. So it would only fire if HP <10 and Hospital is Inactive.
-The Global Key Command would initiate a replace with other on your Hospital to replace it with the actual, active Hospital piece

Clear as mud?

Kinda sorta. Can you explain a little better. Like,

  • Dummy piece (Card piece that just has “Replace with other”)
  • Tech Level Piece (this piece changes the level of the tech - has Global Key Command that fires only when "Tech > 5 && global property “Unlock” = false)

So, a couple of things:

  • How do I change the global property “Unlock” to true, so it doesn’t do the command over and over
  • How would the Global Key Command look? The options for that are kinda confusing

I think the issue you may be running into is that a piece has to have the ‘Does Not Stack’ trait set to be immovable. This trait is set at design time and there isn’t any way I know of to change it via module interaction during run time. What you need to do is make your piece/card and then make a transparent piece of the same size or slightly larger to cover the piece. The transparent piece would contain the does not stack trait and a delete trait and a hide/disable command trait. Hide the delete command until the minimum threshold is met in your GP. Make sure that you put the transparent piece in a layer above the underlying piece so the two items don’t get accidentally swapped.

Then when the covering transparent piece is deleted, the piece underneath is accessible to the user.

Well, I actually want to lock and unlock the piece. I guess I’m not explaining it well enough. :frowning: I’ll just keep trying things.

There is a detailed description of how to do this on p54 of the Designer’s Guide, under ‘Creating Locked Pieces.’ The guide is available from the Docs section of the site.

Ok. That helps with that. Let me ask this. Is there a way to change a piece trait value from the actions of another piece. I thought of another way to accomplish what I want to do…if I’m able to.

I have a game piece that has “Restricted Access” and it’s initially set to “Locked” (which is a non-existant player, so no one can do anything with the piece).

Then I have another piece that is my tech level piece. It allows the player to adjust the level. When the level is a certain point (say >5) then it will change the “Restricted Access” of the previous game piece from “Locked” to “Purple Player” (a valid player).

And the reason I ask this, is because the Locked Pieces example in the Guide is for allowing to lock the pieces themselves. I’m looking for a way for the system to do it when the Tech Level reaches a certain number. And I still don’t quite understand the Global Key thing, which I’m sure is what I am looking to do, I just don’t understand the command.

So I think the Unlock at Value >5 can work with a Global Key Command, the best way to do it would be to connect the Global Key Command to whatever it is that increases/decreases your Value.

So let’s say your Value is a Global Property.
Let’s say we have a piece that has the Set Global Property trait. Some key combo increments by 1, Some Other key combo decrements it by 1. But leave the Menu Command section for these function blank in the Set Global Prop window (this keeps them from showing up for the player). We’re gonna have the Increment/Decrement handled by a Trigger instead.
Next, though, let’s set up a Global Key Command, call it Unlock, if you want. Don’t set a Menu Command name for it, so players can’t access it accidentally. Set a key command for it, this is what key needs to be “pressed” to activate it. Then Set a global key, this is the key that will be pressed on ANOTHER piece. To target a piece, use the Properties Matching section. Have it only press the key on BasicName = WhateverTheLockedPieceIsCalled && (this is saying AND) TheGlobalProperty > 5. This means the Global Key Command to unlock will only be executed ON a specific piece by “BasicName” which is the piece’s name AND if the Global Prop we set up is > 5.
Set up a Trigger, call it Increment Trigger if you want. This Trigger will execute 2 key commands on the piece. First it will do Whatever the Increment key combo you set in the Set Global Property Trait, then it will do the Global Key Command.

So if you’re INCREASING the global property for this is what happens:
Player activates the Increment Trigger → Global Prop is increased by 1 → Unlock Global Key COmmand is executed on the locked piece IF the GLobal Prop is now > 5.

To do the reverse, just set up a Decrement Trigger that decreases the Global Prop then executes a second Global Key Command that checks if the Value is <=5 and executes a Lock on the piece.

Any clearer? I’m not great at explaining Vassal. Hopefully this will allow you to have the game track the value to lock/unlock the piece.

By god, I think that does it. :slight_smile: I still need to play around with it some to work like I want it to, but that does it. Thank you very much.

I did have one more question. Is there a function to directly change a piece trait, in particular the “Restricted Access” trait?

Restricted access? Not that I know of, in fact it can’t even be changed during the game, I don’t believe. What you would typically do would be to use Replace With Other to swap the piece out with an identical piece with a different Restricted Access trait. Seriously.

As for changing other traits, you usually do this:

  1. Piece A triggers a Global Key Command with a property filter to target piece B
  2. Piece B listens for the GKC keystroke with a Dynamic Property, and changes its own property

It is generally not possible for one piece to directly manipulate another piece. Pass control from one piece to another with Global Key Command.