# HG changeset patch # User Wuzzy # Date 1555504969 -3600 # Node ID b25684cd9837e7d185e338d41d03c58b0a375ddd # Parent 503aa47f3aafe751e0c47a8c34a4ff760e6e704b LuaGears: Restructure functions diff -r 503aa47f3aaf -r b25684cd9837 LuaGears.wiki --- a/LuaGears.wiki Wed Apr 17 13:34:00 2019 +0100 +++ b/LuaGears.wiki Wed Apr 17 13:42:49 2019 +0100 @@ -37,6 +37,41 @@ local vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) +=== !AddHog(hogname, botlevel, health, hat) === +Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat. + +`botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team. + +Returns the gear ID. + +*Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game. + +Example: + + local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player + SetGearPosition(player, 1500, 1000) + -- hint: If you don't call `SetGearPosition`, the hog spawns randomly + +=== !AddMissionHog(health) (0.9.25) === +Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`. + +The name and hat match the player's team definition. The hog is also always player-controlled. + +Examples: +-- Add player team with 3 hogs +AddMissionTeam(-1) +AddMissionHog(100) +AddMissionHog(100) +AddMissionHog(100) + +-- You can also mix mission hogs with “hardcoded” hogs. +-- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat. +AddMissionTeam(-2) +AddMissionHog(100) +AddMissionHog(100) +AddHog("My Hardcoded Hog", 0, 100, "NoHat") + + === !SpawnHealthCrate(x, y, [, health]) === Spawns a health crate at the specified position. If `x` and `y` are set to 0, the crate will spawn on a random position (but always on land). Set `health` for the initial health contained in the health crate. If not set, the default health (`HealthCaseAmount`) is used. Do not use a negative value for `health`. @@ -80,41 +115,6 @@ === !SpawnFakeUtilityCrate(x, y, explode, poison) === Same as `SpawnFakeAmmoCrate`, except the crate will look like an utility crate. -=== !AddHog(hogname, botlevel, health, hat) === -Adds a new hedgehog for current team (last created one with the `AddTeam` function), with a bot level, an initial health and a hat. - -`botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot, where `1` is strongest and `5` is the weakest. Note that this is the reverse order of how the bot level is displayed in the game. Note that mixing human-controlled and computer-controlled hedgehogs in the same team is not permitted, but it is permitted to use different computer difficulty levels in the same team. - -Returns the gear ID. - -*Warning*: This only works in singleplayer mode (e.g. missions). Also, Hedgewars only supports up to 64 hedgehogs in a game. - -Example: - - local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player - SetGearPosition(player, 1500, 1000) - -- hint: If you don't call `SetGearPosition`, the hog spawns randomly - -=== !AddMissionHog(health) (0.9.25) === -Add a hedgehog for the current team, using the player-chosen team identity when playing in singleplayer missions. The “current team” is the last team that was added with `AddMissionTeam` or `AddTeam`. - -The name and hat match the player's team definition. The hog is also always player-controlled. - -Examples: --- Add player team with 3 hogs -AddMissionTeam(-1) -AddMissionHog(100) -AddMissionHog(100) -AddMissionHog(100) - --- You can also mix mission hogs with “hardcoded” hogs. --- This adds a player team with 2 hogs taken from the player team and 1 hog with a hardcoded name, botlevel and hat. -AddMissionTeam(-2) -AddMissionHog(100) -AddMissionHog(100) -AddHog("My Hardcoded Hog", 0, 100, "NoHat") - - == Functions to get gear properties == === !GetGearType(gearUid) === @@ -310,25 +310,25 @@ local X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale = GetVisualGearValues(vgUid) -== Functions to modify gears == +== Functions to change position and velocity == +=== !SetGearPosition(gearUid, x, y) === +Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. + +=== !SetGearVelocity(gearUid, dx, dy) === +Gives the specified gear the velocity of `dx`, `dy`. -=== !HideHog(gearUid) === -Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Since 0.9.23, returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden). +=== CopyPV(gearUid, gearUid) === +This sets the position and velocity of the second gear to the first one. -Example: +=== !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(...) - HideHog(gear) -- Hide the newly created gear. - -=== !RestoreHog(gearUid) === -Restores a previously hidden hedgehog. Nothing happens if the hedgehog does not exist or is not hidden. + FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH -Example: - - gear = AddGear(...) - HideHog(gear) -- Hide the newly created gear. - RestoreHog(gear) -- Restore the newly hidden gear. - +== Functions to modify gears == === !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. If `gearUid` is invalid or the gear does not exist, nothing happens. @@ -379,46 +379,6 @@ -- set the tint of a visual gear to bright red. SetVisualGearValues(circleUid, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff0000ff) - -=== !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. `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: - -|| *Value of `manner`* || *Looks* || -|| `SAY_THINK` || Thought bubble || -|| `SAY_SAY` || Speech bubble || -|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) || - -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. || -|| `1` || The bubble is drawn translucent. || -|| `2` || The bubble is drawn fully opaque. || - -Examples: - -HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …” -HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.” -HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!” -=== !HogTurnLeft(gearUid, boolean) === -Faces the specified hog left or right. - -Example: - - HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left - HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right -=== !SetGearPosition(gearUid, x, y) === -Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. - === SetGearCollisionMask(gearUid, mask) === Set the collision mask of the given gear with `gearUid`. The collision mask defines with which gears and terrain types the gear can collide. @@ -451,9 +411,6 @@ [https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112] -=== !SetGearVelocity(gearUid, dx, dy) === -Gives the specified gear the velocity of `dx`, `dy`. - === !SetFlightTime(gearUid, flighttime) === Sets the `FlightTime` of the given gear to `flighttime`. The meaning of `FlightTime` is explained in the section `GetFlightTime`. @@ -526,12 +483,6 @@ end end -=== CopyPV(gearUid, gearUid) === -This sets the position and velocity of the second gear to the first one. - -=== !FollowGear(gearUid) === -Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears. - === !SetHogName(gearUid, name) === Sets the name of the specified hedgehog gear. @@ -541,6 +492,14 @@ === !SetHogHat(gearUid, hat) === Sets the hat of the specified hedgehog gear. +=== !HogTurnLeft(gearUid, boolean) === +Faces the specified hog left or right. + +Example: + + HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left + HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right + === !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. @@ -605,6 +564,50 @@ === !SetGearPos(gearUid, value) === Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information. +=== !HideHog(gearUid) === +Removes a hedgehog from the map. The hidden hedgehog can be restored with `RestoreHog(gearUid)`. Since 0.9.23, returns `true` on success and `false` on failure (if gear does not exist / hog is already hidden). + +Example: + + gear = AddGear(...) + HideHog(gear) -- Hide the newly created gear. + +=== !RestoreHog(gearUid) === +Restores a previously hidden hedgehog. Nothing happens if the hedgehog does not exist or is not hidden. + +Example: + + gear = AddGear(...) + HideHog(gear) -- Hide the newly created gear. + RestoreHog(gear) -- Restore the newly hidden gear. + +== Functions for gear actions == +=== HogSay(gearUid, text, manner [,vgState]) === +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: + +|| *Value of `manner`* || *Looks* || +|| `SAY_THINK` || Thought bubble || +|| `SAY_SAY` || Speech bubble || +|| `SAY_SHOUT` || Exclamatory bubble (denotes shouting) || + +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. || +|| `1` || The bubble is drawn translucent. || +|| `2` || The bubble is drawn fully opaque. || + +Examples: + +HogSay(CurrentHedgehog, "I wonder what to do …", SAY_THINK) -- thought bubble with text “I wonder what to do …” +HogSay(CurrentHedgehog, "I'm hungry.", SAY_SAY) -- speech bubble with text “I’m hungry.” +HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text “I smell CAKE!” + +=== !FollowGear(gearUid) === +Makes the game client follow the specifiec gear (if it exists). Does not work for visual gears. + == Functions to delete gears == === !DeleteGear(gearUid) === Deletes a gear. If the specified gear did not exist, nothing happens.