# Idiot trying to move pieces with send to location

I am trying to make a golf mod. The idea is to have different zones for the holes labeled as zone1, zone2 etc. The player cards have a send to location and I’m trying to use Current zone +1 to advance them around the course but it’s not working. How SHOULD I be doing this?

If your zone names are literally “zone1”, “zone2”, etc., then you can use `{"zone" + Integer.parseInt(CurrentZone.replaceAll("[^0-9]", "") + 1)}` as the destination for the next zone. The `replaceAll()` function will remove everything that’s not a digit from the string, so “zone1” becomes just “1”, etc., and then `Integer.parseInt()` converts that to a number and then you can add 1 to it.
(Note that the first `+` is performing string concatenation, adding the final number to the end of the string “zone”, while the second `+` is just standard addition.)

Note: I haven’t tested this, but I’m fairly certain it works. If you need to be able to go back to hole 1 from hole 18, that makes things more complicated…

To wrap around to hole one use the expression

`````` {"zone" + (Integer.parseInt(CurrentZone.replaceAll("[^0-9]", "") % 18) + 1)}
``````

`x % y` means "x modulo y " and evaluates to the integer remainder after doing the whole number division `x / y`. Let `h` be the current hole as given by

``````Integer.parseInt(CurrentZone.replaceAll("[^0-9]", "")
``````

and `r = h % 18`, then for `h=1,...,17` we have `r=h` (remainder of dividing f.ex. 5 by 18 is 5). For `h=18` we get `r=0`. Since the next hole `n` is defined as `n=r+1` we will get that the next hole after `h=18` is `1`. Not too complicated

Yours,
Christian

1 Like

You could also give each Zone a Zone level Property and a number for that Property which corresponds to the Zone Number. For example, Zone1 could have the Property ZoneNumber, give it a value of 1 then to move to the next Zone you would have something like: “Zone” + (ZoneNumber + 1) which will evaluate as Zone2.

 You can download this sample to see it working.

Darren

My 2 cents. If it were me, I’d be inclined to store the hole number as an integer in its own global property. That would make the arithmetic (incrementing, setting directly, etc) straightforward. Then to go to a specific zone (or “hole”), it would be “zone” + currentHole.

But even then, what does the string “zone” add? Nothing. Why not simply name the zones “1”, “2”, etc?

1 Like

This is what I get with that “Bad Data in Module: Piece: Al Geiberger 1971 Trait: Send To Location - Next Hole - Ctrl+Z Source: Zone[{“zone”+Integer.parseInt(CurrentZone.replaceAll(”[^0-9]“, “”)+1)}]=zone11 Error: Zone not found. Turn on the Audit Trail preference to generate more details in the errorlog.”

Check the spelling - are zones named `Zone1`, …, `Zone18`, or `zone1`, …, `zone18`? Your expression must use the same spelling. Does `zone11` exist in you your module?

Yours,
Christian

Also property names are case sensitive like most passwords.

The spelling is correct. It took it as zone11 (which doesn’t exist yet while I test) instead of zone2.

Thanks I had the limits set to null initially so it took it as a string instead.