# HG changeset patch # User Wuzzy # Date 1519138671 0 # Node ID 4ac63a5c0184bc1a9c21dd8f6fb1761d3a8d299c # Parent 550b1afc9300f30ea0920ed53b4ce852a14c4320 LuaAPI: Remove most pre-0.9.23 version number mentions as very old diff -r 550b1afc9300 -r 4ac63a5c0184 LuaAPI.wiki --- a/LuaAPI.wiki Tue Feb 20 14:51:05 2018 +0000 +++ b/LuaAPI.wiki Tue Feb 20 14:57:51 2018 +0000 @@ -196,12 +196,12 @@ Can be used to show the mission and for more setup, for example initial target spawning. -=== onPreviewInit() (0.9.21) === +=== onPreviewInit() === This function is called when the map preview in the frontend is initialized. This happens when the script is selected or you change a map generator parameter. It is useful for scripts which create their own maps (see `AddPoint` and `FlushPoints`). If you create a map in this function, a preview will be generated from this map and is exposed to the frontend. -=== onParameters() (0.9.21) === +=== onParameters() === This function is called when the script parameters (as specified in the game scheme) become available. The script parameter string is stored in the global variable `ScriptParam`. Please note that it is normally not safe to call many of the other functions inside this function, this function is called very early in the game, only use this to initialize variables and other internal stuff like that. @@ -228,7 +228,7 @@ Because this function is called *before* victories are checked, this is useful to set up your victory conditions here. -=== onSuddenDeath() (0.9.22) === +=== onSuddenDeath() === This function is called on the start of Sudden Death. === onGearAdd(gearUid) === @@ -269,10 +269,10 @@ These indexes can be used to look up details of the clan/team/hedgehog prior to gear creation. Routines to do these lookups will be created as needed. If you add this hook, the expectation is that you will call SetAmmo appropriately. Any values from `onAmmoStoreInit` are ignored. -=== onGearWaterSkip(gear) (0.9.21) === +=== onGearWaterSkip(gear) === This function is called when the gear `gear` skips over water. -=== onScreenResize() (0.9.16) === +=== onScreenResize() === This function is called when you resize the screen. Useful place to put a redraw function for any `vgtHealthTags` you're using. === onAttack() === @@ -357,23 +357,23 @@ For example, it is called right after a bazooka is fired, when both shots of a shotgun have been fired, when extra time is used, or when all 4 shots of a portable portal device have been fired. It is also called when using a multi-shot ammo has been aborted by changing the weapon selection mid-way, because this still uses up the ammo. -=== onHogHide(gearUid) (0.9.16) === +=== onHogHide(gearUid) === This function is called when a hedgehog with the gear ID `gearUid` is hidden (removed from the map). -=== onHogRestore(gearUid) (0.9.16) === +=== onHogRestore(gearUid) === This function is called when a hedgehog with the specified gear ID `gearUid` is restored (unhidden). -=== onSpritePlacement(spriteId, centerX, centerY) (0.9.21) === +=== onSpritePlacement(spriteId, centerX, centerY) === This function is called when a [Sprites Sprite] has been placed. `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite. -=== onGirderPlacement(frameIdx, centerX, centerY) (0.9.21) === +=== onGirderPlacement(frameIdx, centerX, centerY) === This function is called when a girder has been placed. `frameIdx` is used for the length and orientation of the girder. The possible values are explained in `PlaceGirder`. `centerX` and `centerY` are the coordinates of the girder’s center. -=== onRubberPlacement(frameIdx, centerX, centerY) (0.9.21) === +=== onRubberPlacement(frameIdx, centerX, centerY) === This function is called when a rubber has been placed. `frameIdx` is used for the rubber orientation. The possible values are explained in `PlaceRubber`. `centerX` and `centerY` are the coordinates of the rubber’s center. @@ -514,19 +514,19 @@ === !GetHogHat(gearUid) === Returns the hat of the specified hedgehog gear. -=== !GetHogFlag(gearUid) (0.9.22) === +=== !GetHogFlag(gearUid) === Returns the name of the flag of the team of the specified hedgehog gear. === !GetHogFort(gearUid) (0.9.23) === Returns the name of the fort of the team of the specified hedgehog gear. -=== !GetHogGrave(gearUid) (0.9.22) === +=== !GetHogGrave(gearUid) === Returns the name of the grave of the team of the specified hedgehog gear. -=== !GetHogVoicepack(gearUid) (0.9.22) === +=== !GetHogVoicepack(gearUid) === Returns the name of the voicepack of the team of the specified hedgehog gear. -=== !GetAmmoCount(gearUid, ammoType) (0.9.16) === +=== !GetAmmoCount(gearUid, ammoType) === Returns the ammo count of the specified ammo type for the specified hedgehog gear. === !IsHogLocal(gearUid) (0.9.23) === @@ -534,7 +534,7 @@ This is perfect to hide certain captions like weapon messages from enemy eyes. -=== !GetGearTarget(gearUid, x, y) (0.9.16) === +=== !GetGearTarget(gearUid, x, y) === Returns the x and y coordinate of target-based weapons/utilities. Note:: This can’t be used in `onGearAdd()` but must be called after gear creation. @@ -610,25 +610,23 @@ *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that. -=== !GetGearValues(gearUid) (0.9.22) === +=== !GetGearValues(gearUid) === This returns a bunch of values associated with the gear, their meaning is often depending on the gear type and many values might be unused for certain gear types. This is returned (all variables are integers): `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom` -Boom is 0.9.23+ - A rough description of some of the parameters: * `Radius`: Effect or collision radius, most of the time * `ImpactSound`: Sound it makes on a collision (see [Sounds]) * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format. - * `Boom`: Used by most gears to determine the damage dealt. (0.9.23+) + * `Boom`: Used by most gears to determine the damage dealt. Example: --- Get all values in a single line of code (omit Boom in 0.9.22) : +-- Get all values in a single line of code: local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(myGear) @@ -688,8 +686,8 @@ vgear = AddVisualGear(...) DeleteVisualGear(vgear) -- Delete the newly created visual gear. -=== !SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom) (0.9.22) === -Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values. Boom is 0.9.23+. +=== !SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom) === +Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values. Set `nil` for each value you do not want to change. @@ -734,15 +732,15 @@ SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff) -=== !FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16) === -Finds a place for the specified gear between x=`left` and x=`right` and places it there. 0.9.16 adds an optional fifth parameter, `tryHarder`. Setting to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other. +=== !FindPlace(gearUid, fall, left, right[, tryHarder]) === +Finds a place for the specified gear between x=`left` and x=`right` and places it there. `tryHarder` is optional, setting it to `true`/`false` will determine whether the engine attempts to make additional passes, even attempting to place gears on top of each other. Example: gear = AddGear(...) FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH === !HogSay(gearUid, text, manner [,vgState]) === -Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. In 0.9.21 `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise. +Makes the specified gear say, think, or shout some text in a comic-style speech or thought bubble. `gearUid` is _not_ limited to hedgehogs, altough the function name suggests otherwise. The `manner` parameter specifies the type of the bubble and can have one of these values: @@ -751,7 +749,7 @@ || `SAY_SAY` || Speech bubble || || `SAY_SHOUT` || Exclamatory bubble (denotes shouting) || -As of 0.9.21, there is a optional 4th parameter `vgState`, it defines wheather the speechbubble is drawn fully opaque or semi-transparent. The value `0` is the default value. +There is a optional 4th parameter `vgState`, it defines wheather the speechbubble is drawn fully opaque or semi-transparent. The value `0` is the default value. || *Value of `vgState`* || *Effect* || || `0` || If the specified gear is a hedgehog, and it’s the turn of the hedgehog’s team, the bubble is drawn fully opaque.
If the gear is a hedgehog, and it’s another team’s turn, the bubble is drawn translucent.
If the gear is not a hedgehog, the bubble is drawn fully opaque. || @@ -878,8 +876,6 @@ end end -*Historic note*: prior to the ice-gun release, 0.9.19 (commit r10a0a31804f3) `effectState` was of boolean type (`true` = effect enabled, `false` = effect disabled) - === CopyPV(gearUid, gearUid) === This sets the position and velocity of the second gear to the first one. @@ -902,14 +898,14 @@ SetWeapon(amBazooka) -- select the Bazooka. -=== !SetNextWeapon() (0.9.21) === +=== !SetNextWeapon() === This function makes the current hedgehog switch to the next weapon in list of available weapons. It can be used for example in trainings to pre-select a weapon. === !SetHogHat(gearUid, hat) === Sets the hat of the specified hedgehog gear. -=== !SetGearTarget(gearUid, x, y) (0.9.16) === +=== !SetGearTarget(gearUid, x, y) === Sets the x and y coordinate of target-based weapons/utilities. *Note*: This can’t be used in onGearAdd() but must be called after gear creation. @@ -970,7 +966,7 @@ SetGearAIHints(uselessHog, aihDoesntMatter) -- This makes AI hogs stop caring about attacking uselessHog -=== !SetGearPos(gearUid, value) (0.9.18-dev) === +=== !SetGearPos(gearUid, value) === Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information. == Gameplay functions == @@ -1007,7 +1003,7 @@ ==== !GetWind() (0.9.24) ==== Returns current wind, expressed as a floating point number between -100 to 100 inclusive. Note there may be rounding errors. -==== !SetMaxBuildDistance(distInPx) (0.9.22) ==== +==== !SetMaxBuildDistance(distInPx) ==== Sets the maximum building distance for of girders and rubber bands in pixels to `distInPx`. If `distInPx` is `0`, the limit is disabled. If called without arguments, the distance will be reset to the default value. ==== `EndTurn([noTaunts])` (0.9.23) ==== @@ -1061,7 +1057,7 @@ -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.") -==== !AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) ==== +==== !AddAmmo(gearUid, ammoType, ammoCount) ==== Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. `ammoCount` is an optional parameter. If this is set, the ammo will **not** be added, but instead set to `ammoCount`. A value of 0 will remove the weapon, a value of 100 will give infinite ammo. ==== !GetAmmoName(ammoType [, ignoreOverwrite ]) (0.9.23) ==== @@ -1071,10 +1067,10 @@ ==== !MapHasBorder() ==== Returns `true`/`false` if the map has a border or not. -==== !TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) ==== +==== !TestRectForObstacle(x1, y1, x2, y2, landOnly) ==== Checks the rectangle between the given coordinates for possible collisions. Set `landOnly` to `true` if you don’t want to check for collisions with gears (hedgehogs, etc.). -==== !PlaceGirder(x, y, frameIdx) (0.9.16) ==== +==== !PlaceGirder(x, y, frameIdx) ==== Attempts to place a girder with centre points `x`, `y` and a certain length and orientation, specified by `frameIdx`. The girder can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure. These are the accepted values for `frameIdx`: @@ -1114,7 +1110,7 @@ * `sprSpeechCorner` * `sprSpeechEdge` * `sprSpeechTail` - * `sprTargetBee` (since 0.9.23) + * `sprTargetBee` * `sprThoughtCorner` * `sprThoughtEdge` * `sprThoughtTail` @@ -1150,22 +1146,22 @@ EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible) -- Removes indestructibility from a rubber band sprite at (2836, 634). The frameIdx 1 is for the decreasing right rubber band. -==== !AddPoint(x, y [, width [, erase] ]) (0.9.21) ==== +==== !AddPoint(x, y [, width [, erase] ]) ==== This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”. The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff). This function must be called within `onGameInit`, where `MapGen` has been set to `mgDrawn`. You also should call `FlushPoints` when you are finished with drawing. -==== !FlushPoints() (0.9.21) ==== +==== !FlushPoints() ==== Makes sure that all the points/lines specified using `AddPoint` are actually applied to the map. This function must be called within `onGameInit`. === Current hedgehog === -==== !GetCurAmmoType() (0.9.16) ==== +==== !GetCurAmmoType() ==== Returns the currently selected [AmmoTypes Ammo Type]. -==== !SwitchHog(gearUid) (0.9.16) ==== +==== !SwitchHog(gearUid) ==== This function will switch to the hedgehog with the specifiedd `gearUid`. ==== !SetInputMask(mask) ==== @@ -1294,7 +1290,7 @@ `text` uses some special characters for formatting: `|` is used for a line break, and everything written before and including a `:` in a line is written in a lighter color. -As of version 0.9.22, `icon` accepts the following values: +`icon` accepts the following values: || *`icon`* || *What is shown* || || _negative number_ || Icon of an ammo type. It is specified as the negative of an ammo type constant (see [AmmoTypes]), i.e. `-amBazooka` for the bazooka icon. || @@ -1307,7 +1303,7 @@ || `6` || Health crate || || `7` || Ammo crate || || `8` || Barrel || -|| `9` || Dud mine (0.9.23) || +|| `9` || Dud mine || Example: @@ -1347,7 +1343,7 @@ == Stats functions == -=== !SendStat(TStatInfoType, statMessage[, teamName]) (0.9.20) === +=== !SendStat(TStatInfoType, statMessage[, teamName]) === This function allows to change the details of the stats screen seen after the end of a game. @@ -1409,7 +1405,7 @@ * Calling just `EndGame()` won’t produce any stats. * If one would like to produce a custom graph see also `SendHealthStatsOff()`. -=== !SendHealthStatsOff() (0.9.20) === +=== !SendHealthStatsOff() === Prevents the engine of sending health stats to the frontend. If any health stats haven’t been sent before this will cause the health graph to the stats page to be hidden. Use this function in the Lua scripts to produce custom graphs by calling it inside `onGameStart()` and using the `SendStat()` function.