Create account / Log in

Report Action problem

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Report Action problem

Postby zmpouf » November 15th, 2011, 4:05 pm

Hello everybody.

Before I tell you about my problem let me thank you for the awesome job you 're doing. :D I have found answers to almost all of my questions by digging into those forums. :D :D :D Keep up the good work.

To my problem now. I'm creating an new module for Hannibal: Rome vs Carthage. I have added the Replace with Other trait to a piece (Basic Piece Name: Roman PC) with a Keyboard command to Ctrl F. This piece is replaced by a piece named Carthaginian PC. Since I want to report this action I added a Report Action Trait that also activates with Ctrl F. The report format is this: $playerName$ ($playerSide$) flipped $oldPieceName$ to $newPieceName$ in $oldLocation$ * . What I'm trying to get here is something like this: Player (Side) flipped Roman PC to Carthaginian PC in location.

The problem is that the newPieceName property stays to Roman PC. I can get the why: The trait affects only the piece it is on and by replacing it we create a new piece. By pressing Ctrl F the old piece's newPieceName remains the same and the piece is removed from the board.

How can I make the Report Action trait to report the new piece's name? I would like to avoid "hard coding" the new piece's name instead of using a property value.

Cheers,
Andreas
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm

Re: Report Action problem

Postby JustaBill » November 16th, 2011, 12:38 am

The problem is that no single piece will really know the names of both pieces. The old piece knows its name, and the new piece knows its name. This means you're probably going to need both pieces to contribute some effort to the goal, by giving your first piece's Replace with Other trait a Keystroke to Apply After Placement attribute so it can tell the second piece to finish the job.

I can think of two solutions that don't involve hardcoding:

  1. Have the old piece report the first half of the message, and the new piece report the second half. This means your report will take two lines in the chat window. Something like this:

      Player (Side) flipped Roman PC to ...
      ... Carthaginian PC in location.
  2. Have the old piece save its name to a generic, re-usable Global Property, then have the new piece deliver the entire message and use the GP to fill in the old piece's name. This will require the first piece to use a Trigger which first generates the keystroke to load the GP and then generates the keystroke to perform the Replace with Other. The Replace with Other trait's Keystroke to Apply After Placement would cause the second piece to deliver the report, in which the Global Property provides the old piece's name and the new piece provides its own name.
JustaBill
 
Posts: 21
Joined: October 25th, 2011, 3:34 pm

Re: [messages] Edit: [Module Design] Re: Report Action prob

Postby Brent Easton » November 16th, 2011, 12:59 am

In general, I try and avoid the Replace trait for just these reasons, as well as the fact as they are very difficult to work with since the new counter definitions are hidden away inside the replace trait.

It may be too far down the track, but a third option is to change the design of these pieces so that the entire behaviour is built into the one piece using a Layer to change the image and varying Dynamic Properties to change any properties that need to change.
User avatar
Brent Easton
 
Posts: 2757
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Report Action problem

Postby JoelCFC25 » November 16th, 2011, 1:03 am

How about having a piece with a Layer trait (always active, loop through levels)--one level is the Roman PC, the other level is the Carthaginian PC. Report Action will work like a charm if you name the levels according to what you want the message to look like. The piece can be duplicated with the levels reversed if you want both types of PCs to display in the palette.
JoelCFC25
 
Posts: 589
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: Report Action problem

Postby zmpouf » November 16th, 2011, 10:22 am

At the point I am now (almost finished module, just playing with the reporting in chat window), the easiest way to go is to just hard code the new piece's name. Maybe I will use layers instead of replace on a newer version of the module when Vassal 3.2 is released (since it has some new features I could use too :) ).

The reason I used the Replace trait is because at the time I started "moduling" with vassal, roughly a month ago, it seemed a better idea for what I wanted to do. I didn't know that it could cause me that problem later. And every now and then I discover features in the vassal engine that can make my life easier. It's my first module, I couldn't expect everything to be easy.

By the way, all the ideas mentioned above are great. Thank you all for answering my questions.

Cheers,
Andreas
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm

Re: Report Action problem

Postby zmpouf » November 21st, 2011, 4:14 pm

I have another problem with reporting.

Since I don't like the auto-report format a map window offers (moving within/to/in this map) I decided to go with custom reporting. But the auto-report has an advantage: When you move a stack, the report returns a $pieceName$ value as "piece 1, piece 2, ... , piece x". In custom reporting each piece reports alone, so if I move a stack with 10 pieces I get 10 lines of reporting.

To use one line reporting I thought of making a global property to write the moved pieces' names and then use it's value with a report action trait.

What I have done:

a. In my main map window I set the Key command to apply when ending movement: ALT CTRL SHIFT MINUS

b. Add a gp named "CUmoved" (without "")

then on the piece I wanted to report I placed the following traits in this order:

c. Dynamic property trait,
Name: hasmoved
Value: false
Key command: ALT CTRL F6 -set value directly - New Value: true
Key command: ALT CTRL F7 - set value directly - New Value: false

d. Set Global Property trait,
GP Name: CUmoved ,
Key Command ALT CTRL F1 - set value directly - New Value " " (just a space character)

