# Replace with other randomly

**URL:** <https://forum.vassalengine.org/t/replace-with-other-randomly/90549>\
**Category:** Module Design\
**Created:** [September 28, 2026, 7:41pm UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549 "2026-09-28T19:41:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sotchris](https://forum.vassalengine.org/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@Sotchris](https://forum.vassalengine.org/u/Sotchris)\
**Post date:** [September 28, 2026, 7:41pm UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/1 "2026-09-28T19:41:06Z")

</div>

Question: How do I radomly replace a piece from a list using the “Replace with other” trait ?

---

<div class="post-metadata">

**Author:** ![jrwatts](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/jrwatts/32/6972_2.png) [@jrwatts](https://forum.vassalengine.org/u/jrwatts)\
**Post date:** [September 28, 2026, 9:59pm UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/2 "2026-09-28T21:59:54Z")

</div>

Unfortunately, this isn’t easy, unless the only difference between the possible replacement pieces can be represented by a single randomly selected trait (in that case, you can use a single piece, and trigger the random trait selection on placement).

Assuming that isn’t the case, you will need:

1. a separate `Replace with other `trait for each possible replacement piece.
2. a `Dynamic Property` with a command to set it to a random number with the value `{Random(x)}`, where “x” is the number of possible pieces.
3. `a Trigger Action` for each `Replace with other`, all triggered on the same named command, which checks for the `Dynamic Property` to be equal to a specific number, and then runs the matching `Replace with other`.
4. one more `Trigger Action`, which calls the `Dynamic Property` to generate the random number, then calls the other `Trigger Action`s to trigger the correct `Replace with other` trait.

---

<div class="post-metadata">

**Author:** ![cholmcc](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/cholmcc/32/8319_2.png) [@cholmcc](https://forum.vassalengine.org/u/cholmcc)\
**Post date:** [September 28, 2026, 10:57pm UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/3 "2026-09-28T22:57:11Z")

</div>

- Replace With
  - Path: …
  - Key: `replace1`

- Replace With
  - Path: …
  - Key: `replace2`

- …
- Trigger
  - Key: `doReplace`
  - Action keys: [`replace1`],
  - Property: `{Replacement == 1}`

- Trigger
  - Key: `doReplace`
  - Action keys: [`replace2`]
  - Property: `{Replacement == 2}`

- …
- Dynamic Property
  - Name: `Replacement`
  - Commands:
    - Key: `pickReplacement`
    - Expression: `{Random(n)}` (`n` is the number of possiblities)

- Trigger trait
  - Key: `replace`
  - Command: `Random replacement`
  - Action keys: [`pickReplacement`, `doReplace`]

Just to pin it out a bit more.

Please remember to mark the solution to your question. It helps _everybody_.

Yours,  
_Christian_

---

<div class="post-metadata">

**Author:** ![shilinski](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/shilinski/32/6980_2.png) [@shilinski](https://forum.vassalengine.org/u/shilinski)\
**Post date:** [September 29, 2026, 4:25am UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/4 "2026-09-29T04:25:52Z")

</div>

I wouldn’t use replace-with-other. I’d put all the replacements in an always-shuffle deck. In my main piece, I send a GKC to get a random piece from the deck. The replacement would go to the main piece. Then I’d delete the main piece.

---

<div class="post-metadata">

**Author:** ![Sotchris](https://forum.vassalengine.org/letter_avatar_proxy/v4/letter/s/278dde/32.png) [@Sotchris](https://forum.vassalengine.org/u/Sotchris)\
**Post date:** [September 29, 2026, 7:51am UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/5 "2026-09-29T07:51:29Z")

</div>

Thank you for your reply. I must have done something wrong because it doesn’t seem to work.

Is this the proper sequence of traits as they appear on the screen? Also, in the Dynamic Property the Type should be “Set Value Directly”?

---

<div class="post-metadata">

**Author:** ![cholmcc](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/cholmcc/32/8319_2.png) [@cholmcc](https://forum.vassalengine.org/u/cholmcc)\
**Post date:** [September 29, 2026, 7:19pm UTC](https://forum.vassalengine.org/t/replace-with-other-randomly/90549/6 "2026-09-29T19:19:57Z")

</div>

> [@Sotchris](#):
>
> I must have done something wrong because it doesn’t seem to work.

You can try to debug the above by adding context menu commands to f.ex. the `Replace with` traits - just to see that they execute correctly.

You can also add `Report Action` traits that reacts to the `Trigger` and `Dynamic Property` traits, to see that they are executed as you expect. F.ex.

- Report trait
  - Keys: `pickReplacement`
  - Report: `{"~Replacement pick is set to " + Replacement}`

Note, you must either give a literal integer value for `n` in `Random(n)` or define it as a Property -for example

- Marker
  - Name: `n`
  - Value: `10` As an example

> [@Sotchris](#):
>
> Is this the proper sequence of traits as they appear on the screen? Also, in the Dynamic Property the Type should be “Set Value Directly”?

For these traits, the order is not important. If you have `Restrict Acccess` or similar traits, in the same piece or prototype, you must consider where such a trait is relative to the above traits.

> [@Sotchris](#):
>
> Also, in the Dynamic Property the Type should be “Set Value Directly”?

Yes, that’s correct.

Note that it is imporant that you do not give the conditional `Trigger` traits any user visible context menu command. That field should be left blank.

Yours,  
_Christian_
