# HG changeset patch # User Wuzzy # Date 1555510608 -7200 # Node ID d18970cf6ca2e228ab14190e533c2faf01c3fe70 # Parent 396f8204b9fb61a86e1a8aa7f2ab9783ddc62cbd Update other pages for new Lua documentation structure diff -r 396f8204b9fb -r d18970cf6ca2 EngineTestCases.wiki --- a/EngineTestCases.wiki Wed Apr 17 16:12:45 2019 +0200 +++ b/EngineTestCases.wiki Wed Apr 17 16:16:48 2019 +0200 @@ -33,5 +33,5 @@ These scripts are treated like ordinary scripts in Hedgewars (like misions or multiplayer scripts) but there's one important difference: You must call `EndLuaTest` when the test result (success or failure) -has be determined (see [LuaAPI]). +has be determined (see [LuaUtil]). diff -r 396f8204b9fb -r d18970cf6ca2 GearTypes.wiki --- a/GearTypes.wiki Wed Apr 17 16:12:45 2019 +0200 +++ b/GearTypes.wiki Wed Apr 17 16:16:48 2019 +0200 @@ -184,7 +184,7 @@ Hedgehogs also make heavy use of the gear state, see [States]. [GearMessages Gear messages] are used for controlling a hedgehogs movement and actions (e.g. moving left, attacking, jumping, etc.) -Please note that hedgehogs have also many other attributes and functions which are specific to hedgehogs only (like name, team name, hat, etc.). You can find many hedgehog-related functions in LuaAPI. +Please note that hedgehogs have also many other attributes and functions which are specific to hedgehogs only (like name, team name, hat, etc.). You can find many hedgehog-related functions in LuaGears. ==== `gtPortal` ==== A portal from the portable portal device. diff -r 396f8204b9fb -r d18970cf6ca2 LuaGuide.wiki --- a/LuaGuide.wiki Wed Apr 17 16:12:45 2019 +0200 +++ b/LuaGuide.wiki Wed Apr 17 16:16:48 2019 +0200 @@ -63,7 +63,7 @@ The two most important event handlers are `onGameInit` and `onAmmoStoreInit`. They are used instead of loading a game scheme and weapon scheme and in campaign missions or standalone missions `onGameInit` is also used to add teams and hogs. -First we have `onGameInit`. On this event we should add all game modifiers and team setup. If you are making a mission you only need to specify the things you want to change on this event, everything not changed will be set to default. The available game modifiers can be found here: [LuaAPI#onGameInit()] +First we have `onGameInit`. On this event we should add all game modifiers and team setup. If you are making a mission you only need to specify the things you want to change on this event, everything not changed will be set to default. The available game modifiers can be found here: [LuaEvents#onGameInit()] An example of setting up Barrel Mayhem in a style: {{{ @@ -82,9 +82,9 @@ AddTeam("Team", 0xFF0002, "Simple", "Island", "Default", "hedgewars") AddHog("Hedgehog", 0, 1, "NoHat") }}} -To be able to play you must add another team and hog that should have another team color (this team has `0xFF0002`) or if you only want one team add the game flag `gfOneClanMode`. Look into [LuaAPI] to see what the other parameters of `AddTeam` and `AddHog` are. +To be able to play you must add another team and hog that should have another team color (this team has `0xFF0002`) or if you only want one team add the game flag `gfOneClanMode`. Look into [LuaGameplay] and [LuaGears] to see what the other parameters of `AddTeam` and `AddHog` are. -In `onAmmoStoreInit` you set what weapons is available in the game. For every weapon run [LuaAPI#SetAmmo_(ammoType,_count,_probability,_delay,_numberInCrate) SetAmmo]. +In `onAmmoStoreInit` you set what weapons is available in the game. For every weapon, run `SetAmmo` (see [LuaGameplay]). This is used to set both starting weapons and weapons found in crates. Here is an example of the initiation of a training mission: @@ -118,7 +118,7 @@ Each gear has a [GearTypes gear type], for instance, a bazooka shell has the gear type of `gtShell`, a grenade has a gear type of `gtGrenade`, and so on. You will almost always need to check for the gear type with `GetGearType` in the `onGearAdd` function in order to do anything meaningful. -Gears also have a lot of various values to track their position, state, etc. These can be accessed and written to with several “getter” and “setter” functions like `GetPos`, `GetHealth`, `SetTag`, etc. See [LuaAPI] for a full list. In Hedgewars, the gear values and some variable names do not always really mean what they seem to be, their concrete meaning often depends on the actual gear type. For instance, using `GetHealth(h)` on a hedgehog gear (gear type: `gtHedgehog`) will return its health (obviously). Less obviously, using `GetHealth` on a flying saucer gear (gear type: `gtJetpack`) will return its amount of fuel. +Gears also have a lot of various values to track their position, state, etc. These can be accessed and written to with several “getter” and “setter” functions like `GetPos`, `GetHealth`, `SetTag`, etc. See [LuaGears] for a full list. In Hedgewars, the gear values and some variable names do not always really mean what they seem to be, their concrete meaning often depends on the actual gear type. For instance, using `GetHealth(h)` on a hedgehog gear (gear type: `gtHedgehog`) will return its health (obviously). Less obviously, using `GetHealth` on a flying saucer gear (gear type: `gtJetpack`) will return its amount of fuel. To learn all the gory detaily about gears, see [GearTypes]. @@ -138,7 +138,7 @@ Continue with the following pages to learn more: - * [LuaAPI] contains a reference of most available functions and global variables + * [LuaAPI] is the central landing page for everything about the Lua API * [Missions] for a more in-depth guide on how to create missions * [LuaLibraries] contains information about “libraries”, that is, extra scripts you can include for even more functions. One common library is `Locale` for making a mission translatable - * [GearTypes] contains the list of all gear types, along with an explanation of how the gears and their values work \ No newline at end of file + * [GearTypes] contains the list of all gear types, along with an explanation of how the gears and their values work diff -r 396f8204b9fb -r d18970cf6ca2 LuaUtil.wiki --- a/LuaUtil.wiki Wed Apr 17 16:12:45 2019 +0200 +++ b/LuaUtil.wiki Wed Apr 17 16:16:48 2019 +0200 @@ -56,6 +56,30 @@ DeclareAchievement("height reached", teamname, "ClimbHome", -score) Records a team's best height in !ClimbHome. +=== !ParseCommand(string) === +Makes the game client parse and execute the specified internal game engine command. + +The available commands depend on the current engine protocol version. The *engine protocol can (and will) change* between releases. + +*Important*: If you use `ParseCommand` to overcome a shortcoming in our Lua API (e.g. a missing function), please make sure to [https://issues.hedgewars.org/enter_bug.cgi report the issue]. + +With your report we can fix the shortcoming in future releases. We will try to remove the reliance on `ParseCommand` as good as possible. This will allow scripts to use the previously missing feature in a way that won’t break! + +There are many available commands, but actual use in scripting is rare, and even then it's discouraged for long-term use. As of 0.9.24, the only command used in official scripts is: + + * `"draw "`: Draws a hand-drawn map. `MapGen` must be `mgDrawn` for this to work. `` is a string which must follow the format specified in [DrawnMapFormat] + +Moreover, the control action names as listed in [ConfigurationFiles] (under “Binds”) can be used. Note we will eventually try to remove all `ParseCommand`s in the official scripts. + +=== !EndLuaTest(success) === +This function is used by the Hedgewars developers in testing scripts in order to test the game engine. The testing scripts can be found in the Hedgewars source code under `tests/lua`. This function is useless for anything else. + +Calling this function ends an engine test and reports a test result. + +`success` is either one of `TEST_SUCCESSFUL` to report a successful test or `TEST_FAILED` for a failed test. + +See [EngineTestCases] to learn more about testing the engine. + == Library functions == For more utility functions, you might want to check out the [LuaLibraries Lua libraries]. diff -r 396f8204b9fb -r d18970cf6ca2 PresetMaps.wiki --- a/PresetMaps.wiki Wed Apr 17 16:12:45 2019 +0200 +++ b/PresetMaps.wiki Wed Apr 17 16:16:48 2019 +0200 @@ -49,7 +49,7 @@ The name of the *.hwp* file should be the same with the mission script. -In the mission script’s `onGameInit`, map should be set to *some_name*. See [LuaAPI] for more about `onGameInit`. +In the mission script’s `onGameInit`, map should be set to *some_name*. See [LuaEvents] for more about `onGameInit`. ----