• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "Unsorted"
    Differences between revisions 1 and 8 (spanning 7 versions)
    Revision 1 as of 2012-12-06 18:44:18
    Size: 11318
    Editor: Inanna
    Comment:
    Revision 8 as of 2014-06-11 18:36:07
    Size: 10678
    Editor: Inanna
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 1: Line 1:
    This is nothing fancy, just a big list of newly available objects and functions that are not yet documented in the wiki. The number at the start is the bot version it was added in. ## page was renamed from ObjectUnsorted
    This is nothing fancy, just a big list of newly available objects and functions that are not yet documented in the wiki. The number at the start is the bot version it was added in. Thanks to Dismayed for the changelog summary :)
    Line 14: Line 15:
    2676 6th parameter is whether to return array indexed by castle id (Yes) or zero-based (No) (default: No)
         Example:
    2676 list = CastlesInRectangle(123, 234, 156, 274, false, true) // include NPCs into results, and also use castle id as index
     6th parameter is whether to return array indexed by castle id (Yes) or zero-based (No) (default: No)

    Example:
     list = CastlesInRectangle(123, 234, 156, 274, false, true) // include NPCs into results, and also use castle id as index
    Line 18: Line 20:
    2676 castle = list[id] // this works because of 6th parameter in CastlesInRectangle() call set to true  castle = list[id] // this works because of 6th parameter in CastlesInRectangle() call set to true
    Line 20: Line 22:
    Line 21: Line 24:
     Example 1:
    Line 22: Line 26:
        Example 2:  
     
    Example 2:
    Line 25: Line 30:
    2670 Added support for city.x and city.y (returning x and y coordinates of the city)
    Added support for city.x and city.y (returning x and y coordinates of the city)
    Line 32: Line 38:
    2669 FindField(cx, cy, distance, fieldType, [fieldLevel]) - returns array of fields within specified distance from cx,cy  FindField(cx, cy, distance, fieldType, [fieldLevel]) - returns array of fields within specified distance from cx,cy
    Line 34: Line 40:
    2669 y = GetY(city.fieldId)  y = GetY(city.fieldId)
    Line 38: Line 44:
    2668 echo city.myArmies[0].resource // outputs human-readable string representing resources carried by first army
         Renamed getResources() to GetResources()
     echo city.myArmies[0].resource // outputs human-readable string representing resources carried by first army
        
    Renamed getResources() to GetResources()
    Line 46: Line 53:
    2651 colors = [ "green", "red", "yellow" ]  colors = [ "green", "red", "yellow" ]
    Line 48: Line 55:
    2651 echo colors[1] // outputs "red"  echo colors[1] // outputs "red"
    Line 50: Line 57:
    2651 str = colors[1] + " " + fruits[1]  str = colors[1] + " " + fruits[1]
    Line 52: Line 59:
    2651 Added support for object constructors (nested object constructors are fully supported)
    Added support for object constructors (nested object constructors are fully supported)
    Line 54: Line 62:
    2651 execute "whisper " + message.user + " " + message.text
         Added support for unary -, + and ! (not)
    2651 a = -2 < 3 // true
     execute "whisper " + message.user + " " + message.text

    Added support for unary -, + and ! (not)
     a = -2 < 3 // true
    Line 58: Line 67:
    2651 text = "some text"  text = "some text"
    Line 60: Line 69:
    2651 Added date() function
    Added date() function
    Line 62: Line 72:
    2651 echo d.toString() // outputs "Wed Oct 24 10:30:00 GMT-0400 2012"  echo d.toString() // outputs "Wed Oct 24 10:30:00 GMT-0400 2012"
    Line 64: Line 74:
    Line 65: Line 76:
    2650 TroopBeanToString, GetTroops, GetFortifications
    2650 Renamed "getFoodConsumeRate" to "foodConsumeRate" in troop bean
     TroopBeanToString, GetTroops, GetFortifications

    Renamed "getFoodConsumeRate" to "foodConsumeRate" in troop bean
    Line 68: Line 80:
    2650 mytroops = GetTroops("a:30k,b:40k,w:1,p:1,sw:1") // convert troop string to TroopBean object  mytroops = GetTroops("a:30k,b:40k,w:1,p:1,sw:1") // convert troop string to TroopBean object
    Line 70: Line 82:
    2650 echo "Error in troop string"  echo "Error in troop string"
    Line 72: Line 84:
    2650 echo "Food consumption of " + TroopBeanToString(mytroops, ",") + " is " + mytroops.foodConsumeRate + " per hour"  echo "Food consumption of " + TroopBeanToString(mytroops, ",") + " is " + mytroops.foodConsumeRate + " per hour"
    Line 74: Line 86:
    Line 75: Line 88:
         Added "coords" property support to field beans
    2644 field = city.fields[0]
         echo "Field 1 is " + field.name + ", coordinates are: " + FieldIdToCoords(field.id) // outputs something like "Field 1 is Forest, coordinates are: 123,456"
    2644 echo "Field 1 is " + field.name + ", coordinates are: " + GetX(field.id) + "," + GetY(field.id) // same output

    Added "coords" property support to field beans
     field = city.fields[0]
         echo "Field 1 is " + field.name + ", coordinates are: " + FieldIdToCoords(field.id) // outputs "Field 1 is Forest, coordinates are: 123,456"
     echo "Field 1 is " + field.name + ", coordinates are: " + GetX(field.id) + "," + GetY(field.id) // same output
    Line 80: Line 94:
    Line 82: Line 97:
    2643 - added MapDistance(x1, y1, x2, y2) function returning distance between (x1,y1) an (x2,y2) on the map
    2642

    - added MapDistance(x1, y1, x2, y2) function returning distance between (x1,y1) an (x2,y2) on the map
    Line 86: Line 102:
    2635 amount (optional, default = 1): desired amount of resource  amount (optional, default = 1): desired amount of resource
    Line 88: Line 104:
    2635 Method 0 ("now" - default) returns the price to buy or sell the specified amount of resources without waiting.  Method 0 ("now" - default) returns the price to buy or sell the specified amount of resources without waiting.
    Line 90: Line 106:
    2635 BuyPrice(resource) is same as m_context.buyPrice(resource)  BuyPrice(resource) is same as m_context.buyPrice(resource)
    Line 92: Line 108:
    Line 93: Line 110:
         Added support for "NaN" (special constant representing "not a number" value) and isNaN() function
    2634 a = NaN

    Added support for "NaN" (special constant representing "not a number" value) and isNaN() function
     a = NaN
    Line 96: Line 114:
    2634 echo isNaN(b) // outputs "true"
         Added support for "Infinity" (special constant representing infinitly large number) and isFinite() function
    2634 a = 0
     echo isNaN(b) // outputs "true"

    Added support for "Infinity" (special constant representing infinitly large number) and isFinite() function
     a = 0
    Line 100: Line 119:
    2634 echo isFinite(b) // outputs "false"  echo isFinite(b) // outputs "false"
    Line 102: Line 122:
         Example 1 (prints list of up to 10 enemies, unsorted):
    2631 enemies = SearchEnemyCastles(10)

    Example 1 (prints list of up to 10 enemies, unsorted):
     enemies = SearchEnemyCastles(10)
    Line 105: Line 126:
    2631 label loop1  label loop1
    Line 107: Line 128:
    2631 castle = enemies[i]  castle = enemies[i]
    Line 109: Line 130:
    2631 echo "Enemy " + i + ":" fieldIdToCompareString(castle.id) castle.name castle.userName castle.allianceName castle.prestige castle.honor  echo "Enemy " + i + ":" fieldIdToCompareString(castle.id) castle.name castle.userName castle.allianceName castle.prestige castle.honor
    Line 111: Line 132:
    2631 label exit
         Example 2 (prints info for a specific map coordinates, uses cached info, if available)
    2631 x = 123
     label exit

    Example 2 (prints info for a specific map coordinates, uses cached info, if available)
     x = 123
    Line 115: Line 137:
    2631 id = GetFieIdId(x,y)  id = GetFieldId(x,y)
    Line 117: Line 139:
    2631 castle = GetDetailInfo(id, true)  castle = GetDetailInfo(id, true)
    Line 119: Line 141:
    2631 echo "lord=" + castle.userName "alliance=" + castle.allianceName "R=" + castle.relation  echo "lord=" + castle.userName "alliance=" + castle.allianceName "R=" + castle.relation
    Line 121: Line 144:
         Added inline support for the following math functions:
    2630 abs(), acos(), asin(), atan(), atan2(), cos(), sin(), tan(),

    Added inline support for the following math functions:
     abs(), acos(), asin(), atan(), atan2(), cos(), sin(), tan(),
    Line 124: Line 148:
    2630 ceil(), floor(), round(), max(), min()  ceil(), floor(), round(), max(), min()
    Line 126: Line 150:
    2630 Added access to the following constants:
    Added access to the following constants:
    Line 128: Line 153:
    2630 LN2 (logarithm of 2), LN10 (logarithm of 10), LOG10E (base 10 ogarithm of E), LOG2E (base 2 logarithm of E)
         Added support for various resource-related functions and constants
    2630 res = RESOURCETYPE_WOOD
     LN2 (logarithm of 2), LN10 (logarithm of 10), LOG10E (base 10 ogarithm of E), LOG2E (base 2 logarithm of E)

    Added support for various resource-related functions and constants
     res = RESOURCETYPE_WOOD
    Line 132: Line 158:
    Line 134: Line 161:
    2629 Example 1: Simple math
    Example 1: Simple math
    Line 136: Line 164:
    2629 b = 3  b = 3
    Line 138: Line 166:
    2629 c = c + 1 // c is 6 now  c = c + 1 // c is 6 now
    Line 140: Line 168:
    2629 echo a b c d // outputs 2 3 6 25
         Example 2: String operations
    2629 text1 = "Hello"
     echo a b c d // outputs 2 3 6 25

    Example 2: String operations
     text1 = "Hello"
    Line 144: Line 173:
    2629 result = text1 + ", " + text2 + "!"  result = text1 + ", " + text2 + "!"
    Line 146: Line 175:
    2629 echo result // outputs "Hello, world!"  echo result // outputs "Hello, world!"
    Line 148: Line 177:
    2629 echo result.indexOf("o") // 4
         Example 3: References:
    2629 echo "List of heroes in " + m_city.cityManager.name + ":"
     echo result.indexOf("o") // 4

    Example 3: References:
     echo "List of heroes in " + m_city.cityManager.name + ":"
    Line 152: Line 182:
    2629 i = 0  i = 0
    Line 154: Line 184:
    2629 ifgoto i>=count done // note, round brackets are optional and spaces between operands are not required  ifgoto i>=count done // note, round brackets are optional and spaces between operands are not required
    Line 156: Line 186:
    2629 i = i + 1  i = i + 1
    Line 158: Line 188:
    2629 goto loop1  goto loop1
    Line 160: Line 190:
    2629 Example 4: Function references
    Example 4: Function references
    Line 162: Line 193:
    2629 res = 0  res = 0
    Line 164: Line 195:
    2629 echo "Current " + ResourceNames[res] + " price is " + ask(res)  echo "Current " + ResourceNames[res] + " price is " + ask(res)
    Line 166: Line 197:
    Line 168: Line 200:
         Added "end" command (terminates script)
    Added "end" command (terminates script)
    Line 171: Line 205:
    2607 m_context.hasBuff(XXX) // true if we have buff XXX applied  m_context.hasBuff(XXX) // true if we have buff XXX applied
    Line 173: Line 207:
    2607 m_city.cityManager.buff(XXX) // returns BuffBean object or null if buff XXX is not applied
         Example 1: Checking if city has buff applied
    2607 ifgoto ( m_city.cityManager.hasBuff(ForceopenclosegateBuff ) == true ) gatesforced
         Example 2: Accessing individual player (account) buff properties
    2607 print m_context.buff(StopTroopsUpkeepBuff).descName
     m_city.cityManager.buff(XXX) // returns BuffBean object or null if buff XXX is not applied

    Example 1: Checking if city has buff applied
     ifgoto ( m_city.cityManager.hasBuff(ForceopenclosegateBuff ) == true ) gatesforced

    Example 2: Accessing individual player (account) buff properties
     echo m_context.buff(StopTroopsUpkeepBuff).descName
    Line 179: Line 215:
    2607 m_context.truced // true if account is truced (including server merge truce)
    m_context.truced // true if account is truced (including server merge truce)
    Line 181: Line 218:
    Line 182: Line 220:
    Line 184: Line 223:
    2603 m_context.findFirstCity() // "main" city object  m_context.findFirstCity() // "main" city object
    Line 186: Line 225:
    2603 m_city.cityManager.comfortingNeeds(1).needAmount // amount of food needed to do disaster relief  m_city.cityManager.comfortingNeeds(1).needAmount // amount of food needed to do disaster relief
    Line 188: Line 227:
    Line 190: Line 230:
    Line 193: Line 234:
    2561 Dropped round brackets and renamed
         m_city.cityManager.enemyArmies[x].startFieldCoords => m_city.cityManager.enemyArmies[x].startCoords
    2561 m_city.cityManager.enemyArmies[x].targetFieldCoords => m_city.cityManager.enemyArmies[x].targetCoords
         m_city.cityManager.cityCoords => m_city.cityManager.coords
    2557 m_city.cityManager.enemyArmies[x].startFieldCoords
         m_city.cityManager.enemyArmies[x].targetFieldCoords
    2557 m_city.cityManager.cityCoords

    This is nothing fancy, just a big list of newly available objects and functions that are not yet documented in the wiki. The number at the start is the bot version it was added in. Thanks to Dismayed for the changelog summary :)

    2698    Added "isAvailable" to HeroBean object (returns true if hero is not busy and either mayor or idle)
    
    2695    Eliminated MapCastles(x,y,r) [use more flexible CastleInRectangle(x1,y1,x2,y2) instead]
    
    2693    Renamed updateDetailInfo() to UpdateDetailInfo()
    
    2683    Renamed stateName() to StateName() (the function converts numeric castle's "state" property to name)
    
    2676    Added 2 additional (optional) boolean parameters to CastlesInRectangle():
            5th parameter is whether to omit NPCs from results (default: Yes)
            6th parameter is whether to return array indexed by castle id (Yes) or zero-based (No) (default: No)
    
            Example:
            list = CastlesInRectangle(123, 234, 156, 274, false, true) // include NPCs into results, and also use castle id as index
            id = GetFieldId(142, 255)
            castle = list[id] // this works because of 6th parameter in CastlesInRectangle() call set to true
            ifgosub castle found // same as "ifgosub castle != null found"
    
    2670    Added ResetMap function allowing to clear cached map data (used by rescanmap/rescanrec):
            Example 1:
            a = ResetMap(x,y,radius)       // resets circular area with center at x,y
            
            Example 2:
            a = ResetMap(x,y,width,height) // resets rectangular area with start at x,y
            In both examples, "a" is dummy variable (will be assigned null).2670    
    
            Added support for city.x and city.y (returning x and y coordinates of the city)
            Example: 
            x = GetX(city.fieldId) // x-coordinate of the city
            x = city.x // simpler way to do the same
    
    2669    GetFieldType(str) - converts valley name to type
            GetFieldName(integer) - converts valley type to name
            FindField(cx, cy, distance, fieldType, [fieldLevel]) - returns array of fields within specified distance from cx,cy
            x = GetX(city.fieldId)
            y = GetY(city.fieldId)
    
    2668    Resource objects can now be auto-converted to string as needed
            For example:
            echo city.myArmies[0].resource // outputs human-readable string representing resources carried by first army
        
            Renamed getResources() to GetResources()
    
    2662    Added support for haunted castle items and increased army sizes (to be further refined)
            Reserved resources now include amount needed to do 1-time comforting if city has non-zero grievance
    
    2651    Added support for array constructors (nested arrays constructors are fully supported)
            Example:
            colors = [ "green", "red", "yellow" ]
            fruits = [ "pear", "apple", "banana" ]
            echo colors[1] // outputs "red"
            echo fruits[0] // outputs "pear"
            str = colors[1] + " " + fruits[1]
            echo "I like " + str + "s" // outputs "I like red apples"
    
            Added support for object constructors (nested object constructors are fully supported)
            message = { user:"bucks", text:"What's wrong with you?" }
            execute "whisper " + message.user + " " + message.text
    
            Added support for unary -, + and ! (not)
            a = -2 < 3 // true
            b = !a // false
            text = "some text"
            xx = !text // false
    
            Added date() function
            d = date(2012, 9, 24, 10, 30) // note, months are counted from 0,output below is for EST time zone
            echo d.toString() // outputs "Wed Oct 24 10:30:00 GMT-0400 2012"
            echo d.toUTCString() // outputs "Wed Oct 24 14:30:00 2012 UTC"
    
    2650    Changed first letter to capital in the following functions
            TroopBeanToString, GetTroops, GetFortifications
    
            Renamed "getFoodConsumeRate" to "foodConsumeRate" in troop bean
            Example: Find food consumtpion for a specified troop string
            mytroops = GetTroops("a:30k,b:40k,w:1,p:1,sw:1") // convert troop string to TroopBean object
            ifgoto mytroops continue
            echo "Error in troop string"
            end
            echo "Food consumption of " + TroopBeanToString(mytroops, ",") + " is " + mytroops.foodConsumeRate + " per hour"
            echo "Food consumption per 1 minute is " + mytroops.foodConsumption(60)
    
    2644    Renamed FieldIdToCompareString() to FieldIdToCoords()
    
            Added "coords" property support to field beans
            field = city.fields[0]
            echo "Field 1 is " + field.name + ", coordinates are: " + FieldIdToCoords(field.id) // outputs "Field 1 is Forest, coordinates are: 123,456"
            echo "Field 1 is " + field.name + ", coordinates are: " + GetX(field.id) + "," + GetY(field.id) // same output
            echo "Field 1 is " + field.name + ", coordinates are: " + field.coords // same output
    
    2643    - these functions (all use field id as parameter) renamed to start with upper-case letter:
            GetLevel, GetType, GetZoneName, GetX, GetY
    
            - added MapDistance(x1, y1, x2, y2) function returning distance between (x1,y1) an (x2,y2) on the map
    
    2635    New BuyPrice() and SellPrice() functions use up to 3 parameters: resource, amount, method
            resource (required): 0 - food, 1 - wood, 2 - stone, 3 - iron
            amount (optional, default = 1): desired amount of resource
            method (optional, default = 0): 0 - "now", 1 - "average" (see explanation below)
            Method 0 ("now" - default) returns the price to buy or sell the specified amount of resources without waiting.
            Method 1 ("average") returns average price needed to buy or sell the specified amount of resources
            BuyPrice(resource) is same as m_context.buyPrice(resource)
            SellPrice(resource) is same as m_context.sellPrice(resource)
    
    2634    Added "return" (same as "gosubreturn")
    
            Added support for "NaN" (special constant representing "not a number" value) and isNaN() function
            a = NaN
            b = a + 2
            echo isNaN(b) // outputs "true"
    
            Added support for "Infinity" (special constant representing infinitly large number) and isFinite() function
            a = 0
            b = 2 / a // division by zero!
            echo isFinite(b) // outputs "false"
    
    2631    Added support for various map-related functions in expressions (function availability and exact names/parameters are subject to change!)
    
            Example 1 (prints list of up to 10 enemies, unsorted):
            enemies = SearchEnemyCastles(10)
            i = 0
            label loop1
            ifgoto i >= enemies.length exit
            castle = enemies[i]
            i = i + 1
            echo "Enemy " + i + ":" fieldIdToCompareString(castle.id) castle.name castle.userName castle.allianceName castle.prestige castle.honor
            goto loop1
            label exit
    
            Example 2 (prints info for a specific map coordinates, uses cached info, if available)
            x = 123
            y = 456
            id = GetFieldId(x,y)
            label notyet
            castle = GetDetailInfo(id, true)
            ifgoto castle == null notyet
            echo "lord=" + castle.userName "alliance=" + castle.allianceName "R=" + castle.relation
    
    2630    Added support for "<>" operator (same as "!=") in expressions
    
            Added inline support for the following math functions:
            abs(), acos(), asin(), atan(), atan2(), cos(), sin(), tan(),
            exp(), pow(), log(),
            ceil(), floor(), round(), max(), min()
            random(), sqrt()
    
            Added access to the following constants:
            PI, E, SQRT1_2 (square root of 2 divided by 2), SQRT2 (square root of 2)
            LN2 (logarithm of 2), LN10 (logarithm of 10), LOG10E (base 10 ogarithm of E), LOG2E (base 2 logarithm of E)
    
            Added support for various resource-related functions and constants
            res = RESOURCETYPE_WOOD
            echo "Resource type " + res + " is for " + ResourceNames[res]
    
    2629    Variables can hold value of any time (number, string, array/function/oibject reference)
            Expressions are supported in ifgoto/ifgosub
    
            Example 1: Simple math
            a = 2
            b = 3
            c = a + b // c is 5 now
            c = c + 1 // c is 6 now
            d = (a + b) (c - 1)
            echo a b c d // outputs 2 3 6 25
    
            Example 2: String operations
            text1 = "Hello"
            text2 = "world"
            result = text1 + ", " + text2 + "!"
            len = result.length
            echo result // outputs "Hello, world!"
            echo len // 13
            echo result.indexOf("o") // 4
    
            Example 3: References:
            echo "List of heroes in " + m_city.cityManager.name + ":"
            heroes = m_city.cityManager.heroes
            i = 0
            count = heroes.length
            ifgoto i>=count done // note, round brackets are optional and spaces between operands are not required
            label loop1
            i = i + 1
            echo i + ". " + heroes[i].name
            goto loop1
            label done
    
            Example 4: Function references
            ask = m_context.buyPrice // note, buyPrice is a function!
            res = 0
            label resloop
            echo "Current " + ResourceNames[res] + " price is " + ask(res)
            res = res + 1
    
            Added "execute" command allowing to run arbitrary command with custom parameters, e.g.
            execute "buy food " + amount + " " + price // buy 5m food @ 22.5
    
            Added "end" command (terminates script)
    
    2607    Allow to check city/player (account) buffs from scripts:
            m_city.cityManager.hasBuff(XXX) // true if city has buff XXX applied
            m_context.hasBuff(XXX) // true if we have buff XXX applied
            m_context.buff(XXX) // returns BuffBean object or null if buff XXX is not applied
            m_city.cityManager.buff(XXX) // returns BuffBean object or null if buff XXX is not applied
    
            Example 1: Checking if city has buff applied
            ifgoto ( m_city.cityManager.hasBuff(ForceopenclosegateBuff ) == true ) gatesforced
    
            Example 2: Accessing individual player (account) buff properties
            echo m_context.buff(StopTroopsUpkeepBuff).descName
            // the above would print "No food for your troops will be consumed under this status." if buff is applied
    
            m_context.truced // true if account is truced (including server merge truce)
            m_context.inTruceCooldown // true if account is in truce cooldown
    
    2606    Recognize "null" as valid value in scripts
    
    2603    m_context.marketReady() // set to false after (re)login, becomes true after market prices for all 4 resources are refreshed
            m_context.marketReady() // set to false after (re)login, becomes true after market prices for all 4 resources are refreshed
            m_context.findFirstCity() // "main" city object
            New functions (not all possible parameters are shown):
            m_city.cityManager.comfortingNeeds(1).needAmount // amount of food needed to do disaster relief
            m_city.cityManager.comfortingNeeds(2).needAmount // amount of food needed to do praying
    
    2600    Added disaster relief/praying factor access via scripts (m_city.cityManager.PRFactor)
            Added display of food amount needed for disaster relief/praying and current PR factor
    
    2595    IsHeroInCastle() now supports hero-strings
            ifgoto ( m_city.IsHeroInCastle(any:att>200) == true ) found
            Added "is_researching" (returns true if there is a research going on)


    ScriptObjects

    Unsorted (last edited 2014-06-11 18:36:07 by Inanna)