[{"data":1,"prerenderedAt":3133},["ShallowReactive",2],{"guide-mod-scripts":3},{"data":4,"body":5,"toc":3113},{},{"type":6,"children":7},"root",[8,62,69,167,173,372,378,399,446,534,580,616,625,630,941,947,958,1017,1022,1230,1235,1247,1270,1289,1295,1300,1661,1825,1831,1836,2105,2293,2299,2304,2404,2410,2415,2487,2493,2503,2546,2721,2727,2739,2748,2760,2771,2790,2796,2801],{"type":9,"tag":10,"props":11,"children":12},"element","p",{},[13,16,28,30,36,38,43,45,50,52,60],{"type":14,"value":15},"text","A mod's boss can be driven by a short Lua script. The boss kit (",{"type":9,"tag":17,"props":18,"children":20},"a",{"href":19},"\u002Fguides\u002Fcontent-reference",[21],{"type":9,"tag":22,"props":23,"children":25},"code",{"className":24},[],[26],{"type":14,"value":27},"docs\u002FHOWTO-CONTENT.md",{"type":14,"value":29},", \"A boss\nkit\") says ",{"type":9,"tag":31,"props":32,"children":33},"em",{},[34],{"type":14,"value":35},"which",{"type":14,"value":37}," abilities a boss uses and ",{"type":9,"tag":31,"props":39,"children":40},{},[41],{"type":14,"value":42},"how often",{"type":14,"value":44},"; a script says ",{"type":9,"tag":31,"props":46,"children":47},{},[48],{"type":14,"value":49},"which one, and when",{"type":14,"value":51},",\nby reading how the fight stands. This guide is the whole API. The data words that name a script\nare in ",{"type":9,"tag":17,"props":53,"children":54},{"href":19},[55],{"type":9,"tag":22,"props":56,"children":58},{"className":57},[],[59],{"type":14,"value":27},{"type":14,"value":61},", \"A scripted ability\"; what a script may return are the abilities\nof that file, so read \"A boss kit\" first.",{"type":9,"tag":63,"props":64,"children":66},"h2",{"id":65},"what-a-script-is-and-where-it-runs",[67],{"type":14,"value":68},"What a script is, and where it runs",{"type":9,"tag":70,"props":71,"children":72},"ul",{},[73,109,128,152],{"type":9,"tag":74,"props":75,"children":76},"li",{},[77,79,85,87,93,95,100,102,107],{"type":14,"value":78},"A script is Lua 5.1 in a sandbox. It cannot reach your files, the network, the clock or the\ngame: it gets a ",{"type":9,"tag":22,"props":80,"children":82},{"className":81},[],[83],{"type":14,"value":84},"ctx",{"type":14,"value":86}," of plain numbers, a ",{"type":9,"tag":22,"props":88,"children":90},{"className":89},[],[91],{"type":14,"value":92},"state",{"type":14,"value":94}," of plain data it kept from its last call, and\nit returns ",{"type":9,"tag":31,"props":96,"children":97},{},[98],{"type":14,"value":99},"commands",{"type":14,"value":101}," (abilities to play, lines to yell) and the ",{"type":9,"tag":22,"props":103,"children":105},{"className":104},[],[106],{"type":14,"value":92},{"type":14,"value":108}," to keep.",{"type":9,"tag":74,"props":110,"children":111},{},[112,118,120,126],{"type":9,"tag":113,"props":114,"children":115},"strong",{},[116],{"type":14,"value":117},"Only the host runs it, and only in the native game.",{"type":14,"value":119}," In co-op the host's game plays the\nbosses; a guest sees what it is sent and never runs a script. The browser build has no scripts:\nit refuses a scripted mod before anything starts (the capability ",{"type":9,"tag":22,"props":121,"children":123},{"className":122},[],[124],{"type":14,"value":125},"scripts-v1",{"type":14,"value":127},", below).",{"type":9,"tag":74,"props":129,"children":130},{},[131,136,138,143,145,150],{"type":9,"tag":113,"props":132,"children":133},{},[134],{"type":14,"value":135},"No official pack has scripts.",{"type":14,"value":137}," A scripted mod is ",{"type":9,"tag":113,"props":139,"children":140},{},[141],{"type":14,"value":142},"Modded",{"type":14,"value":144}," like every mod: heroes and\nprogress of its own, no cloud saves, no ranks, co-op only on exactly the same lock. The Mods\nwindow marks it with a ",{"type":9,"tag":113,"props":146,"children":147},{},[148],{"type":14,"value":149},"Scripts",{"type":14,"value":151}," badge and asks a second time before it is chosen.",{"type":9,"tag":74,"props":153,"children":154},{},[155,157,165],{"type":14,"value":156},"A script runs on the player's computer, so a package with scripts is reviewed as source (see\n\"Publishing a mod\" in ",{"type":9,"tag":17,"props":158,"children":159},{"href":19},[160],{"type":9,"tag":22,"props":161,"children":163},{"className":162},[],[164],{"type":14,"value":27},{"type":14,"value":166},").",{"type":9,"tag":63,"props":168,"children":170},{"id":169},"the-files",[171],{"type":14,"value":172},"The files",{"type":9,"tag":70,"props":174,"children":175},{},[176,213,241,302,336,346],{"type":9,"tag":74,"props":177,"children":178},{},[179,181,187,189,195,197,203,205,211],{"type":14,"value":180},"A script is the file ",{"type":9,"tag":22,"props":182,"children":184},{"className":183},[],[185],{"type":14,"value":186},"packs\u002F\u003Cpackage id>\u002Fscripts\u002F\u003Cname>.lua",{"type":14,"value":188}," of your package, a locked object\nof the kind ",{"type":9,"tag":22,"props":190,"children":192},{"className":191},[],[193],{"type":14,"value":194},"script",{"type":14,"value":196},". The name is lower case letters, digits, ",{"type":9,"tag":22,"props":198,"children":200},{"className":199},[],[201],{"type":14,"value":202},"_",{"type":14,"value":204}," and ",{"type":9,"tag":22,"props":206,"children":208},{"className":207},[],[209],{"type":14,"value":210},"-",{"type":14,"value":212},". UTF-8, no NUL byte (a\nbyte order mark is dropped). At most 64 KiB a file, 16 files a package, 1 MiB of scripts a\nprofile.",{"type":9,"tag":74,"props":214,"children":215},{},[216,218,223,225,231,233,239],{"type":14,"value":217},"A profile with a script requires the capability ",{"type":9,"tag":22,"props":219,"children":221},{"className":220},[],[222],{"type":14,"value":125},{"type":14,"value":224}," in ",{"type":9,"tag":22,"props":226,"children":228},{"className":227},[],[229],{"type":14,"value":230},"profile.json",{"type":14,"value":232},"\n(",{"type":9,"tag":22,"props":234,"children":236},{"className":235},[],[237],{"type":14,"value":238},"azs-release profile-lock",{"type":14,"value":240}," writes it). A game without it refuses the import and says why.",{"type":9,"tag":74,"props":242,"children":243},{},[244,249,251,264,268,270,276,278,284,286,292,294,300],{"type":9,"tag":113,"props":245,"children":246},{},[247],{"type":14,"value":248},"A boss kit names a script",{"type":14,"value":250},":",{"type":9,"tag":252,"props":253,"children":259},"pre",{"className":254,"code":256,"language":257,"meta":258},[255],"language-toml","[[boss.kit]]\nevery = 8.0\nability = { script = { name = \"slam\", params = { reach = 4.0 } } }\n","toml","",[260],{"type":9,"tag":22,"props":261,"children":262},{"__ignoreMap":258},[263],{"type":14,"value":256},{"type":9,"tag":265,"props":266,"children":267},"br",{},[],{"type":14,"value":269},"When the entry comes due (",{"type":9,"tag":22,"props":271,"children":273},{"className":272},[],[274],{"type":14,"value":275},"every",{"type":14,"value":277},") the script's ",{"type":9,"tag":22,"props":279,"children":281},{"className":280},[],[282],{"type":14,"value":283},"fire",{"type":14,"value":285}," hook runs. ",{"type":9,"tag":22,"props":287,"children":289},{"className":288},[],[290],{"type":14,"value":291},"params",{"type":14,"value":293}," (at most 16, finite\nnumbers) are numbers your script reads as ",{"type":9,"tag":22,"props":295,"children":297},{"className":296},[],[298],{"type":14,"value":299},"ctx.params.reach",{"type":14,"value":301},". Several entries may name one\nscript with different params.",{"type":9,"tag":74,"props":303,"children":304},{},[305,310,312,318,320,326,328,334],{"type":9,"tag":113,"props":306,"children":307},{},[308],{"type":14,"value":309},"A phase names a script",{"type":14,"value":311}," with ",{"type":9,"tag":22,"props":313,"children":315},{"className":314},[],[316],{"type":14,"value":317},"script = \"\u003Cname>\"",{"type":14,"value":319}," on a ",{"type":9,"tag":22,"props":321,"children":323},{"className":322},[],[324],{"type":14,"value":325},"[[boss.phase]]",{"type":14,"value":327},": its ",{"type":9,"tag":22,"props":329,"children":331},{"className":330},[],[332],{"type":14,"value":333},"phase",{"type":14,"value":335}," hook runs\nas the boss takes that phase up.",{"type":9,"tag":74,"props":337,"children":338},{},[339,344],{"type":9,"tag":113,"props":340,"children":341},{},[342],{"type":14,"value":343},"Where a name resolves.",{"type":14,"value":345}," In the pack that defines the boss kit file, never in another pack.\nA script is no step of a combo, and an elite's kit (a zone's lair guardian) cannot call one:\nthe import refuses it, naming the elite and the script.",{"type":9,"tag":74,"props":347,"children":348},{},[349,354,356,362,364,370],{"type":9,"tag":113,"props":350,"children":351},{},[352],{"type":14,"value":353},"Yells.",{"type":14,"value":355}," A script may have the boss say a line of its kit file's ",{"type":9,"tag":22,"props":357,"children":359},{"className":358},[],[360],{"type":14,"value":361},"[boss.yells.\u003Cid>]",{"type":14,"value":363},", a text\nin all twelve languages like a phase's ",{"type":9,"tag":22,"props":365,"children":367},{"className":366},[],[368],{"type":14,"value":369},"yell",{"type":14,"value":371},". A script cannot make up a line.",{"type":9,"tag":63,"props":373,"children":375},{"id":374},"the-hooks",[376],{"type":14,"value":377},"The hooks",{"type":9,"tag":10,"props":379,"children":380},{},[381,383,389,391,397],{"type":14,"value":382},"A script defines up to three global functions at its top level. Each is called as\n",{"type":9,"tag":22,"props":384,"children":386},{"className":385},[],[387],{"type":14,"value":388},"hook(ctx, state)",{"type":14,"value":390}," and may return ",{"type":9,"tag":22,"props":392,"children":394},{"className":393},[],[395],{"type":14,"value":396},"commands, state",{"type":14,"value":398},".",{"type":9,"tag":10,"props":400,"children":401},{},[402,407,409,414,416,422,424,429,431,437,439,445],{"type":9,"tag":22,"props":403,"children":405},{"className":404},[],[406],{"type":14,"value":92},{"type":14,"value":408}," is always a table: empty at a boss's first call, after that a copy of the state kept last.\nA ",{"type":9,"tag":22,"props":410,"children":412},{"className":411},[],[413],{"type":14,"value":333},{"type":14,"value":415}," or ",{"type":9,"tag":22,"props":417,"children":419},{"className":418},[],[420],{"type":14,"value":421},"death",{"type":14,"value":423}," can come before any ",{"type":9,"tag":22,"props":425,"children":427},{"className":426},[],[428],{"type":14,"value":283},{"type":14,"value":430}," (a boss can fall in one blow), and the check calls\nevery hook with an empty state too, so a hook must not count on a field another hook sets: write\n",{"type":9,"tag":22,"props":432,"children":434},{"className":433},[],[435],{"type":14,"value":436},"(state.casts or 0)",{"type":14,"value":438},", never ",{"type":9,"tag":22,"props":440,"children":442},{"className":441},[],[443],{"type":14,"value":444},"state.casts + 1",{"type":14,"value":398},{"type":9,"tag":70,"props":447,"children":448},{},[449,475,501],{"type":9,"tag":74,"props":450,"children":451},{},[452,458,460,466,468,474],{"type":9,"tag":22,"props":453,"children":455},{"className":454},[],[456],{"type":14,"value":457},"fire(ctx, state)",{"type":14,"value":459},": a kit entry that names the script comes due. ",{"type":9,"tag":22,"props":461,"children":463},{"className":462},[],[464],{"type":14,"value":465},"ctx.event",{"type":14,"value":467}," is ",{"type":9,"tag":22,"props":469,"children":471},{"className":470},[],[472],{"type":14,"value":473},"nil",{"type":14,"value":398},{"type":9,"tag":74,"props":476,"children":477},{},[478,484,486,491,493,499],{"type":9,"tag":22,"props":479,"children":481},{"className":480},[],[482],{"type":14,"value":483},"phase(ctx, state)",{"type":14,"value":485},": a phase that names the script begins. ",{"type":9,"tag":22,"props":487,"children":489},{"className":488},[],[490],{"type":14,"value":465},{"type":14,"value":492}," is the phase number as\ntext: ",{"type":9,"tag":22,"props":494,"children":496},{"className":495},[],[497],{"type":14,"value":498},"\"1\"",{"type":14,"value":500}," for the first phase after the opening one.",{"type":9,"tag":74,"props":502,"children":503},{},[504,510,512,517,518,524,526,532],{"type":9,"tag":22,"props":505,"children":507},{"className":506},[],[508],{"type":14,"value":509},"death(ctx, state)",{"type":14,"value":511},": the boss falls; called once for every script its kit and phases name, in\nname order, after which the boss's state is forgotten. ",{"type":9,"tag":22,"props":513,"children":515},{"className":514},[],[516],{"type":14,"value":465},{"type":14,"value":467},{"type":9,"tag":22,"props":519,"children":521},{"className":520},[],[522],{"type":14,"value":523},"\"death\"",{"type":14,"value":525},". It may return\n",{"type":9,"tag":22,"props":527,"children":529},{"className":528},[],[530],{"type":14,"value":531},"say",{"type":14,"value":533}," commands only.",{"type":9,"tag":10,"props":535,"children":536},{},[537,539,544,545,550,552,557,559,564,566,571,573,578],{"type":14,"value":538},"A ",{"type":9,"tag":22,"props":540,"children":542},{"className":541},[],[543],{"type":14,"value":333},{"type":14,"value":415},{"type":9,"tag":22,"props":546,"children":548},{"className":547},[],[549],{"type":14,"value":421},{"type":14,"value":551}," hook the script does not define is not called. A ",{"type":9,"tag":22,"props":553,"children":555},{"className":554},[],[556],{"type":14,"value":283},{"type":14,"value":558}," hook it does not\ndefine is an error each time (see \"Errors\"). When several hooks are due in one step they run\nsorted by boss, a boss's ",{"type":9,"tag":22,"props":560,"children":562},{"className":561},[],[563],{"type":14,"value":333},{"type":14,"value":565}," before its ",{"type":9,"tag":22,"props":567,"children":569},{"className":568},[],[570],{"type":14,"value":283},{"type":14,"value":572},", ",{"type":9,"tag":22,"props":574,"children":576},{"className":575},[],[577],{"type":14,"value":283},{"type":14,"value":579}," in kit order.",{"type":9,"tag":10,"props":581,"children":582},{},[583,585,591,593,599,601,606,608,614],{"type":14,"value":584},"The top level of the file runs afresh before every call, in a new environment: a ",{"type":9,"tag":22,"props":586,"children":588},{"className":587},[],[589],{"type":14,"value":590},"local",{"type":14,"value":592}," there\n(like ",{"type":9,"tag":22,"props":594,"children":596},{"className":595},[],[597],{"type":14,"value":598},"nova",{"type":14,"value":600}," in the example) is rebuilt each time and keeps nothing. What lasts between calls is\nthe ",{"type":9,"tag":22,"props":602,"children":604},{"className":603},[],[605],{"type":14,"value":92},{"type":14,"value":607},", and nothing else. Assigning a global from inside a hook is an error\n(",{"type":9,"tag":22,"props":609,"children":611},{"className":610},[],[612],{"type":14,"value":613},"a script cannot set the global 'x'",{"type":14,"value":615},"): keep what lasts in the state.",{"type":9,"tag":617,"props":618,"children":619},"h3",{"id":84},[620],{"type":9,"tag":22,"props":621,"children":623},{"className":622},[],[624],{"type":14,"value":84},{"type":9,"tag":10,"props":626,"children":627},{},[628],{"type":14,"value":629},"Plain numbers, a fresh table at every call:",{"type":9,"tag":631,"props":632,"children":633},"table",{},[634,653],{"type":9,"tag":635,"props":636,"children":637},"thead",{},[638],{"type":9,"tag":639,"props":640,"children":641},"tr",{},[642,648],{"type":9,"tag":643,"props":644,"children":645},"th",{},[646],{"type":14,"value":647},"Field",{"type":9,"tag":643,"props":649,"children":650},{},[651],{"type":14,"value":652},"Meaning",{"type":9,"tag":654,"props":655,"children":656},"tbody",{},[657,675,692,709,726,757,774,791,835,872,917],{"type":9,"tag":639,"props":658,"children":659},{},[660,670],{"type":9,"tag":661,"props":662,"children":663},"td",{},[664],{"type":9,"tag":22,"props":665,"children":667},{"className":666},[],[668],{"type":14,"value":669},"ctx.time",{"type":9,"tag":661,"props":671,"children":672},{},[673],{"type":14,"value":674},"the run's clock, in seconds",{"type":9,"tag":639,"props":676,"children":677},{},[678,687],{"type":9,"tag":661,"props":679,"children":680},{},[681],{"type":9,"tag":22,"props":682,"children":684},{"className":683},[],[685],{"type":14,"value":686},"ctx.tier",{"type":9,"tag":661,"props":688,"children":689},{},[690],{"type":14,"value":691},"the difficulty tier, from 0",{"type":9,"tag":639,"props":693,"children":694},{},[695,704],{"type":9,"tag":661,"props":696,"children":697},{},[698],{"type":9,"tag":22,"props":699,"children":701},{"className":700},[],[702],{"type":14,"value":703},"ctx.boss.hp_share",{"type":9,"tag":661,"props":705,"children":706},{},[707],{"type":14,"value":708},"the boss's health, 0 to 1",{"type":9,"tag":639,"props":710,"children":711},{},[712,721],{"type":9,"tag":661,"props":713,"children":714},{},[715],{"type":9,"tag":22,"props":716,"children":718},{"className":717},[],[719],{"type":14,"value":720},"ctx.boss.phase",{"type":9,"tag":661,"props":722,"children":723},{},[724],{"type":14,"value":725},"the boss's phase, 0 in the opening one",{"type":9,"tag":639,"props":727,"children":728},{},[729,752],{"type":9,"tag":661,"props":730,"children":731},{},[732,738,739,745,746],{"type":9,"tag":22,"props":733,"children":735},{"className":734},[],[736],{"type":14,"value":737},"ctx.boss.x",{"type":14,"value":572},{"type":9,"tag":22,"props":740,"children":742},{"className":741},[],[743],{"type":14,"value":744},"y",{"type":14,"value":572},{"type":9,"tag":22,"props":747,"children":749},{"className":748},[],[750],{"type":14,"value":751},"z",{"type":9,"tag":661,"props":753,"children":754},{},[755],{"type":14,"value":756},"where the boss stands",{"type":9,"tag":639,"props":758,"children":759},{},[760,769],{"type":9,"tag":661,"props":761,"children":762},{},[763],{"type":9,"tag":22,"props":764,"children":766},{"className":765},[],[767],{"type":14,"value":768},"ctx.boss.facing",{"type":9,"tag":661,"props":770,"children":771},{},[772],{"type":14,"value":773},"the direction from the boss to its nearest hero, in radians",{"type":9,"tag":639,"props":775,"children":776},{},[777,786],{"type":9,"tag":661,"props":778,"children":779},{},[780],{"type":9,"tag":22,"props":781,"children":783},{"className":782},[],[784],{"type":14,"value":785},"ctx.boss.adds_alive",{"type":9,"tag":661,"props":787,"children":788},{},[789],{"type":14,"value":790},"how many ordinary enemies are alive",{"type":9,"tag":639,"props":792,"children":793},{},[794,803],{"type":9,"tag":661,"props":795,"children":796},{},[797],{"type":9,"tag":22,"props":798,"children":800},{"className":799},[],[801],{"type":14,"value":802},"ctx.heroes[i]",{"type":9,"tag":661,"props":804,"children":805},{},[806,808,814,815,820,821,827,829],{"type":14,"value":807},"up to five heroes that are in the fight, in seat order: ",{"type":9,"tag":22,"props":809,"children":811},{"className":810},[],[812],{"type":14,"value":813},"x",{"type":14,"value":572},{"type":9,"tag":22,"props":816,"children":818},{"className":817},[],[819],{"type":14,"value":744},{"type":14,"value":572},{"type":9,"tag":22,"props":822,"children":824},{"className":823},[],[825],{"type":14,"value":826},"hp_share",{"type":14,"value":828},". The list can be empty: look before you read ",{"type":9,"tag":22,"props":830,"children":832},{"className":831},[],[833],{"type":14,"value":834},"ctx.heroes[1]",{"type":9,"tag":639,"props":836,"children":837},{},[838,847],{"type":9,"tag":661,"props":839,"children":840},{},[841],{"type":9,"tag":22,"props":842,"children":844},{"className":843},[],[845],{"type":14,"value":846},"ctx.params",{"type":9,"tag":661,"props":848,"children":849},{},[850,852,857,859,864,865,870],{"type":14,"value":851},"the ",{"type":9,"tag":22,"props":853,"children":855},{"className":854},[],[856],{"type":14,"value":291},{"type":14,"value":858}," of the kit entry that named the script (empty for ",{"type":9,"tag":22,"props":860,"children":862},{"className":861},[],[863],{"type":14,"value":333},{"type":14,"value":204},{"type":9,"tag":22,"props":866,"children":868},{"className":867},[],[869],{"type":14,"value":421},{"type":14,"value":871},")",{"type":9,"tag":639,"props":873,"children":874},{},[875,883],{"type":9,"tag":661,"props":876,"children":877},{},[878],{"type":9,"tag":22,"props":879,"children":881},{"className":880},[],[882],{"type":14,"value":465},{"type":9,"tag":661,"props":884,"children":885},{},[886,891,893,898,900,905,906,911,912],{"type":9,"tag":22,"props":887,"children":889},{"className":888},[],[890],{"type":14,"value":473},{"type":14,"value":892}," for ",{"type":9,"tag":22,"props":894,"children":896},{"className":895},[],[897],{"type":14,"value":283},{"type":14,"value":899},", the phase number as text for ",{"type":9,"tag":22,"props":901,"children":903},{"className":902},[],[904],{"type":14,"value":333},{"type":14,"value":572},{"type":9,"tag":22,"props":907,"children":909},{"className":908},[],[910],{"type":14,"value":523},{"type":14,"value":892},{"type":9,"tag":22,"props":913,"children":915},{"className":914},[],[916],{"type":14,"value":421},{"type":9,"tag":639,"props":918,"children":919},{},[920,929],{"type":9,"tag":661,"props":921,"children":922},{},[923],{"type":9,"tag":22,"props":924,"children":926},{"className":925},[],[927],{"type":14,"value":928},"ctx.roll()",{"type":9,"tag":661,"props":930,"children":931},{},[932,934,939],{"type":14,"value":933},"the next number, 0 up to (not including) 1, of the run's ",{"type":9,"tag":22,"props":935,"children":937},{"className":936},[],[938],{"type":14,"value":194},{"type":14,"value":940}," random stream",{"type":9,"tag":617,"props":942,"children":944},{"id":943},"what-a-hook-returns",[945],{"type":14,"value":946},"What a hook returns",{"type":9,"tag":10,"props":948,"children":949},{},[950,956],{"type":9,"tag":22,"props":951,"children":953},{"className":952},[],[954],{"type":14,"value":955},"return commands, state",{"type":14,"value":957},". Both are optional.",{"type":9,"tag":70,"props":959,"children":960},{},[961,992],{"type":9,"tag":74,"props":962,"children":963},{},[964,969,971,976,978,983,984,990],{"type":9,"tag":22,"props":965,"children":967},{"className":966},[],[968],{"type":14,"value":99},{"type":14,"value":970},": a list (keys 1 to n, no holes) of at most ",{"type":9,"tag":113,"props":972,"children":973},{},[974],{"type":14,"value":975},"8",{"type":14,"value":977}," commands, or ",{"type":9,"tag":22,"props":979,"children":981},{"className":980},[],[982],{"type":14,"value":473},{"type":14,"value":415},{"type":9,"tag":22,"props":985,"children":987},{"className":986},[],[988],{"type":14,"value":989},"{}",{"type":14,"value":991}," for none.",{"type":9,"tag":74,"props":993,"children":994},{},[995,1000,1002,1007,1009,1015],{"type":9,"tag":22,"props":996,"children":998},{"className":997},[],[999],{"type":14,"value":92},{"type":14,"value":1001},": the table to keep for the next call (see \"State\"). A hook that returns ",{"type":9,"tag":113,"props":1003,"children":1004},{},[1005],{"type":14,"value":1006},"no second\nvalue",{"type":14,"value":1008}," keeps the old state; ",{"type":9,"tag":22,"props":1010,"children":1012},{"className":1011},[],[1013],{"type":14,"value":1014},"return commands, nil",{"type":14,"value":1016}," clears it.",{"type":9,"tag":617,"props":1018,"children":1019},{"id":99},[1020],{"type":14,"value":1021},"Commands",{"type":9,"tag":70,"props":1023,"children":1024},{},[1025,1043,1129,1184,1202],{"type":9,"tag":74,"props":1026,"children":1027},{},[1028,1034,1036,1041],{"type":9,"tag":22,"props":1029,"children":1031},{"className":1030},[],[1032],{"type":14,"value":1033},"{ say = \"\u003Cid>\" }",{"type":14,"value":1035},": the boss yells the English line of ",{"type":9,"tag":22,"props":1037,"children":1039},{"className":1038},[],[1040],{"type":14,"value":361},{"type":14,"value":1042},". No other field.",{"type":9,"tag":74,"props":1044,"children":1045},{},[1046,1052,1054,1060,1062,1067,1069,1074,1076,1082,1084,1090,1092,1098,1099,1105,1106,1112,1114,1120,1122,1127],{"type":9,"tag":22,"props":1047,"children":1049},{"className":1048},[],[1050],{"type":14,"value":1051},"{ ability = \u003Cability>, delay = \u003Cseconds> }",{"type":14,"value":1053},": plays an ability ",{"type":9,"tag":22,"props":1055,"children":1057},{"className":1056},[],[1058],{"type":14,"value":1059},"delay",{"type":14,"value":1061}," seconds from now. ",{"type":9,"tag":22,"props":1063,"children":1065},{"className":1064},[],[1066],{"type":14,"value":1059},{"type":14,"value":1068},"\nis optional (0) and is 0 to ",{"type":9,"tag":113,"props":1070,"children":1071},{},[1072],{"type":14,"value":1073},"30",{"type":14,"value":1075},". ",{"type":9,"tag":22,"props":1077,"children":1079},{"className":1078},[],[1080],{"type":14,"value":1081},"\u003Cability>",{"type":14,"value":1083}," is the table a kit writes after ",{"type":9,"tag":22,"props":1085,"children":1087},{"className":1086},[],[1088],{"type":14,"value":1089},"ability =",{"type":14,"value":1091},", in\nLua: ",{"type":9,"tag":22,"props":1093,"children":1095},{"className":1094},[],[1096],{"type":14,"value":1097},"{ nova = { spell = 905193, radius = 9.0, warn = 2.0 } }",{"type":14,"value":572},{"type":9,"tag":22,"props":1100,"children":1102},{"className":1101},[],[1103],{"type":14,"value":1104},"{ adds = 5 }",{"type":14,"value":572},{"type":9,"tag":22,"props":1107,"children":1109},{"className":1108},[],[1110],{"type":14,"value":1111},"\"charge\"",{"type":14,"value":1113},". It\ngoes through the kit's own number checks, and one more: an ability with a ",{"type":9,"tag":22,"props":1115,"children":1117},{"className":1116},[],[1118],{"type":14,"value":1119},"warn",{"type":14,"value":1121}," gives ",{"type":9,"tag":113,"props":1123,"children":1124},{},[1125],{"type":14,"value":1126},"at least\n1.0 second",{"type":14,"value":1128}," of warning (a script can read where the heroes are, so a hit it places must be one\na hero can still step out of).",{"type":9,"tag":74,"props":1130,"children":1131},{},[1132,1138,1140,1146,1148,1153,1155,1161,1163,1168,1170,1175,1177,1182],{"type":9,"tag":22,"props":1133,"children":1135},{"className":1134},[],[1136],{"type":14,"value":1137},"{ ability = { combo = { { \u003Cstep>, ... }, \u003Cgap> } }, delay = \u003Cseconds> }",{"type":14,"value":1139},": a combo as the kit's\n",{"type":9,"tag":22,"props":1141,"children":1143},{"className":1142},[],[1144],{"type":14,"value":1145},"combo",{"type":14,"value":1147}," is: ",{"type":9,"tag":113,"props":1149,"children":1150},{},[1151],{"type":14,"value":1152},"1 to 8",{"type":14,"value":1154}," steps, ",{"type":9,"tag":22,"props":1156,"children":1158},{"className":1157},[],[1159],{"type":14,"value":1160},"gap",{"type":14,"value":1162}," seconds apart (",{"type":9,"tag":113,"props":1164,"children":1165},{},[1166],{"type":14,"value":1167},"0 to 10",{"type":14,"value":1169},"), the first ",{"type":9,"tag":22,"props":1171,"children":1173},{"className":1172},[],[1174],{"type":14,"value":1059},{"type":14,"value":1176}," seconds from\nnow. The ability table holds ",{"type":9,"tag":22,"props":1178,"children":1180},{"className":1179},[],[1181],{"type":14,"value":1145},{"type":14,"value":1183}," and nothing else; a step is no combo and no script.",{"type":9,"tag":74,"props":1185,"children":1186},{},[1187,1189,1194,1196,1201],{"type":14,"value":1188},"A command with any other field is refused. ",{"type":9,"tag":22,"props":1190,"children":1192},{"className":1191},[],[1193],{"type":14,"value":421},{"type":14,"value":1195}," may only ",{"type":9,"tag":22,"props":1197,"children":1199},{"className":1198},[],[1200],{"type":14,"value":531},{"type":14,"value":398},{"type":9,"tag":74,"props":1203,"children":1204},{},[1205,1207,1213,1214,1220,1222,1228],{"type":14,"value":1206},"Numbers go by value, so ",{"type":9,"tag":22,"props":1208,"children":1210},{"className":1209},[],[1211],{"type":14,"value":1212},"4",{"type":14,"value":204},{"type":9,"tag":22,"props":1215,"children":1217},{"className":1216},[],[1218],{"type":14,"value":1219},"4.0",{"type":14,"value":1221}," are the same. A command table may share a sub-table with\nanother (the example's ",{"type":9,"tag":22,"props":1223,"children":1225},{"className":1224},[],[1226],{"type":14,"value":1227},"nova(radius)",{"type":14,"value":1229}," builds a fresh one each time anyway).",{"type":9,"tag":617,"props":1231,"children":1232},{"id":92},[1233],{"type":14,"value":1234},"State",{"type":9,"tag":10,"props":1236,"children":1237},{},[1238,1240,1245],{"type":14,"value":1239},"The state is what a script remembers, kept per boss and per script name (a boss that dies takes\nit with it), and carried through checkpoints and a host handover. It is ",{"type":9,"tag":22,"props":1241,"children":1243},{"className":1242},[],[1244],{"type":14,"value":473},{"type":14,"value":1246}," or a table of:",{"type":9,"tag":70,"props":1248,"children":1249},{},[1250,1260,1265],{"type":9,"tag":74,"props":1251,"children":1252},{},[1253,1258],{"type":9,"tag":22,"props":1254,"children":1256},{"className":1255},[],[1257],{"type":14,"value":473},{"type":14,"value":1259},", booleans, finite numbers, strings, and tables of those;",{"type":9,"tag":74,"props":1261,"children":1262},{},[1263],{"type":14,"value":1264},"table keys that are numbers or strings;",{"type":9,"tag":74,"props":1266,"children":1267},{},[1268],{"type":14,"value":1269},"no functions, no table with a metatable, and no table held twice (a cycle or two keys naming one\ntable): copy it instead.",{"type":9,"tag":10,"props":1271,"children":1272},{},[1273,1275,1280,1282,1287],{"type":14,"value":1274},"At most ",{"type":9,"tag":113,"props":1276,"children":1277},{},[1278],{"type":14,"value":1279},"4 KiB",{"type":14,"value":1281}," once encoded and ",{"type":9,"tag":113,"props":1283,"children":1284},{},[1285],{"type":14,"value":1286},"16 levels",{"type":14,"value":1288}," of tables (the state itself is level 1). The\nstate a hook receives is a copy: a change reaches the next call only through the returned state.\nA returned state that breaks a rule fails the call (see \"Errors\"), which keeps the old state.",{"type":9,"tag":63,"props":1290,"children":1292},{"id":1291},"the-sandbox",[1293],{"type":14,"value":1294},"The sandbox",{"type":9,"tag":10,"props":1296,"children":1297},{},[1298],{"type":14,"value":1299},"What exists:",{"type":9,"tag":70,"props":1301,"children":1302},{},[1303,1380,1501,1616],{"type":9,"tag":74,"props":1304,"children":1305},{},[1306,1308,1314,1315,1321,1322,1328,1329,1335,1336,1342,1343,1349,1350,1356,1357,1363,1364,1370,1372,1378],{"type":14,"value":1307},"Base: ",{"type":9,"tag":22,"props":1309,"children":1311},{"className":1310},[],[1312],{"type":14,"value":1313},"assert",{"type":14,"value":572},{"type":9,"tag":22,"props":1316,"children":1318},{"className":1317},[],[1319],{"type":14,"value":1320},"error",{"type":14,"value":572},{"type":9,"tag":22,"props":1323,"children":1325},{"className":1324},[],[1326],{"type":14,"value":1327},"ipairs",{"type":14,"value":572},{"type":9,"tag":22,"props":1330,"children":1332},{"className":1331},[],[1333],{"type":14,"value":1334},"next",{"type":14,"value":572},{"type":9,"tag":22,"props":1337,"children":1339},{"className":1338},[],[1340],{"type":14,"value":1341},"pairs",{"type":14,"value":572},{"type":9,"tag":22,"props":1344,"children":1346},{"className":1345},[],[1347],{"type":14,"value":1348},"select",{"type":14,"value":572},{"type":9,"tag":22,"props":1351,"children":1353},{"className":1352},[],[1354],{"type":14,"value":1355},"tonumber",{"type":14,"value":572},{"type":9,"tag":22,"props":1358,"children":1360},{"className":1359},[],[1361],{"type":14,"value":1362},"tostring",{"type":14,"value":572},{"type":9,"tag":22,"props":1365,"children":1367},{"className":1366},[],[1368],{"type":14,"value":1369},"type",{"type":14,"value":1371},",\n",{"type":9,"tag":22,"props":1373,"children":1375},{"className":1374},[],[1376],{"type":14,"value":1377},"unpack",{"type":14,"value":1379}," (at most 250 values: more is an error).",{"type":9,"tag":74,"props":1381,"children":1382},{},[1383,1389,1391,1397,1398,1404,1406,1412,1413,1419,1420,1426,1427,1433,1435,1441,1442,1448,1450,1456,1457,1463,1464,1470,1471,1477,1479,1485,1487,1492,1493,1499],{"type":9,"tag":22,"props":1384,"children":1386},{"className":1385},[],[1387],{"type":14,"value":1388},"string",{"type":14,"value":1390},": ",{"type":9,"tag":22,"props":1392,"children":1394},{"className":1393},[],[1395],{"type":14,"value":1396},"len",{"type":14,"value":572},{"type":9,"tag":22,"props":1399,"children":1401},{"className":1400},[],[1402],{"type":14,"value":1403},"byte",{"type":14,"value":1405}," (at most 250 values), ",{"type":9,"tag":22,"props":1407,"children":1409},{"className":1408},[],[1410],{"type":14,"value":1411},"char",{"type":14,"value":572},{"type":9,"tag":22,"props":1414,"children":1416},{"className":1415},[],[1417],{"type":14,"value":1418},"sub",{"type":14,"value":572},{"type":9,"tag":22,"props":1421,"children":1423},{"className":1422},[],[1424],{"type":14,"value":1425},"upper",{"type":14,"value":572},{"type":9,"tag":22,"props":1428,"children":1430},{"className":1429},[],[1431],{"type":14,"value":1432},"lower",{"type":14,"value":1434}," (ASCII only),\n",{"type":9,"tag":22,"props":1436,"children":1438},{"className":1437},[],[1439],{"type":14,"value":1440},"rep",{"type":14,"value":572},{"type":9,"tag":22,"props":1443,"children":1445},{"className":1444},[],[1446],{"type":14,"value":1447},"format",{"type":14,"value":1449}," (only ",{"type":9,"tag":22,"props":1451,"children":1453},{"className":1452},[],[1454],{"type":14,"value":1455},"%d",{"type":14,"value":572},{"type":9,"tag":22,"props":1458,"children":1460},{"className":1459},[],[1461],{"type":14,"value":1462},"%s",{"type":14,"value":572},{"type":9,"tag":22,"props":1465,"children":1467},{"className":1466},[],[1468],{"type":14,"value":1469},"%f",{"type":14,"value":204},{"type":9,"tag":22,"props":1472,"children":1474},{"className":1473},[],[1475],{"type":14,"value":1476},"%%",{"type":14,"value":1478},", no widths, at most 32 values). Strings take the\nmethod form, ",{"type":9,"tag":22,"props":1480,"children":1482},{"className":1481},[],[1483],{"type":14,"value":1484},"(\"x\"):upper()",{"type":14,"value":1486},". The bounds of ",{"type":9,"tag":22,"props":1488,"children":1490},{"className":1489},[],[1491],{"type":14,"value":1377},{"type":14,"value":204},{"type":9,"tag":22,"props":1494,"children":1496},{"className":1495},[],[1497],{"type":14,"value":1498},"string.byte",{"type":14,"value":1500}," are truncated toward\nzero, and NaN reads as 0.",{"type":9,"tag":74,"props":1502,"children":1503},{},[1504,1510,1511,1517,1518,1524,1525,1531,1532,1538,1539,1545,1546,1552,1553,1559,1560,1566,1567,1573,1574,1580,1581,1587,1588,1594,1595,1601,1602,1608,1609,1615],{"type":9,"tag":22,"props":1505,"children":1507},{"className":1506},[],[1508],{"type":14,"value":1509},"math",{"type":14,"value":1390},{"type":9,"tag":22,"props":1512,"children":1514},{"className":1513},[],[1515],{"type":14,"value":1516},"abs",{"type":14,"value":572},{"type":9,"tag":22,"props":1519,"children":1521},{"className":1520},[],[1522],{"type":14,"value":1523},"ceil",{"type":14,"value":572},{"type":9,"tag":22,"props":1526,"children":1528},{"className":1527},[],[1529],{"type":14,"value":1530},"floor",{"type":14,"value":572},{"type":9,"tag":22,"props":1533,"children":1535},{"className":1534},[],[1536],{"type":14,"value":1537},"max",{"type":14,"value":572},{"type":9,"tag":22,"props":1540,"children":1542},{"className":1541},[],[1543],{"type":14,"value":1544},"min",{"type":14,"value":572},{"type":9,"tag":22,"props":1547,"children":1549},{"className":1548},[],[1550],{"type":14,"value":1551},"sqrt",{"type":14,"value":572},{"type":9,"tag":22,"props":1554,"children":1556},{"className":1555},[],[1557],{"type":14,"value":1558},"fmod",{"type":14,"value":572},{"type":9,"tag":22,"props":1561,"children":1563},{"className":1562},[],[1564],{"type":14,"value":1565},"huge",{"type":14,"value":572},{"type":9,"tag":22,"props":1568,"children":1570},{"className":1569},[],[1571],{"type":14,"value":1572},"pi",{"type":14,"value":572},{"type":9,"tag":22,"props":1575,"children":1577},{"className":1576},[],[1578],{"type":14,"value":1579},"sin",{"type":14,"value":572},{"type":9,"tag":22,"props":1582,"children":1584},{"className":1583},[],[1585],{"type":14,"value":1586},"cos",{"type":14,"value":572},{"type":9,"tag":22,"props":1589,"children":1591},{"className":1590},[],[1592],{"type":14,"value":1593},"exp",{"type":14,"value":1371},{"type":9,"tag":22,"props":1596,"children":1598},{"className":1597},[],[1599],{"type":14,"value":1600},"log",{"type":14,"value":572},{"type":9,"tag":22,"props":1603,"children":1605},{"className":1604},[],[1606],{"type":14,"value":1607},"atan2",{"type":14,"value":572},{"type":9,"tag":22,"props":1610,"children":1612},{"className":1611},[],[1613],{"type":14,"value":1614},"pow",{"type":14,"value":398},{"type":9,"tag":74,"props":1617,"children":1618},{},[1619,1624,1625,1631,1632,1638,1639,1645,1646,1652,1653,1659],{"type":9,"tag":22,"props":1620,"children":1622},{"className":1621},[],[1623],{"type":14,"value":631},{"type":14,"value":1390},{"type":9,"tag":22,"props":1626,"children":1628},{"className":1627},[],[1629],{"type":14,"value":1630},"concat",{"type":14,"value":572},{"type":9,"tag":22,"props":1633,"children":1635},{"className":1634},[],[1636],{"type":14,"value":1637},"sort",{"type":14,"value":572},{"type":9,"tag":22,"props":1640,"children":1642},{"className":1641},[],[1643],{"type":14,"value":1644},"insert",{"type":14,"value":572},{"type":9,"tag":22,"props":1647,"children":1649},{"className":1648},[],[1650],{"type":14,"value":1651},"remove",{"type":14,"value":1075},{"type":9,"tag":22,"props":1654,"children":1656},{"className":1655},[],[1657],{"type":14,"value":1658},"table.sort",{"type":14,"value":1660}," is a stable merge sort: elements that\ncompare equal keep their order, and a comparator that is not consistent gives some order, never\nan error. Every comparison is counted as fuel: a sort of 1,000 numbers costs about 140,000 of a\ncall's 200,000.",{"type":9,"tag":10,"props":1662,"children":1663},{},[1664,1666,1672,1673,1679,1681,1687,1689,1694,1696,1702,1703,1709,1710,1716,1717,1723,1724,1730,1731,1737,1738,1744,1745,1751,1752,1758,1759,1765,1767,1773,1774,1780,1781,1787,1788,1794,1795,1801,1802,1808,1810,1816,1818,1824],{"type":14,"value":1665},"Nothing else exists: no ",{"type":9,"tag":22,"props":1667,"children":1669},{"className":1668},[],[1670],{"type":14,"value":1671},"pcall",{"type":14,"value":415},{"type":9,"tag":22,"props":1674,"children":1676},{"className":1675},[],[1677],{"type":14,"value":1678},"xpcall",{"type":14,"value":1680}," (a script could catch the out-of-fuel error and go\non), no ",{"type":9,"tag":22,"props":1682,"children":1684},{"className":1683},[],[1685],{"type":14,"value":1686},"math.random",{"type":14,"value":1688}," (use ",{"type":9,"tag":22,"props":1690,"children":1692},{"className":1691},[],[1693],{"type":14,"value":928},{"type":14,"value":1695},"), no ",{"type":9,"tag":22,"props":1697,"children":1699},{"className":1698},[],[1700],{"type":14,"value":1701},"os",{"type":14,"value":572},{"type":9,"tag":22,"props":1704,"children":1706},{"className":1705},[],[1707],{"type":14,"value":1708},"io",{"type":14,"value":572},{"type":9,"tag":22,"props":1711,"children":1713},{"className":1712},[],[1714],{"type":14,"value":1715},"require",{"type":14,"value":572},{"type":9,"tag":22,"props":1718,"children":1720},{"className":1719},[],[1721],{"type":14,"value":1722},"load",{"type":14,"value":572},{"type":9,"tag":22,"props":1725,"children":1727},{"className":1726},[],[1728],{"type":14,"value":1729},"loadstring",{"type":14,"value":1371},{"type":9,"tag":22,"props":1732,"children":1734},{"className":1733},[],[1735],{"type":14,"value":1736},"dofile",{"type":14,"value":572},{"type":9,"tag":22,"props":1739,"children":1741},{"className":1740},[],[1742],{"type":14,"value":1743},"getmetatable",{"type":14,"value":572},{"type":9,"tag":22,"props":1746,"children":1748},{"className":1747},[],[1749],{"type":14,"value":1750},"setmetatable",{"type":14,"value":572},{"type":9,"tag":22,"props":1753,"children":1755},{"className":1754},[],[1756],{"type":14,"value":1757},"rawget",{"type":14,"value":572},{"type":9,"tag":22,"props":1760,"children":1762},{"className":1761},[],[1763],{"type":14,"value":1764},"rawset",{"type":14,"value":1766},", no ",{"type":9,"tag":22,"props":1768,"children":1770},{"className":1769},[],[1771],{"type":14,"value":1772},"string.find",{"type":14,"value":572},{"type":9,"tag":22,"props":1775,"children":1777},{"className":1776},[],[1778],{"type":14,"value":1779},"match",{"type":14,"value":572},{"type":9,"tag":22,"props":1782,"children":1784},{"className":1783},[],[1785],{"type":14,"value":1786},"gsub",{"type":14,"value":1371},{"type":9,"tag":22,"props":1789,"children":1791},{"className":1790},[],[1792],{"type":14,"value":1793},"gmatch",{"type":14,"value":415},{"type":9,"tag":22,"props":1796,"children":1798},{"className":1797},[],[1799],{"type":14,"value":1800},"dump",{"type":14,"value":1766},{"type":9,"tag":22,"props":1803,"children":1805},{"className":1804},[],[1806],{"type":14,"value":1807},"table.getn",{"type":14,"value":1809},". The library tables cannot be written to. The ",{"type":9,"tag":22,"props":1811,"children":1813},{"className":1812},[],[1814],{"type":14,"value":1815},"^",{"type":14,"value":1817}," operator is\nrefused when the script loads: write ",{"type":9,"tag":22,"props":1819,"children":1821},{"className":1820},[],[1822],{"type":14,"value":1823},"math.pow(x, y)",{"type":14,"value":398},{"type":9,"tag":617,"props":1826,"children":1828},{"id":1827},"limits",[1829],{"type":14,"value":1830},"Limits",{"type":9,"tag":10,"props":1832,"children":1833},{},[1834],{"type":14,"value":1835},"Every number, as the game enforces it:",{"type":9,"tag":631,"props":1837,"children":1838},{},[1839,1855],{"type":9,"tag":635,"props":1840,"children":1841},{},[1842],{"type":9,"tag":639,"props":1843,"children":1844},{},[1845,1850],{"type":9,"tag":643,"props":1846,"children":1847},{},[1848],{"type":14,"value":1849},"What",{"type":9,"tag":643,"props":1851,"children":1852},{},[1853],{"type":14,"value":1854},"Limit",{"type":9,"tag":654,"props":1856,"children":1857},{},[1858,1871,1884,1897,1909,1922,1940,1957,1980,2000,2012,2025,2042,2054,2066,2079],{"type":9,"tag":639,"props":1859,"children":1860},{},[1861,1866],{"type":9,"tag":661,"props":1862,"children":1863},{},[1864],{"type":14,"value":1865},"VM instructions one hook call may run (the fuel)",{"type":9,"tag":661,"props":1867,"children":1868},{},[1869],{"type":14,"value":1870},"200,000",{"type":9,"tag":639,"props":1872,"children":1873},{},[1874,1879],{"type":9,"tag":661,"props":1875,"children":1876},{},[1877],{"type":14,"value":1878},"VM instructions all the calls of one simulation step may run together",{"type":9,"tag":661,"props":1880,"children":1881},{},[1882],{"type":14,"value":1883},"1,000,000",{"type":9,"tag":639,"props":1885,"children":1886},{},[1887,1892],{"type":9,"tag":661,"props":1888,"children":1889},{},[1890],{"type":14,"value":1891},"Memory the VM may hold",{"type":9,"tag":661,"props":1893,"children":1894},{},[1895],{"type":14,"value":1896},"8 MiB",{"type":9,"tag":639,"props":1898,"children":1899},{},[1900,1905],{"type":9,"tag":661,"props":1901,"children":1902},{},[1903],{"type":14,"value":1904},"Commands one call may return",{"type":9,"tag":661,"props":1906,"children":1907},{},[1908],{"type":14,"value":975},{"type":9,"tag":639,"props":1910,"children":1911},{},[1912,1917],{"type":9,"tag":661,"props":1913,"children":1914},{},[1915],{"type":14,"value":1916},"A call's command list, read as data (a table held twice counts twice)",{"type":9,"tag":661,"props":1918,"children":1919},{},[1920],{"type":14,"value":1921},"64 KiB",{"type":9,"tag":639,"props":1923,"children":1924},{},[1925,1935],{"type":9,"tag":661,"props":1926,"children":1927},{},[1928,1933],{"type":9,"tag":22,"props":1929,"children":1931},{"className":1930},[],[1932],{"type":14,"value":1059},{"type":14,"value":1934}," of a command",{"type":9,"tag":661,"props":1936,"children":1937},{},[1938],{"type":14,"value":1939},"0 to 30 s",{"type":9,"tag":639,"props":1941,"children":1942},{},[1943,1953],{"type":9,"tag":661,"props":1944,"children":1945},{},[1946,1948],{"type":14,"value":1947},"Steps of a ",{"type":9,"tag":22,"props":1949,"children":1951},{"className":1950},[],[1952],{"type":14,"value":1145},{"type":9,"tag":661,"props":1954,"children":1955},{},[1956],{"type":14,"value":1152},{"type":9,"tag":639,"props":1958,"children":1959},{},[1960,1975],{"type":9,"tag":661,"props":1961,"children":1962},{},[1963,1968,1970],{"type":9,"tag":22,"props":1964,"children":1966},{"className":1965},[],[1967],{"type":14,"value":1160},{"type":14,"value":1969}," of a ",{"type":9,"tag":22,"props":1971,"children":1973},{"className":1972},[],[1974],{"type":14,"value":1145},{"type":9,"tag":661,"props":1976,"children":1977},{},[1978],{"type":14,"value":1979},"0 to 10 s",{"type":9,"tag":639,"props":1981,"children":1982},{},[1983,1995],{"type":9,"tag":661,"props":1984,"children":1985},{},[1986,1988,1993],{"type":14,"value":1987},"Warning (",{"type":9,"tag":22,"props":1989,"children":1991},{"className":1990},[],[1992],{"type":14,"value":1119},{"type":14,"value":1994},") of a script's ability",{"type":9,"tag":661,"props":1996,"children":1997},{},[1998],{"type":14,"value":1999},"at least 1.0 s",{"type":9,"tag":639,"props":2001,"children":2002},{},[2003,2008],{"type":9,"tag":661,"props":2004,"children":2005},{},[2006],{"type":14,"value":2007},"State, encoded",{"type":9,"tag":661,"props":2009,"children":2010},{},[2011],{"type":14,"value":1279},{"type":9,"tag":639,"props":2013,"children":2014},{},[2015,2020],{"type":9,"tag":661,"props":2016,"children":2017},{},[2018],{"type":14,"value":2019},"Levels of tables in the state",{"type":9,"tag":661,"props":2021,"children":2022},{},[2023],{"type":14,"value":2024},"16",{"type":9,"tag":639,"props":2026,"children":2027},{},[2028,2038],{"type":9,"tag":661,"props":2029,"children":2030},{},[2031,2036],{"type":9,"tag":22,"props":2032,"children":2034},{"className":2033},[],[2035],{"type":14,"value":291},{"type":14,"value":2037}," of a kit entry",{"type":9,"tag":661,"props":2039,"children":2040},{},[2041],{"type":14,"value":2024},{"type":9,"tag":639,"props":2043,"children":2044},{},[2045,2050],{"type":9,"tag":661,"props":2046,"children":2047},{},[2048],{"type":14,"value":2049},"One script file",{"type":9,"tag":661,"props":2051,"children":2052},{},[2053],{"type":14,"value":1921},{"type":9,"tag":639,"props":2055,"children":2056},{},[2057,2062],{"type":9,"tag":661,"props":2058,"children":2059},{},[2060],{"type":14,"value":2061},"Script files of a package",{"type":9,"tag":661,"props":2063,"children":2064},{},[2065],{"type":14,"value":2024},{"type":9,"tag":639,"props":2067,"children":2068},{},[2069,2074],{"type":9,"tag":661,"props":2070,"children":2071},{},[2072],{"type":14,"value":2073},"Script files of a profile",{"type":9,"tag":661,"props":2075,"children":2076},{},[2077],{"type":14,"value":2078},"1 MiB together",{"type":9,"tag":639,"props":2080,"children":2081},{},[2082,2100],{"type":9,"tag":661,"props":2083,"children":2084},{},[2085,2087,2092,2093,2098],{"type":14,"value":2086},"Values one ",{"type":9,"tag":22,"props":2088,"children":2090},{"className":2089},[],[2091],{"type":14,"value":1377},{"type":14,"value":415},{"type":9,"tag":22,"props":2094,"children":2096},{"className":2095},[],[2097],{"type":14,"value":1498},{"type":14,"value":2099}," returns",{"type":9,"tag":661,"props":2101,"children":2102},{},[2103],{"type":14,"value":2104},"250",{"type":9,"tag":10,"props":2106,"children":2107},{},[2108,2110,2116,2118,2124,2125,2131,2132,2138,2139,2145,2147,2153,2155,2161,2162,2168,2169,2175,2177,2183,2185,2190,2191,2196,2197,2202,2203,2208,2209,2214,2215,2220,2221,2226,2227,2232,2233,2238,2240,2246,2247,2253,2255,2261,2263,2269,2270,2276,2277,2283,2285,2291],{"type":14,"value":2109},"Fuel is counted in steps of 1,000 instructions. Work that one instruction or one library function\ndoes in proportion to its operands is charged on top, before it is done, one instruction for every\n32 bytes: the bytes ",{"type":9,"tag":22,"props":2111,"children":2113},{"className":2112},[],[2114],{"type":14,"value":2115},"..",{"type":14,"value":2117}," copies, both lengths of a string ",{"type":9,"tag":22,"props":2119,"children":2121},{"className":2120},[],[2122],{"type":14,"value":2123},"\u003C",{"type":14,"value":572},{"type":9,"tag":22,"props":2126,"children":2128},{"className":2127},[],[2129],{"type":14,"value":2130},"\u003C=",{"type":14,"value":572},{"type":9,"tag":22,"props":2133,"children":2135},{"className":2134},[],[2136],{"type":14,"value":2137},">",{"type":14,"value":415},{"type":9,"tag":22,"props":2140,"children":2142},{"className":2141},[],[2143],{"type":14,"value":2144},">=",{"type":14,"value":2146},", 16 bytes for each\nvalue a ",{"type":9,"tag":22,"props":2148,"children":2150},{"className":2149},[],[2151],{"type":14,"value":2152},"...",{"type":14,"value":2154}," expands to where all its values are taken (",{"type":9,"tag":22,"props":2156,"children":2158},{"className":2157},[],[2159],{"type":14,"value":2160},"f(...)",{"type":14,"value":572},{"type":9,"tag":22,"props":2163,"children":2165},{"className":2164},[],[2166],{"type":14,"value":2167},"{...}",{"type":14,"value":572},{"type":9,"tag":22,"props":2170,"children":2172},{"className":2171},[],[2173],{"type":14,"value":2174},"return ...",{"type":14,"value":2176},"; not\n",{"type":9,"tag":22,"props":2178,"children":2180},{"className":2179},[],[2181],{"type":14,"value":2182},"local a, b = ...",{"type":14,"value":2184},"), 1 byte for each array slot and 3 for each node of a table that rehashes (the\nstore that finds a full table; a rehash that shrinks the array part also pays 3 for each slot it\nmoves into the hash part), and what ",{"type":9,"tag":22,"props":2186,"children":2188},{"className":2187},[],[2189],{"type":14,"value":1440},{"type":14,"value":572},{"type":9,"tag":22,"props":2192,"children":2194},{"className":2193},[],[2195],{"type":14,"value":1447},{"type":14,"value":572},{"type":9,"tag":22,"props":2198,"children":2200},{"className":2199},[],[2201],{"type":14,"value":1630},{"type":14,"value":572},{"type":9,"tag":22,"props":2204,"children":2206},{"className":2205},[],[2207],{"type":14,"value":1418},{"type":14,"value":572},{"type":9,"tag":22,"props":2210,"children":2212},{"className":2211},[],[2213],{"type":14,"value":1425},{"type":14,"value":572},{"type":9,"tag":22,"props":2216,"children":2218},{"className":2217},[],[2219],{"type":14,"value":1432},{"type":14,"value":572},{"type":9,"tag":22,"props":2222,"children":2224},{"className":2223},[],[2225],{"type":14,"value":1341},{"type":14,"value":1371},{"type":9,"tag":22,"props":2228,"children":2230},{"className":2229},[],[2231],{"type":14,"value":1334},{"type":14,"value":204},{"type":9,"tag":22,"props":2234,"children":2236},{"className":2235},[],[2237],{"type":14,"value":1355},{"type":14,"value":2239}," copy or scan. A table that grows because a constructor sizes it (",{"type":9,"tag":22,"props":2241,"children":2243},{"className":2242},[],[2244],{"type":14,"value":2245},"{ ... }",{"type":14,"value":1371},{"type":9,"tag":22,"props":2248,"children":2250},{"className":2249},[],[2251],{"type":14,"value":2252},"{ 1, 2, 3 }",{"type":14,"value":2254},") is not charged. So ",{"type":9,"tag":22,"props":2256,"children":2258},{"className":2257},[],[2259],{"type":14,"value":2260},"a .. b",{"type":14,"value":2262}," of two 100,000-byte strings costs 6,250 fuel, while\nshort strings cost next to nothing, and the growth of a table to 100 string keys costs 12. A\n",{"type":9,"tag":22,"props":2264,"children":2266},{"className":2265},[],[2267],{"type":14,"value":2268},"string.rep",{"type":14,"value":572},{"type":9,"tag":22,"props":2271,"children":2273},{"className":2272},[],[2274],{"type":14,"value":2275},"string.format",{"type":14,"value":415},{"type":9,"tag":22,"props":2278,"children":2280},{"className":2279},[],[2281],{"type":14,"value":2282},"table.concat",{"type":14,"value":2284}," that would pass the memory limit is an error at\nonce. ",{"type":9,"tag":22,"props":2286,"children":2288},{"className":2287},[],[2289],{"type":14,"value":2290},"azs-script check",{"type":14,"value":2292}," also warns when a script holds more\nthan half the memory.",{"type":9,"tag":617,"props":2294,"children":2296},{"id":2295},"determinism",[2297],{"type":14,"value":2298},"Determinism",{"type":9,"tag":10,"props":2300,"children":2301},{},[2302],{"type":14,"value":2303},"Every machine must play the same fight from the same seed. The sandbox keeps it so; a script that depends on anything else is refused by the check.",{"type":9,"tag":70,"props":2305,"children":2306},{},[2307,2323,2350,2360,2386],{"type":9,"tag":74,"props":2308,"children":2309},{},[2310,2315,2316,2321],{"type":9,"tag":22,"props":2311,"children":2313},{"className":2312},[],[2314],{"type":14,"value":1341},{"type":14,"value":204},{"type":9,"tag":22,"props":2317,"children":2319},{"className":2318},[],[2320],{"type":14,"value":1334},{"type":14,"value":2322}," walk a table in a fixed order: number keys ascending, then string keys in byte\norder. A table keyed by a table, a function or a boolean has no order, and walking it is an\nerror.",{"type":9,"tag":74,"props":2324,"children":2325},{},[2326,2328,2334,2335,2341,2343,2348],{"type":14,"value":2327},"Strings compare by their bytes, as unsigned numbers, whatever the computer's language settings:\n",{"type":9,"tag":22,"props":2329,"children":2331},{"className":2330},[],[2332],{"type":14,"value":2333},"\"Z\" \u003C \"a\"",{"type":14,"value":572},{"type":9,"tag":22,"props":2336,"children":2338},{"className":2337},[],[2339],{"type":14,"value":2340},"\"a\" \u003C \"a\\0\"",{"type":14,"value":2342},", and ",{"type":9,"tag":22,"props":2344,"children":2346},{"className":2345},[],[2347],{"type":14,"value":1658},{"type":14,"value":2349}," without a comparator sorts strings so.",{"type":9,"tag":74,"props":2351,"children":2352},{},[2353,2358],{"type":9,"tag":22,"props":2354,"children":2356},{"className":2355},[],[2357],{"type":14,"value":1362},{"type":14,"value":2359}," of a table or a function is an error (it would print an address).",{"type":9,"tag":74,"props":2361,"children":2362},{},[2363,2365,2370,2372,2377,2379,2384],{"type":14,"value":2364},"Chance is ",{"type":9,"tag":22,"props":2366,"children":2368},{"className":2367},[],[2369],{"type":14,"value":928},{"type":14,"value":2371},", the run's own ",{"type":9,"tag":22,"props":2373,"children":2375},{"className":2374},[],[2376],{"type":14,"value":194},{"type":14,"value":2378}," stream, drawn only when you call it. There is no\nclock: ",{"type":9,"tag":22,"props":2380,"children":2382},{"className":2381},[],[2383],{"type":14,"value":669},{"type":14,"value":2385}," is the run's.",{"type":9,"tag":74,"props":2387,"children":2388},{},[2389,2391,2396,2397,2402],{"type":14,"value":2390},"The same ",{"type":9,"tag":22,"props":2392,"children":2394},{"className":2393},[],[2395],{"type":14,"value":84},{"type":14,"value":204},{"type":9,"tag":22,"props":2398,"children":2400},{"className":2399},[],[2401],{"type":14,"value":92},{"type":14,"value":2403}," must give the same commands, state and fuel. The check calls every\nhook twice in two VMs to see that.",{"type":9,"tag":617,"props":2405,"children":2407},{"id":2406},"errors",[2408],{"type":14,"value":2409},"Errors",{"type":9,"tag":10,"props":2411,"children":2412},{},[2413],{"type":14,"value":2414},"None of these ends the run.",{"type":9,"tag":70,"props":2416,"children":2417},{},[2418,2450,2482],{"type":9,"tag":74,"props":2419,"children":2420},{},[2421,2423,2428,2429,2434,2436,2441,2443,2448],{"type":14,"value":2422},"A hook that raises an error, runs out of fuel or memory, returns commands that break a shape rule\n(more than 8, an unknown field, a ",{"type":9,"tag":22,"props":2424,"children":2426},{"className":2425},[],[2427],{"type":14,"value":1059},{"type":14,"value":415},{"type":9,"tag":22,"props":2430,"children":2432},{"className":2431},[],[2433],{"type":14,"value":1160},{"type":14,"value":2435}," out of range, a combo of the wrong shape, an\nability table the kit would not read) or returns a state that breaks a rule ",{"type":9,"tag":113,"props":2437,"children":2438},{},[2439],{"type":14,"value":2440},"fails",{"type":14,"value":2442},": it\ngives no commands, keeps the old state, and is counted and logged. The ",{"type":9,"tag":113,"props":2444,"children":2445},{},[2446],{"type":14,"value":2447},"third",{"type":14,"value":2449}," failure of one\nscript on one boss switches that script off for that boss until the fight ends; the boss\ngoes on with its other kit entries.",{"type":9,"tag":74,"props":2451,"children":2452},{},[2453,2455,2460,2462,2467,2468,2473,2475,2480],{"type":14,"value":2454},"A single command that is well formed but may not play (its numbers fail the kit's checks, its\n",{"type":9,"tag":22,"props":2456,"children":2458},{"className":2457},[],[2459],{"type":14,"value":1119},{"type":14,"value":2461}," is under 1.0 s, it is not a ",{"type":9,"tag":22,"props":2463,"children":2465},{"className":2464},[],[2466],{"type":14,"value":531},{"type":14,"value":224},{"type":9,"tag":22,"props":2469,"children":2471},{"className":2470},[],[2472],{"type":14,"value":421},{"type":14,"value":2474},", or it names a yell the boss kit does not\ndefine) is ",{"type":9,"tag":113,"props":2476,"children":2477},{},[2478],{"type":14,"value":2479},"dropped",{"type":14,"value":2481},": the rest play. Drops are counted; the first three of each script on each\nboss are logged.",{"type":9,"tag":74,"props":2483,"children":2484},{},[2485],{"type":14,"value":2486},"A script that does not load (a syntax error, or a top level that fails) is logged once and none\nof the profile's scripts runs.",{"type":9,"tag":63,"props":2488,"children":2490},{"id":2489},"checking-a-profile",[2491],{"type":14,"value":2492},"Checking a profile",{"type":9,"tag":252,"props":2494,"children":2498},{"className":2495,"code":2497,"language":14,"meta":258},[2496],"language-text","azs-script check \u003Cprofile folder>\n",[2499],{"type":9,"tag":22,"props":2500,"children":2501},{"__ignoreMap":258},[2502],{"type":14,"value":2497},{"type":9,"tag":10,"props":2504,"children":2505},{},[2506,2508,2514,2516,2521,2523,2528,2530,2536,2538,2544],{"type":14,"value":2507},"It resolves the profile as ",{"type":9,"tag":22,"props":2509,"children":2511},{"className":2510},[],[2512],{"type":14,"value":2513},"azs-content profile-check",{"type":14,"value":2515}," does, then runs every script a boss kit or\nphase names: it loads, calls every hook the kit uses it through (and ",{"type":9,"tag":22,"props":2517,"children":2519},{"className":2518},[],[2520],{"type":14,"value":421},{"type":14,"value":2522}," when defined) against\n30 fixed fights (the boss at 100, 75, 50, 25 and 5 % health, each with 0 to 5 heroes, and every\n",{"type":9,"tag":22,"props":2524,"children":2526},{"className":2525},[],[2527],{"type":14,"value":291},{"type":14,"value":2529}," set of the kit entries that name it), calls each hook twice in two VMs, and then calls\neach 200 times in a row with its state carried over. It prints one line per problem,\n",{"type":9,"tag":22,"props":2531,"children":2533},{"className":2532},[],[2534],{"type":14,"value":2535},"packs\u002F\u003Cpackage>\u002Fscripts\u002F\u003Cname>.lua:\u003Cline>: \u003Cmessage>",{"type":14,"value":2537}," (no line when the VM has none), and exits\n1 when there is any; with none it prints ",{"type":9,"tag":22,"props":2539,"children":2541},{"className":2540},[],[2542],{"type":14,"value":2543},"azs-script: \u003Cfolder>: N script(s) checked, no problems",{"type":14,"value":2545},"\nand exits 0. The game runs the same check when a profile with scripts is imported. A problem is one\nof:",{"type":9,"tag":70,"props":2547,"children":2548},{},[2549,2568,2580,2591,2601,2624,2637,2665,2676,2686],{"type":9,"tag":74,"props":2550,"children":2551},{},[2552,2558,2560,2566],{"type":9,"tag":22,"props":2553,"children":2555},{"className":2554},[],[2556],{"type":14,"value":2557},"a boss kit names the script ... but ... does not exist",{"type":14,"value":2559},": no file at that path in the pack that\ndefines the kit file. ",{"type":9,"tag":22,"props":2561,"children":2563},{"className":2562},[],[2564],{"type":14,"value":2565},"... is not a script name",{"type":14,"value":2567},": a name that breaks the rule above.",{"type":9,"tag":74,"props":2569,"children":2570},{},[2571,2573,2578],{"type":14,"value":2572},"A syntax error with its line, or the ",{"type":9,"tag":22,"props":2574,"children":2576},{"className":2575},[],[2577],{"type":14,"value":1815},{"type":14,"value":2579}," operator message, or a top level that fails.",{"type":9,"tag":74,"props":2581,"children":2582},{},[2583,2589],{"type":9,"tag":22,"props":2584,"children":2586},{"className":2585},[],[2587],{"type":14,"value":2588},"loads alone but not together with the profile's other scripts",{"type":14,"value":2590},": the game loads every script\nof a profile into one VM, whose 8 MiB they share; the first script that does not fit is named.",{"type":9,"tag":74,"props":2592,"children":2593},{},[2594,2600],{"type":9,"tag":22,"props":2595,"children":2597},{"className":2596},[],[2598],{"type":14,"value":2599},"a boss kit calls its ... hook, which the script does not define",{"type":14,"value":398},{"type":9,"tag":74,"props":2602,"children":2603},{},[2604,2610,2612,2617,2618,2623],{"type":9,"tag":22,"props":2605,"children":2607},{"className":2606},[],[2608],{"type":14,"value":2609},"... gave different results in two identical calls",{"type":14,"value":2611},": the script depends on something other than\n",{"type":9,"tag":22,"props":2613,"children":2615},{"className":2614},[],[2616],{"type":14,"value":84},{"type":14,"value":204},{"type":9,"tag":22,"props":2619,"children":2621},{"className":2620},[],[2622],{"type":14,"value":92},{"type":14,"value":398},{"type":9,"tag":74,"props":2625,"children":2626},{},[2627,2629,2635],{"type":14,"value":2628},"An error of a hook, named with the fight it met (",{"type":9,"tag":22,"props":2630,"children":2632},{"className":2631},[],[2633],{"type":14,"value":2634},"0 hero(es), boss at 100% health",{"type":14,"value":2636},") and its\nline: a nil index, out of fuel, out of memory, a bad command list.",{"type":9,"tag":74,"props":2638,"children":2639},{},[2640,2642,2648,2650,2656,2657,2663],{"type":14,"value":2641},"A command problem: ",{"type":9,"tag":22,"props":2643,"children":2645},{"className":2644},[],[2646],{"type":14,"value":2647},"says x, but boss b has no yell x in its kit file",{"type":14,"value":2649}," (each boss that uses the\nscript is checked on its own, as the run does), ",{"type":9,"tag":22,"props":2651,"children":2653},{"className":2652},[],[2654],{"type":14,"value":2655},"warn = ... is under the 1 s of warning a script's ability must give",{"type":14,"value":572},{"type":9,"tag":22,"props":2658,"children":2660},{"className":2659},[],[2661],{"type":14,"value":2662},"death may return say commands only",{"type":14,"value":2664},", or the kit's\nown number check of the ability.",{"type":9,"tag":74,"props":2666,"children":2667},{},[2668,2674],{"type":9,"tag":22,"props":2669,"children":2671},{"className":2670},[],[2672],{"type":14,"value":2673},"... after chained calls: bad state ...",{"type":14,"value":2675},": the state outgrows its limits when a hook's state is\nfed back to it (the 200 calls).",{"type":9,"tag":74,"props":2677,"children":2678},{},[2679,2685],{"type":9,"tag":22,"props":2680,"children":2682},{"className":2681},[],[2683],{"type":14,"value":2684},"uses about N KiB, more than half the 8 MiB limit",{"type":14,"value":398},{"type":9,"tag":74,"props":2687,"children":2688},{},[2689,2695,2697,2703,2705,2711,2713,2719],{"type":9,"tag":22,"props":2690,"children":2692},{"className":2691},[],[2693],{"type":14,"value":2694},"a call took N ms; a slow script freezes the game while it runs",{"type":14,"value":2696}," (or ",{"type":9,"tag":22,"props":2698,"children":2700},{"className":2699},[],[2701],{"type":14,"value":2702},"its calls took N ms together",{"type":14,"value":2704},"): one call took more than 250 ms, or all calls of one use of the script more than\n10 s (each use starts from zero). ",{"type":9,"tag":22,"props":2706,"children":2708},{"className":2707},[],[2709],{"type":14,"value":2710},"its top level took N ms; a slow script freezes the game while it loads",{"type":14,"value":2712},": loading the script (running its top level) took more than 250 ms, a bound of\nits own (",{"type":9,"tag":22,"props":2714,"children":2716},{"className":2715},[],[2717],{"type":14,"value":2718},"CHECK_LOAD_SLOW",{"type":14,"value":2720},"). In each case the script is checked no further. These are\nwall-clock limits of the check only; the game has no clock in a run.",{"type":9,"tag":63,"props":2722,"children":2724},{"id":2723},"a-worked-example",[2725],{"type":14,"value":2726},"A worked example",{"type":9,"tag":10,"props":2728,"children":2729},{},[2730,2732,2738],{"type":14,"value":2731},"A boss that slams a nova every 8 seconds, and on every third slam a combo of three growing novas\nand a yell; it yells once more as it dies. Appended to a boss kit file, ",{"type":9,"tag":22,"props":2733,"children":2735},{"className":2734},[],[2736],{"type":14,"value":2737},"packs\u002F\u003Cpackage>\u002Fbosses\u002F\u003Cboss>.toml",{"type":14,"value":250},{"type":9,"tag":252,"props":2740,"children":2743},{"className":2741,"code":2742,"language":257,"meta":258},[255],"[[boss.kit]]\nevery = 8.0\nability = { script = { name = \"slam\", params = { reach = 4.0 } } }\n\n[boss.yells.slam]\nen = \"Slam!\"\nde = \"Wumms!\"\nfr = \"Boum !\"\nes = \"¡Zas!\"\npt = \"Pancada!\"\nru = \"Бам!\"\nit = \"Bum!\"\npl = \"Trzask!\"\ntr = \"Güm!\"\nja = \"ドン！\"\nzh = \"砰！\"\nko = \"쾅!\"\n",[2744],{"type":9,"tag":22,"props":2745,"children":2746},{"__ignoreMap":258},[2747],{"type":14,"value":2742},{"type":9,"tag":10,"props":2749,"children":2750},{},[2751,2753,2759],{"type":14,"value":2752},"and ",{"type":9,"tag":22,"props":2754,"children":2756},{"className":2755},[],[2757],{"type":14,"value":2758},"packs\u002F\u003Cpackage>\u002Fscripts\u002Fslam.lua",{"type":14,"value":250},{"type":9,"tag":252,"props":2761,"children":2766},{"className":2762,"code":2764,"language":2765,"meta":258},[2763],"language-lua","-- slam.lua: a nova on every cast, and on every third cast a combo of three novas and a yell.\nlocal function nova(radius)\n  return { nova = { spell = 905193, radius = radius, warn = 1.5 } }\nend\n\nfunction fire(ctx, state)\n  local casts = (state.casts or 0) + 1\n  state.casts = casts\n  local radius = (ctx.params.reach or 4) + 2 + ctx.roll() * 2\n  if casts % 3 == 0 then\n    local steps = { nova(radius), nova(radius + 2), nova(radius + 4) }\n    return { { ability = { combo = { steps, 1.5 } } }, { say = \"slam\" } }, state\n  end\n  return { { ability = nova(radius), delay = 0.5 } }, state\nend\n\nfunction death(ctx, state)\n  return { { say = \"slam\" } }\nend\n","lua",[2767],{"type":9,"tag":22,"props":2768,"children":2769},{"__ignoreMap":258},[2770],{"type":14,"value":2764},{"type":9,"tag":10,"props":2772,"children":2773},{},[2774,2780,2782,2788],{"type":9,"tag":22,"props":2775,"children":2777},{"className":2776},[],[2778],{"type":14,"value":2779},"crates\u002Fsurvivors-script\u002Ftests\u002Fguide.rs",{"type":14,"value":2781}," holds both files verbatim (",{"type":9,"tag":22,"props":2783,"children":2785},{"className":2784},[],[2786],{"type":14,"value":2787},"tests\u002Fexample\u002F",{"type":14,"value":2789},") and runs\nthe check on a profile built from them, so this example cannot go stale.",{"type":9,"tag":63,"props":2791,"children":2793},{"id":2792},"known-limits",[2794],{"type":14,"value":2795},"Known limits",{"type":9,"tag":10,"props":2797,"children":2798},{},[2799],{"type":14,"value":2800},"These are accepted for the first version, and an author should know them.",{"type":9,"tag":70,"props":2802,"children":2803},{},[2804,2899,2917,3002,3012,3071,3093,3103],{"type":9,"tag":74,"props":2805,"children":2806},{},[2807,2812,2814,2819,2821,2826,2828,2833,2834,2839,2841,2846,2848,2854,2856,2861,2863,2869,2871,2876,2878,2883,2885,2890,2892,2897],{"type":9,"tag":113,"props":2808,"children":2809},{},[2810],{"type":14,"value":2811},"How long a call can hold the host.",{"type":14,"value":2813}," The instructions that do work in proportion to their\noperands pay for it in fuel (see \"Limits\"): ",{"type":9,"tag":22,"props":2815,"children":2817},{"className":2816},[],[2818],{"type":14,"value":2115},{"type":14,"value":2820},", string comparison, ",{"type":9,"tag":22,"props":2822,"children":2824},{"className":2823},[],[2825],{"type":14,"value":2152},{"type":14,"value":2827},", a table's rehash,\nand the library functions. ",{"type":9,"tag":22,"props":2829,"children":2831},{"className":2830},[],[2832],{"type":14,"value":1377},{"type":14,"value":204},{"type":9,"tag":22,"props":2835,"children":2837},{"className":2836},[],[2838],{"type":14,"value":1498},{"type":14,"value":2840}," return at most 250 values, and\n",{"type":9,"tag":22,"props":2842,"children":2844},{"className":2843},[],[2845],{"type":14,"value":1658},{"type":14,"value":2847}," is a merge sort whose comparisons are counted, so no order of the elements makes it\nslow. The work the meter and the library charge is therefore at most about 6.4 MB per call\n(200,000 fuel at 32 bytes); for rehashes that figure is nominal, since a node is charged at a\nfixed 3 bytes, far under its real size, and the measured times below are the bound. Measured on Windows 11 in a release build, each of these loops ends\nin fuel: comparing two 2 MB strings 1 ms (20 s before the meter), concatenating a 512 KiB string\nwith itself 1 ms (1.6 s before), ",{"type":9,"tag":22,"props":2849,"children":2851},{"className":2850},[],[2852],{"type":14,"value":2853},"unpack(t, 1, 250)",{"type":14,"value":2855}," 7 ms (28 ms before; a 7,000-value ",{"type":9,"tag":22,"props":2857,"children":2859},{"className":2858},[],[2860],{"type":14,"value":1377},{"type":14,"value":2862},"\ntook 0.7 s and is now refused), ",{"type":9,"tag":22,"props":2864,"children":2866},{"className":2865},[],[2867],{"type":14,"value":2868},"string.byte(s, 1, 250)",{"type":14,"value":2870}," 1 ms, a 7,000-value ",{"type":9,"tag":22,"props":2872,"children":2874},{"className":2873},[],[2875],{"type":14,"value":2152},{"type":14,"value":2877}," 0 ms (0.17 s\nbefore), ",{"type":9,"tag":22,"props":2879,"children":2881},{"className":2880},[],[2882],{"type":14,"value":1658},{"type":14,"value":2884}," of a 12,000-element order crafted against the old quicksort under 1 ms\n(0.4 s before), removing and inserting keys of a full 32,768-key table, which rehashes it each\ntime, 20 ms (9 s before), and the same beside a 32,768-slot array 2 ms (0.2 s before). A table\nwhose array part shrinks and grows again at each rehash is charged by the rule in \"Limits\", but\nits worst case was not measured. Some work\nis not charged: copying a C function's results (a 600-value ",{"type":9,"tag":22,"props":2886,"children":2888},{"className":2887},[],[2889],{"type":14,"value":2152},{"type":14,"value":2891}," through 95 nested ",{"type":9,"tag":22,"props":2893,"children":2895},{"className":2894},[],[2896],{"type":14,"value":1348},{"type":14,"value":2898},"\ncalls, 6 ms), the garbage collector, and long chains of keys that collide in a table. The game\nhas no clock (a clock would break determinism); the author check and the import check still time\nevery call and every load, and a script one call or top level of which takes more than 250 ms\n(or all its calls in one check more than 10 s) is reported and checked no further.",{"type":9,"tag":74,"props":2900,"children":2901},{},[2902,2907,2909,2915],{"type":9,"tag":113,"props":2903,"children":2904},{},[2905],{"type":14,"value":2906},"Hash collisions.",{"type":14,"value":2908}," Lua 5.1 hashes strings and numbers without a secret seed, so a script can\nbuild keys that all land in one chain of a table (or of the VM's string table). Each new key or\nlookup then walks the chain inside one instruction, and fuel does not see that work: it grows\nwith the square of the number of such keys. How long one call can hold the host this way is not\nmeasured yet. The author check reports such a script only after the call returns; it cannot stop\na call. The defence for now is the registry's review of the source. A fix needs a keyed hash in\nthe ",{"type":9,"tag":22,"props":2910,"children":2912},{"className":2911},[],[2913],{"type":14,"value":2914},"lua-src",{"type":14,"value":2916}," fork, and it is not done.",{"type":9,"tag":74,"props":2918,"children":2919},{},[2920,2925,2927,2932,2934,2940,2942,2948,2950,2955,2957,2962,2964,2970,2971,2977,2979,2985,2986,2992,2994,3000],{"type":9,"tag":113,"props":2921,"children":2922},{},[2923],{"type":14,"value":2924},"Numbers as text.",{"type":14,"value":2926}," ",{"type":9,"tag":22,"props":2928,"children":2930},{"className":2929},[],[2931],{"type":14,"value":2115},{"type":14,"value":2933}," and a number passed where a string is wanted (",{"type":9,"tag":22,"props":2935,"children":2937},{"className":2936},[],[2938],{"type":14,"value":2939},"string.upper(0.5)",{"type":14,"value":2941},") use\nthe C library's ",{"type":9,"tag":22,"props":2943,"children":2945},{"className":2944},[],[2946],{"type":14,"value":2947},"%.14g",{"type":14,"value":2949},", which prints every finite number alike on the supported platforms and\ndifferently for NaN and the infinities. Never concatenate a number that may not be finite.\n",{"type":9,"tag":22,"props":2951,"children":2953},{"className":2952},[],[2954],{"type":14,"value":1355},{"type":14,"value":2956}," returns ",{"type":9,"tag":22,"props":2958,"children":2960},{"className":2959},[],[2961],{"type":14,"value":473},{"type":14,"value":2963}," for a result that is not finite, but a non-finite number can still\ncome from arithmetic (",{"type":9,"tag":22,"props":2965,"children":2967},{"className":2966},[],[2968],{"type":14,"value":2969},"1\u002F0",{"type":14,"value":572},{"type":9,"tag":22,"props":2972,"children":2974},{"className":2973},[],[2975],{"type":14,"value":2976},"0\u002F0",{"type":14,"value":2978},"), from a string turned into a number by arithmetic or a\ncomparison (",{"type":9,"tag":22,"props":2980,"children":2982},{"className":2981},[],[2983],{"type":14,"value":2984},"\"inf\" + 0",{"type":14,"value":572},{"type":9,"tag":22,"props":2987,"children":2989},{"className":2988},[],[2990],{"type":14,"value":2991},"\"1e999\" + 0",{"type":14,"value":2993},"), and from a literal too large to hold: ",{"type":9,"tag":22,"props":2995,"children":2997},{"className":2996},[],[2998],{"type":14,"value":2999},"1e999",{"type":14,"value":3001}," in the\nsource is infinity.",{"type":9,"tag":74,"props":3003,"children":3004},{},[3005,3010],{"type":9,"tag":113,"props":3006,"children":3007},{},[3008],{"type":14,"value":3009},"Near the memory cap.",{"type":14,"value":3011}," A script that holds close to the 8 MiB can fail on one VM and not on\nanother: the VM that has run the fight so far holds garbage a VM built fresh after a host\nhandover does not. That is why the check warns at half the cap; stay well under it.",{"type":9,"tag":74,"props":3013,"children":3014},{},[3015,3020,3021,3026,3027,3032,3034,3039,3041,3047,3049,3055,3056,3062,3063,3069],{"type":9,"tag":113,"props":3016,"children":3017},{},[3018],{"type":14,"value":3019},"Two spellings of a number.",{"type":14,"value":2926},{"type":9,"tag":22,"props":3022,"children":3024},{"className":3023},[],[3025],{"type":14,"value":1362},{"type":14,"value":204},{"type":9,"tag":22,"props":3028,"children":3030},{"className":3029},[],[3031],{"type":14,"value":2275},{"type":14,"value":3033}," print the shortest text that reads\nback as the same number, ",{"type":9,"tag":22,"props":3035,"children":3037},{"className":3036},[],[3038],{"type":14,"value":2115},{"type":14,"value":3040}," prints 14 significant digits: ",{"type":9,"tag":22,"props":3042,"children":3044},{"className":3043},[],[3045],{"type":14,"value":3046},"tostring(0.1 + 0.2)",{"type":14,"value":3048}," is\n",{"type":9,"tag":22,"props":3050,"children":3052},{"className":3051},[],[3053],{"type":14,"value":3054},"0.30000000000000004",{"type":14,"value":572},{"type":9,"tag":22,"props":3057,"children":3059},{"className":3058},[],[3060],{"type":14,"value":3061},"\"\" .. (0.1 + 0.2)",{"type":14,"value":467},{"type":9,"tag":22,"props":3064,"children":3066},{"className":3065},[],[3067],{"type":14,"value":3068},"0.3",{"type":14,"value":3070},". Pick one and keep to it.",{"type":9,"tag":74,"props":3072,"children":3073},{},[3074,3085,3087,3092],{"type":9,"tag":113,"props":3075,"children":3076},{},[3077,3079,3084],{"type":14,"value":3078},"No ",{"type":9,"tag":22,"props":3080,"children":3082},{"className":3081},[],[3083],{"type":14,"value":1815},{"type":14,"value":398},{"type":14,"value":3086}," The operator is refused when the script loads; use ",{"type":9,"tag":22,"props":3088,"children":3090},{"className":3089},[],[3091],{"type":14,"value":1823},{"type":14,"value":398},{"type":9,"tag":74,"props":3094,"children":3095},{},[3096,3101],{"type":9,"tag":113,"props":3097,"children":3098},{},[3099],{"type":14,"value":3100},"Scripts run in bosses' kits only.",{"type":14,"value":3102}," A script in an elite's kit is refused at import; only boss\nkits and phases call scripts.",{"type":9,"tag":74,"props":3104,"children":3105},{},[3106,3111],{"type":9,"tag":113,"props":3107,"children":3108},{},[3109],{"type":14,"value":3110},"A script is code.",{"type":14,"value":3112}," It cannot leave its sandbox, but it runs on the player's computer, so the\nregistry's reviewers read it as source, and a review is no promise.",{"title":258,"searchDepth":3114,"depth":3114,"links":3115},3,[3116,3118,3119,3125,3130,3131,3132],{"id":65,"depth":3117,"text":68},2,{"id":169,"depth":3117,"text":172},{"id":374,"depth":3117,"text":377,"children":3120},[3121,3122,3123,3124],{"id":84,"depth":3114,"text":84},{"id":943,"depth":3114,"text":946},{"id":99,"depth":3114,"text":1021},{"id":92,"depth":3114,"text":1234},{"id":1291,"depth":3117,"text":1294,"children":3126},[3127,3128,3129],{"id":1827,"depth":3114,"text":1830},{"id":2295,"depth":3114,"text":2298},{"id":2406,"depth":3114,"text":2409},{"id":2489,"depth":3117,"text":2492},{"id":2723,"depth":3117,"text":2726},{"id":2792,"depth":3117,"text":2795},1795142597239]