[messages] Edit: [Module Design] Re: Stacked pieces

JustaBill martinson2005 at netscape.net
Wed Jul 11 12:28:45 MST 2012


[This message has been edited.]

Sorry to necro an old thread, but I have pretty much the same issue.

If I'm reading him correctly, I think the OP's need has been
misunderstood.  The way it was presented left the impression that he
wanted to treat certain "special" units in the stack differently, but I
think he just wanted to treat a _limited number_ of units differently,
regardless of their characteristics.  For example, there might be a game
rule that says "one unit goes to the dead pile and the rest return to
your camp".

I have a very similar need in Cosmic Encounter, where there are stacks
of identical ships all over the place but you often need to pop one (or
some other number) of them off the top to send it somewhere.  This is
cumbersome for the user, since you have to double-click to expand the
stack, drag the top ship(s) away from the stack, double-click again to
reset your stack, then drag the isolated ship(s) where you want them to
go.  Over and over again.  I want to build one-shot commands to do this
work for the user, in two different contexts:

(I) Pull: Bring 1 ship "here" from the standard dead pile (called "the
warp").
(II) Push: Send 1 ship "there" (somewhere predefined) off the top of a
stack.

Note: I can't really use _decks_ for this, for reasons I'll omit in the
interest of brevity.

"Pulling" is doable if you use a global counter of some kind.  All the
objects (pieces) that can be "here" destinations for the ship from the
warp use a prototype that defines a Retrieve 1 Ship trigger (Ctrl-R)
that
  * sets my global GenericCounter = 1
  * records the "here" object's location in global properties GenericX
and GenericY
  * issues a "Move" Global Key Command to all units of the appropriate
color in the warp


The "Move" key is caught by a trigger on the ships that
  * checks to make sure GenericCounter > 0
  * sends the ship to GenericX,GenericY
  * performs a one-pixel "jog" using Move Fixed Distance to force the
ship to jump onto any stack already at that location (this does not
always work, btw)
  * increments global GenericCounter by -1


In this way, I can easily implement "bring 4 ships here" by initially
setting GenericCounter to 4 instead of 1.  The first _n_ ships processed
move as desired, and the remaining ships do nothing since GenericCounter
has now wound down to zero.

"Pushing," though, I'm finding impossible.  The method outlined above
requires either setting or clearing a global either before or after all
of the incremental actions, so you can really only do it when it's
triggered by something external to the pieces being moved, such as
another piece that wants to receive them, a global hotkey sending them
to a known location, etc.  What Scenario II really wants is for the user
to be able to right-click on the top piece of a stack, _or_ left-click
on the entire stack, and have the chosen key command (not an external
button) send the top _n_ pieces from that stack regardless of how many
are selected.  Basically, I'm trying to define a stack-level command by
attaching it to the pieces in the stack.  As best I can tell, this is
not doable since in a "push" context every action that will happen will
be sent to each of the pieces in the stack, and I have no way to
initialize my GenericCounter to 1 or 4 without the initialization being
repeated right before each selected piece is processed.  (I am assuming
the "command stack" in Vassal works by identifying all pieces that
should receive a keystroke and then queuing up the keystrokes against
those pieces; at least my empirical results seem to suggest this.)

Even using a deck doesn't seem to help.  I could move the pieces to a
hidden deck, draw the top 1 or 4 cards from that deck, senbd them
somewhere, and then move the rest of the deck back to the original spot
— but without an external initiation point, I can only issue the "Draw
1" or "Draw 4" command from the pieces themselves, which would cause it
to happen an unpredictable number of times.  So I'm baffled about how to
implement this in a way that doesn't require two or more steps (select
your pieces, then move your mouse to a toolbar and click a button).

What would make this all a lot simpler would be some way to __define
action X as a _stack_-level action__ and then define whether it applies
to the entire stack or the top _n_ pieces that meet whatever filter
criteria are supplied.  (And maybe specify the minimum total stack size
for the action to apply in the first place: specifying "2" would mean
the action is ignored if the piece isn't actually in a stack.) If this
were just implemented for Triggers I think that would be sufficient for
most needs, since a trigger can fire  anything else. The idea is that it
wouldn't matter if the user left-clicked the whole stack or
right-clicked the top piece, or if a piece that had been sent to the
bottom was still selected; in all cases the Trigger would be applied as
if the user had manually selected the top _n_ pieces that meet the
filter criteria and then performed the command.

Alternatively, what I need is a __module-level setting to make stacks
work more like decks__ in the sense that you can grab and drag the top
piece off in one smooth action without moving the whole stack. 
Basically, a global option that I can check that says the default drag
on the top of a stack applies to the top piece instead of the whole
stack; thus, to move an entire stack I would have to left-click it
first.  This would save users TONS of extra clicking in my Cosmic
Encounter module.  Basically, Vassal assumes all stacks are "sticky" but
non-wargames often need them to be "non-sticky".

_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=35135#p35135


More information about the messages mailing list