e.Trigger action trait,
watch for: ALT CTRL SHIFT MINUS
Perform: ALT CTRL F6 , ALT CTRL F1 , ALT CTRL F2

f. Global Key command trait,
Keyboard Command: ALT CTRL F2
Global Key Command: ALT CTRL F3
Matching Properties: hasmoved=true
Restrict range: yes
Fixed Range: yes
Range: 1

g. Set Global Property trait,
GP Name: CUmoved ,
Key Command ALT CTRL F4 - set value directly - New Value "$CUmoved$$PieceName$, "

h. Trigger action trait,
watch for: ALT CTRL F3
Perform: ALT CTRL F4 , ALT CTRL F5 , ALT CTRL F7

i. Report Action trait,
Report on keystrokes: ALT CTRL F5
Report format: $playerName$ moved $CUmoved$

the above doesn't work:
problem 1: The report action trait doesn't report anything.

problem 2: the CUmoved GP gets the name of the top piece in the stack only.

If I remove the Matching Properties: hasmoved=true from step f then it gets all names correctly. But then, if I move a two piece stack in a location that already contains a piece of the same type, the CUmoved GP gets the names of all three pieces.


The way I wanted to work is this:

Move a stack with two pieces from irregular_grid_1 to irregular_grid_2,
trigger an end movement on map (step e.),
change the value of "hasmoved" to "true" in all pieces in stack (step c.),
send a key command to all pieces in irregular_grid_2 that moved now (here comes the use of the hasmoved propery - If I move the pieces to irregular_grid_2 but there existed another piece then I would trigger this piece too),
each of the pieces I sent the key command adds it's name to the CUmoved Global variable,
report the pieces moved by using the $CUmoved$ value
set all pieces hasmoved property to value false.

What am I doing wrong? I would like a why too because I can't figure this out.

Sorry for the long post.

Cheers,
Andreas
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm

Re: Report Action problem

Postby DrNostromo » November 22nd, 2011, 4:11 am

When you're using a Global Key Command to send a command, are you making sure the "Suppress Individual Reports" is NOT checked (it's checked by default).
User avatar
DrNostromo
 
Posts: 1036
Joined: December 21st, 2007, 3:54 am
Location: Wine Country, Cal. USA

Re: Report Action problem

Postby zmpouf » November 22nd, 2011, 9:04 am

Thank you DrNostromo.

That was the first problem. When I unchecked Suppress Individual Reports the report trait started reporting.

But what about the second problem? I can't understand why it reports only the top piece.
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm

Re: Report Action problem

Postby zmpouf » December 1st, 2011, 10:33 pm

Ok, I solved this so I thought it might interest someone else how I did it.

a. In my main map window I set the Key command to apply when ending movement: ALT CTRL SHIFT MINUS

b. Add a gp named "CUmoved"

c. Add a gp named "Passes"

d. Add a gp named "PieceTotal"

e. Add a gp named "PieceTotalCounted"

then on the piece I wanted to report I placed the following traits in this order:

f.Trigger action trait,
watch for: ALT CTRL SHIFT MINUS
Perform: ALT CTRL F12 , ALT CTRL F6 , ALT CTRL F1

g. Trigger action trait,
Trigger when properties match: PieceTotalCounted=false
watch for: ALT CTRL F1
Perform: ALT CTRL F10 , ALT CTRL F2 , ALT CTRL F8 , ALT CTRL F3

h. Trigger action trait,
Trigger when properties match: PieceTotalCounted=true
watch for: ALT CTRL F1
Perform: ALT CTRL F3

i. Trigger action trait,
Trigger when properties match: Passes=$PieceTotal$
watch for: ALT CTRL F3
Perform: ALT CTRL F4 , ALT CTRL F11 , ALT CTRL F7 , ALT CTRL F5

j. Global Key command trait,
Keyboard Command: ALT CTRL F2
Global Key Command: ALT CTRL F9
Matching Properties: Selected=true
Restrict range: yes
Fixed Range: yes
Range: 1

k. Set Global Property trait,
GP Name: Passes ,
Key Command: ALT CTRL F12 - increment numeric value - increment by: 1
Key Command: ALT CTRL F11 - set value directly - New Value: "0"

l. Set Global Property trait,
GP Name: PieceTotal,
Key Command: ALT CTRL F10 - set value directly - New Value: "0"
Key Command: ALT CTRL F9 - increment numeric value - increment by: 1

m. Set Global Property trait,
GP Name: PieceTotalCounted,
Key Command: ALT CTRL F8 - set value directly - New Value: "true"
Key Command: ALT CTRL F7 - set value directly - New Value: "false"

n. Name: CUmoved,
Key Command: ALT CTRL F6 - set value directly - New Value: "$CUmoved$$PieceName$, "
Key Command: ALT CTRL F5 - set value directly - New Value: ""

o. Report Action trait,
Report on keystrokes: ALT CTRL F4
Report format: $playerName$ moved $CUmoved$

It's easy to see what I'm doing here, if anybody can't see it then tell me and I 'll explain it.

Cheers,
Andreas
zmpouf
 
Posts: 24
Joined: August 22nd, 2011, 1:51 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 1 guest