Easier looping

While the addition of scripting will allow programmers to more easily add looping constructs to their modules, I also see a need for a basic looping facility for the non-programmers among us. I don’t want to force people into using Scripting to basic functions.

My idea is to add a looping option to ‘Trigger action’ for counter loops and to ‘Multi-action button’ for component loops.

Loop? Y/N
Hotkey before loop:
Loop X times OR Loop until property match is true
Hotkey after loop:

For Trigger Action, the before/after Hotkeys would be sent to the current counter. For the Mutlti-action button, the Hotkeys would be sent to the top level Component Hotkey handler.

I think this should allow you to implement the basic looping structures far more easily than the various complex schemes people have created to date.

Thoughts?
B.

I think that’s reasonable for non programming.
Will the future scripting still allow for key commands, where by we can have
a live CP such as:

If(CTRL A, Property = x, CTRL B) or some such stuff?

Post generated using Mail2Forum (mail2forum.com)

I’m not sure I follow. The If() function in a Calculated Property is

If (condional, return value if true, return value if false)

I don’t quite understand what you are trying to achieve?

B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

That’s right,

My conditional is the keystroke, in other words if that keystroke occurs, do
this (return true), else do that (return false).

Just a different way of using the if() function in CP

Post generated using Mail2Forum (mail2forum.com)

Still doesn’t make much sense to me I’m afraid.

Do you mean you want the CP to be able to interrogate the current KeyCommand being processed and perform different options depending on what it is?

I’m also not sure what you mean by ‘Will the future scripting still allow for key commands’? what current scripting components allow for key commands?

Perhaps a more detailed scenario would help me follow your thinking?

Confused,
B.
*********** REPLY SEPARATOR ***********

On 28/06/2009 at 10:30 PM Tim McCarron wrote:

[quote]
That’s right,

My conditional is the keystroke, in other words if that keystroke occurs,
do
this (return true), else do that (return false).

Just a different way of using the if() function in CP

Post generated using Mail2Forum (mail2forum.com)

Yep, that’s what I meant - allow the CP interrogate the key command.
Essentially this is similar to a passive TA where you would listen for a
certain key before performing another key, but instead we have two path
options we can follow instead of just the one, true - do this, false - do
that.
To do that today we need 2 similar secondary triggers and rely on 2
different PME’s in the trait stack after the primary trigger, so the
sequence goes down the right path.

By “will future scripting allow…” I meant you had mentioned something
before about you would be able to insert/use the key command into future
scripting somehow - not exactly sure what you intended. There is nothing
currently. It was in a thread here somewhere or email, will have to dig it
up :slight_smile:

Post generated using Mail2Forum (mail2forum.com)

Hi Tim,

I don’t really see this as part of Calculated Property. I had envision this sort of thing more in stage 2 where you would fire off a ‘Script’ trait which would have a complete Java script in it that can do any sort of fancy stuff - Enquire on Control keys, fire off hot keys and key commands etc.

B.

*********** REPLY SEPARATOR ***********

On 28/06/2009 at 11:57 PM Tim McCarron wrote:

[quote]
Yep, that’s what I meant - allow the CP interrogate the key command.
Essentially this is similar to a passive TA where you would listen for a
certain key before performing another key, but instead we have two path
options we can follow instead of just the one, true - do this, false - do
that.
To do that today we need 2 similar secondary triggers and rely on 2
different PME’s in the trait stack after the primary trigger, so the
sequence goes down the right path.

By “will future scripting allow…” I meant you had mentioned something
before about you would be able to insert/use the key command into future
scripting somehow - not exactly sure what you intended. There is nothing
currently. It was in a thread here somewhere or email, will have to dig it
up :slight_smile:

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

I would combine “Loop?” and the termination condition. If it’s blank,
there’s no loop.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I like to spell things out clearly for newbs and hide clutter from them if possible.

Loop? would be a checkbox, if unchecked, then all the rest of the loop related fields will not be visible.

I’m thinking to cover all possibilities, we need option for either While or Until loops. (In newb speak - Check End Condition before or after loop).

What about including for loop type functionality with a Property name defined and start, stop and step values?

B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On Jun 29, 2009, at 1:43 AM, Brent Easton wrote:

Minor naming suggestion:

Use the word “repeat” instead of “loop”. I think that would be more
widely recognized by non-programmers.

Also, I’m a little bit confused by what is happening in the loop with
this suggestion:

Does that mean you fire a HotKey, then repeatedly do the "Trigger
action’, and then fire another HotKey?

This setup leaves me a bit confused about what exactly gets repeated
in the loop.

-Tom.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

*********** REPLY SEPARATOR ***********

Good idea

Yes, that is the idea. That the set of KeyStrokes in the ‘Perform these KeyStrokes’ will get repeatly run. The Hotkey before and after loop are additional keystrokes that will be performed prior and after running the loop section, even if the loop section does not run at all because the loop condition is not true.

I will need to play with the wording and layout to make sure it is clear. The references to ‘Hotkey’ should be to ‘KeyStrokes’ to keep things consistent.

How about this, immediately below the ‘Perform these Keystrokes’ section:

Repeatedly perform these Keystrokes? [checkbox, hides other repeat options when not checked[

Repeat KeyStrokes a specific number of times: [
Repeat KeyStrokes while property match is true: [ 3 types of loop to choose from ]
Repeat KeyStrokes until a property match is true: [

Perform this KeyStroke before repeating:
Perform this KeyStroke after repeating:

The while/until distinction will be a little unclear to non-programmers, but this can be explained in the reference manual. An Until loop is guaranteed to repeat the keystrokes at least once. A while loop may not repeat the keystrokes at all if the condition is already false.

I’d also like to get an index variable in there to make life easier. You can create this using the before/after keystroke and setting up a seperate Dynamic property, but it such a common requirement in a loop scenario that I think it should be included. How do you say ‘Loop Index Variable’ in non-programmer speak? The direct translation is a ‘Repeat counter Property’. How about:

Create a Property to count repeats? [Checkbox, hide next 3 options if unchecked]
Count Property Name:
Before repeating, set Count Property to: [integer]
At end of each repeat, Count Property by: [integer]

B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

My inclination would be to use accurate terminology, and accompany that
with an explanation of it in the docs.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)