// TELEPORT v0.04 (c) 2014 NeatPortal.com
// This script will check if all your cities are in the specified state, and do nothing if they are.
// Otherwise it will prepare and teleport cities as needed.
// Once all cities are in the right state the script with close the bot (allowing for clean restart by the director).
//
// Usage example: To teleport all cities to Tuscany run bot with these custom command line parameters:
// -runscript Teleport.txt -teleport tuscany
if Config.teleport == null goto finish
state = Config.teleport.toUpperCase()
if state == GetZoneName(city.fieldId).toUpperCase() goto finish
config wartown:2,comfort:1
recallall
sleep 30
// sort by reachTime, descending
label checkArmies
army = city.selfArmies.toArray().sortOn("reachTime", 18)[0]
if army == null goto teleport
secondsLeft = ceil(TimeDiff(army.reachTime) / 1000) // time left in seconds, rounded up
if secondsLeft > 0 echo "Waiting for armies to return for " + secondsLeft + " seconds"
if secondsLeft > 0 execute "sleep " + secondsLeft
if city.selfArmies.length > 0 say "Still have armies"
if city.selfArmies.length > 0 goto checkArmies
label teleport
try = 0
say "Trying to teleport " + city.name + " to " + state
sleep 10
label tryteleport
try = try + 1
execute "teleport " + state
if !$error goto finalcheck
if try >= 5 goto giveup
say "Can't teleport " + city.name + " to " + state + ", will retry in 5 minutes"
sleep 5:00
goto tryteleport
label finalcheck
x = 0
label checkCities
if GetZoneName(cities[x].cityManager.fieldId).toUpperCase() != state goto continue
x = x + 1
if x < cities.length goto checkCities
say "All cities are now in " + state + ", will close in 10 seconds"
sleep 10
// assuming the director will restart the bot
exit
label giveup
say "Can't teleport " + city.name + " to " + state
label continue
loadgoals
label finish
Please enter your password of your account at the remote wiki below.
You should trust both wikis because the password could be read by the particular administrators.
Clear message

![[+]](/moin_static/explorer/img/toggle1.png)

![[-]](/moin_static/explorer/img/toggle0.png)
