changeset 416 | 5aa55bbe4b73 |
parent 415 | 70961d4eef05 |
child 417 | f4b7962d39cd |
415:70961d4eef05 | 416:5aa55bbe4b73 |
---|---|
15 === About this wiki page === |
15 === About this wiki page === |
16 This page tends to become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
16 This page tends to become outdated. For a list of undocumented functions, see [http://hw.ercatec.net/docs/lua_wiki_check.php]. |
17 |
17 |
18 |
18 |
19 === Tutorial missions === |
19 === Tutorial missions === |
20 Tutorial missions are located within text files inside "share/hedgewars/Data/Missions/Training". The game will list all files with the lua extension inside this directory in the Training selection screen. You'll find some premade example scripts within this directory that contain several comments on the script lines and what they do. |
20 Tutorial missions are located within text files inside "share/hedgewars/Data/Missions/Training". The game will list all files with the lua extension inside this directory in the Training selection screen. You'll find some premade example scripts within this directory that contain several comments on the script lines and what they do./ |
21 |
21 |
22 |
22 |
23 === Special maps === |
23 === Special maps === |
24 In addition to tutorial missions predrawn maps (maps not created using the random map creator) may contain a single lua script file named "map.lua". If it's there it will be used once the map is played. This way it's possible to play maps alone or over the internet using custom goals. Maps containing lua scripts will be listed with a "Mission:" prefix in map selection. |
24 In addition to tutorial missions predrawn maps (maps not created using the random map creator) may contain a single lua script file named "map.lua". If it's there it will be used once the map is played. This way it's possible to play maps alone or over the internet using custom goals. Maps containing lua scripts will be listed with a "Mission:" prefix in map selection. |
25 |
25 |
129 <blockquote>This function is called when a gear is damaged. |
129 <blockquote>This function is called when a gear is damaged. |
130 </blockquote> |
130 </blockquote> |
131 |
131 |
132 Example: |
132 Example: |
133 |
133 |
134 <code lang="lua"> function onGearDamage(gear, damage) |
134 <code language="lua"> function onGearDamage(gear, damage) |
135 if (GetGearType(gear) == gtHedgehog) then |
135 if (GetGearType(gear) == gtHedgehog) then |
136 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
136 -- adds a message saying, e.g. "Hoggy H took 25 points of damage" |
137 AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
137 AddCaption(GetHogName(gear) .. ' took ' .. damage .. ' points of damage') |
138 end |
138 end |
139 end</code> |
139 end</code> |
298 |
298 |
299 <blockquote>This creates a new gear at position x,y (measured from top left) of kind gearType (see [GearTypes Gear Types]). The initial velocities are dx and dy. All arguments are numbers. The function returns the uid of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States]. |
299 <blockquote>This creates a new gear at position x,y (measured from top left) of kind gearType (see [GearTypes Gear Types]). The initial velocities are dx and dy. All arguments are numbers. The function returns the uid of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States]. |
300 </blockquote> |
300 </blockquote> |
301 Example: |
301 Example: |
302 |
302 |
303 <code lang="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
303 <code language="lua"> local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
304 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
304 FindPlace(gear, true, 0, LAND_WIDTH)</code> |
305 |
305 |
306 === <tt>!AddVisualGear(x, y, visualGearType, state, critical)</tt> === |
306 === <tt>!AddVisualGear(x, y, visualGearType, state, critical)</tt> === |
307 |
307 |
308 <blockquote>This creates a new visual gear at position x,y (measured from top left) of kind visualGearType (see [VisualGearTypes Visual Gear Types]). The function returns the uid of the visual gear created. Set critical to true if the visual gear is crucial to game play. False if it is just an effect, and can be skipped when in fastforward (such as when joining a room). A critical visual gear will always be created, a non-critical one may fail. Most visual gears delete themselves. |
308 <blockquote>This creates a new visual gear at position x,y (measured from top left) of kind visualGearType (see [VisualGearTypes Visual Gear Types]). The function returns the uid of the visual gear created. Set critical to true if the visual gear is crucial to game play. False if it is just an effect, and can be skipped when in fastforward (such as when joining a room). A critical visual gear will always be created, a non-critical one may fail. Most visual gears delete themselves. |
309 </blockquote> |
309 </blockquote> |
310 Example: |
310 Example: |
311 |
311 |
312 <code lang="lua"> -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created. |
312 <code language="lua"> -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created. |
313 vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) |
313 vgear = AddVisualGear(1000, 1000, vgtExplosion, 0, false) |
314 </code> |
314 </code> |
315 |
315 |
316 === <tt>!SpawnHealthCrate(x, y)</tt> === |
316 === <tt>!SpawnHealthCrate(x, y)</tt> === |
317 |
317 |
321 |
321 |
322 <blockquote>Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). Because by default settings the number of ammo in crates is zero it has to be increased to at least one with SetAmmo first, see the example: |
322 <blockquote>Spawns an ammo crate at the specified position with content of ammoType (see [AmmoTypes Ammo Types]). Because by default settings the number of ammo in crates is zero it has to be increased to at least one with SetAmmo first, see the example: |
323 </blockquote> |
323 </blockquote> |
324 Example: |
324 Example: |
325 |
325 |
326 <code lang="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- see below |
326 <code language="lua"> SetAmmo(amGrenade, 0, 0, 0, 1) -- see below |
327 SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map</code> |
327 SpawnAmmoCrate(0, 0, amGrenade) -- x=y=0 means random position on map</code> |
328 === <tt>!SpawnUtilityCrate(x, y, ammoType)</tt> === |
328 === <tt>!SpawnUtilityCrate(x, y, ammoType)</tt> === |
329 |
329 |
330 <blockquote>Spawns an utility crate at specified position with content of ammoType. |
330 <blockquote>Spawns an utility crate at specified position with content of ammoType. |
331 </blockquote> |
331 </blockquote> |
332 Example: |
332 Example: |
333 |
333 |
334 <code lang="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
334 <code language="lua"> SetAmmo(amLaserSight, 0, 0, 0, 1) |
335 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
335 SpawnUtilityCrate(0, 0, amLaserSight)</code> |
336 |
336 |
337 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
337 === <tt>!SpawnFakeAmmoCrate(x, y, explode, poison) </tt> === |
338 |
338 |
339 Spawns a crate which looks exactly like a real ammo crate but contains not any ammo. It can be use useful for scripted events or to create a trap. |
339 Spawns a crate which looks exactly like a real ammo crate but contains not any ammo. It can be use useful for scripted events or to create a trap. |
341 If `explode` is `true`, the crate will explode when collected. |
341 If `explode` is `true`, the crate will explode when collected. |
342 If `poison` is `true`, the collector will be poisoned. |
342 If `poison` is `true`, the collector will be poisoned. |
343 |
343 |
344 Example: |
344 Example: |
345 |
345 |
346 <code lang="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
346 <code language="lua">SpawnFakeAmmoCrate(500, 432, false, false) -- Spawns a fake ammo crate at the coordinates (500, 434) without explosion and poison. |
347 </code> |
347 </code> |
348 |
348 |
349 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
349 === <tt>!SpawnFakeHealthCrate(x, y, explode, poison) </tt> === |
350 |
350 |
351 Spawns a crate which looks exactly like a real health crate but it will not heal the player. It can be use useful for scripted events or to create a trap. |
351 Spawns a crate which looks exactly like a real health crate but it will not heal the player. It can be use useful for scripted events or to create a trap. |
367 |
367 |
368 Notice: This works only for singleplayers training missions for now and will desync multiplayer games. |
368 Notice: This works only for singleplayers training missions for now and will desync multiplayer games. |
369 |
369 |
370 Example: |
370 Example: |
371 |
371 |
372 <code lang="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
372 <code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
373 SetGearPosition(player, 1500, 1000)</code> |
373 SetGearPosition(player, 1500, 1000)</code> |
374 == Functions to get gear properties == |
374 == Functions to get gear properties == |
375 |
375 |
376 === <tt>!GetGearType(gearUid)</tt> === |
376 === <tt>!GetGearType(gearUid)</tt> === |
377 |
377 |
489 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
489 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter. State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour. |
490 Most visual gears require little to no modification of parameters. |
490 Most visual gears require little to no modification of parameters. |
491 </blockquote> |
491 </blockquote> |
492 Example: |
492 Example: |
493 |
493 |
494 <code lang="lua"> GetVisualGearValues(vgUid) -- return visual gear values |
494 <code language="lua"> GetVisualGearValues(vgUid) -- return visual gear values |
495 </code> |
495 </code> |
496 |
496 |
497 == Functions to modify gears == |
497 == Functions to modify gears == |
498 |
498 |
499 === <tt>!HideHog(gearUid)</tt> === |
499 === <tt>!HideHog(gearUid)</tt> === |
500 |
500 |
501 <blockquote>Removes a hedgehog from the map. The hidden hedgehog can be restored with !RestoreHog(gearUid). The current hedgehog cannot be hidden!</blockquote> |
501 <blockquote>Removes a hedgehog from the map. The hidden hedgehog can be restored with !RestoreHog(gearUid). The current hedgehog cannot be hidden!</blockquote> |
502 Example: |
502 Example: |
503 |
503 |
504 <code lang="lua"> gear = AddGear(...) |
504 <code language="lua"> gear = AddGear(...) |
505 HideHog(gear) -- Hide the newly created gear.</code> |
505 HideHog(gear) -- Hide the newly created gear.</code> |
506 |
506 |
507 === <tt>!RestoreHog(gearUid)</tt> === |
507 === <tt>!RestoreHog(gearUid)</tt> === |
508 |
508 |
509 <blockquote>Restores a previously hidden hedgehog.</blockquote> |
509 <blockquote>Restores a previously hidden hedgehog.</blockquote> |
510 Example: |
510 Example: |
511 |
511 |
512 <code lang="lua"> gear = AddGear(...) |
512 <code language="lua"> gear = AddGear(...) |
513 HideHog(gear) -- Hide the newly created gear. |
513 HideHog(gear) -- Hide the newly created gear. |
514 RestoreHog(gear) -- Restore the newly hidden gear.</code> |
514 RestoreHog(gear) -- Restore the newly hidden gear.</code> |
515 |
515 |
516 === <tt>!DeleteGear(gearUid)</tt> === |
516 === <tt>!DeleteGear(gearUid)</tt> === |
517 |
517 |
518 <blockquote>Deletes a Gear</blockquote> |
518 <blockquote>Deletes a Gear</blockquote> |
519 Example: |
519 Example: |
520 |
520 |
521 <code lang="lua"> gear = AddGear(...) |
521 <code language="lua"> gear = AddGear(...) |
522 DeleteGear(gear) -- Delete the newly created gear.</code> |
522 DeleteGear(gear) -- Delete the newly created gear.</code> |
523 |
523 |
524 === <tt>!DeleteVisualGear(vgUid)</tt> === |
524 === <tt>!DeleteVisualGear(vgUid)</tt> === |
525 |
525 |
526 <blockquote>Deletes a Visual Gear. Note, most visual gears delete themselves.</blockquote> |
526 <blockquote>Deletes a Visual Gear. Note, most visual gears delete themselves.</blockquote> |
527 Example: |
527 Example: |
528 |
528 |
529 <code lang="lua"> vgear = AddVisualGear(...) |
529 <code language="lua"> vgear = AddVisualGear(...) |
530 DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
530 DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code> |
531 |
531 |
532 |
532 |
533 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> === |
533 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> === |
534 |
534 |
535 <blockquote>This allows manipulation of many of the visual gear values. Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values. In the case of vgtCircle, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
535 <blockquote>This allows manipulation of many of the visual gear values. Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values. In the case of vgtCircle, the visual gear values are mapped as follows. X, Y: position. State: radius. Timer: Thickness. FrameTicks: pulsation speed (0 to disable). dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA. |
536 Most visual gears require little to no modification of parameters. |
536 Most visual gears require little to no modification of parameters. |
537 </blockquote> |
537 </blockquote> |
538 Example: |
538 Example: |
539 |
539 |
540 <code lang="lua"> -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red. |
540 <code language="lua"> -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red. |
541 SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff) |
541 SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff) |
542 </code> |
542 </code> |
543 |
543 |
544 === <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> === |
544 === <tt>!FindPlace(gearUid, fall, left, right, tryHarder) (0.9.16)</tt> === |
545 |
545 |
546 <blockquote>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. |
546 <blockquote>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. |
547 </blockquote> |
547 </blockquote> |
548 Example: |
548 Example: |
549 |
549 |
550 <code lang="lua"> gear = AddGear(...) |
550 <code language="lua"> gear = AddGear(...) |
551 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
551 FindPlace(gear, true, 0, LAND_WIDTH) -- places the gear randomly between 0 and LAND_WIDTH</code> |
552 === <tt>!HogSay(gearUid, text, manner)</tt> === |
552 === <tt>!HogSay(gearUid, text, manner)</tt> === |
553 |
553 |
554 <blockquote>Makes the specified gear say, think, or shout some text in a bubble. |
554 <blockquote>Makes the specified gear say, think, or shout some text in a bubble. |
555 </blockquote> |
555 </blockquote> |
556 Example: |
556 Example: |
557 |
557 |
558 <code lang="lua"> HogSay(CurrentHedgehog, "I wonder what to do...", SAY_THINK) -- thought bubble with text |
558 <code language="lua"> HogSay(CurrentHedgehog, "I wonder what to do...", SAY_THINK) -- thought bubble with text |
559 HogSay(CurrentHedgehog, "I'm hungry...", SAY_SAY) -- speech bubble with text |
559 HogSay(CurrentHedgehog, "I'm hungry...", SAY_SAY) -- speech bubble with text |
560 HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text |
560 HogSay(CurrentHedgehog, "I smell CAKE!", SAY_SHOUT) -- exclamatory bubble with text |
561 </code> |
561 </code> |
562 === <tt>!HogTurnLeft(gearUid, boolean)</tt> === |
562 === <tt>!HogTurnLeft(gearUid, boolean)</tt> === |
563 |
563 |
564 <blockquote>Faces the specified hog left or right. |
564 <blockquote>Faces the specified hog left or right. |
565 </blockquote> |
565 </blockquote> |
566 Example: |
566 Example: |
567 |
567 |
568 <code lang="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
568 <code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
569 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
569 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
570 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
570 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
571 |
571 |
572 <blockquote>Places the specified gear exactly at the position (x,y). |
572 <blockquote>Places the specified gear exactly at the position (x,y). |
573 </blockquote> |
573 </blockquote> |
579 |
579 |
580 <blockquote>This updates the settings for a specified [AmmoTypes Ammo Type] as of count available for players, spawn probability, availability delay in turns, and the number available in crates. This is supposed to be used in the onAmmoStoreInit() event handler. |
580 <blockquote>This updates the settings for a specified [AmmoTypes Ammo Type] as of count available for players, spawn probability, availability delay in turns, and the number available in crates. This is supposed to be used in the onAmmoStoreInit() event handler. |
581 </blockquote> |
581 </blockquote> |
582 Example: |
582 Example: |
583 |
583 |
584 <code lang="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
584 <code language="lua"> SetAmmo(amShotgun, 9, 0, 0, 0) -- unlimited amount of shotgun ammo for players |
585 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade</code> |
585 SetAmmo(amGrenade, 0, 0, 0, 3) -- crates should contain always three grenade</code> |
586 === <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> === |
586 === <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> === |
587 |
587 |
588 <blockquote>Adds ammoType to the specified gear. The amount added is determined by the arguments passed via !SetAmmo() in the onAmmoStoreInit() event handler. In 0.9.16 ammo can be set directly via the optional third parameter, ammoCount. A value of 0 will remove the weapon, a value of 100 will give infinite ammo. |
588 <blockquote>Adds ammoType to the specified gear. The amount added is determined by the arguments passed via !SetAmmo() in the onAmmoStoreInit() event handler. In 0.9.16 ammo can be set directly via the optional third parameter, ammoCount. A value of 0 will remove the weapon, a value of 100 will give infinite ammo. |
589 |
589 |
600 * Starting the RC Plane 10 shots |
600 * Starting the RC Plane 10 shots |
601 * Starting Flying Saucer (gtJetpack) with only 50% fuel. |
601 * Starting Flying Saucer (gtJetpack) with only 50% fuel. |
602 * Setting all the mines to duds. |
602 * Setting all the mines to duds. |
603 * (And more!) |
603 * (And more!) |
604 |
604 |
605 <code lang="lua"> function onGearAdd(gear) |
605 <code language="lua"> function onGearAdd(gear) |
606 if (GetGearType(gear) == gtRCPlaane) then |
606 if (GetGearType(gear) == gtRCPlaane) then |
607 SetHealth(gear, 10) |
607 SetHealth(gear, 10) |
608 end |
608 end |
609 if (GetGearType(gear) == gtJetpack) then |
609 if (GetGearType(gear) == gtJetpack) then |
610 SetHealth(gear, 1000) |
610 SetHealth(gear, 1000) |
622 <blockquote>Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear. |
622 <blockquote>Sets the state for one of the effects <tt>heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen</tt> for the specified hedgehog gear. |
623 A value of 0 usually means the effect is disabled, values other than that indicate that it is enabled and in some cases specify e.g. the remaining time of that effect. |
623 A value of 0 usually means the effect is disabled, values other than that indicate that it is enabled and in some cases specify e.g. the remaining time of that effect. |
624 </blockquote> |
624 </blockquote> |
625 Example: (sets all bots poisoned) |
625 Example: (sets all bots poisoned) |
626 |
626 |
627 <code lang="lua"> function onGearAdd(gear) |
627 <code language="lua"> function onGearAdd(gear) |
628 if (GetGearType(gear) == gtHedgehog) and (GetBotLevel(gear) > 0) then |
628 if (GetGearType(gear) == gtHedgehog) and (GetBotLevel(gear) > 0) then |
629 SetEffect(gear, hePoisoned, 1) |
629 SetEffect(gear, hePoisoned, 1) |
630 end |
630 end |
631 end</code> |
631 end</code> |
632 |
632 |
657 |
657 |
658 <blockquote>Sets the selected weapon of CurrentHedgehog to one of the [AmmoTypes Ammo Type]. |
658 <blockquote>Sets the selected weapon of CurrentHedgehog to one of the [AmmoTypes Ammo Type]. |
659 |
659 |
660 <b>Example:</b> |
660 <b>Example:</b> |
661 |
661 |
662 <code lang="lua"> |
662 <code language="lua"> |
663 AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka |
663 AddAmmo(CurrentHedgehog, amBazooka, 1) -- give the CurrentHedgehog a bazooka |
664 SetWeapon(amBazooka) -- select the Bazooka.</code> |
664 SetWeapon(amBazooka) -- select the Bazooka.</code> |
665 </blockquote> |
665 </blockquote> |
666 |
666 |
667 === <tt>!SetNextWeapon()</tt> (0.9.21) === |
667 === <tt>!SetNextWeapon()</tt> (0.9.21) === |
823 ==== <tt>!SetInputMask(mask)</tt> ==== |
823 ==== <tt>!SetInputMask(mask)</tt> ==== |
824 |
824 |
825 <blockquote>Masks specified player input. |
825 <blockquote>Masks specified player input. |
826 </blockquote> |
826 </blockquote> |
827 Example: |
827 Example: |
828 <code lang="lua"> -- masks the long and high jump commands |
828 <code language="lua"> -- masks the long and high jump commands |
829 SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) |
829 SetInputMask(band(0xFFFFFFFF, bnot(gmLJump + gmHJump))) |
830 -- clears input mask, allowing player to take actions |
830 -- clears input mask, allowing player to take actions |
831 SetInputMask(0xFFFFFFFF) |
831 SetInputMask(0xFFFFFFFF) |
832 </code> |
832 </code> |
833 Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. |
833 Note: Using the input mask is an effective way to script uninterrupted cinematics, or create modes such as No Jumping. |
849 </blockquote> |
849 </blockquote> |
850 Notice: This works only for singleplayer's training missions for now and will desync multiplayer games. Flag setting is dev only. |
850 Notice: This works only for singleplayer's training missions for now and will desync multiplayer games. Flag setting is dev only. |
851 |
851 |
852 Example: |
852 Example: |
853 |
853 |
854 <code lang="lua"> AddTeam("team 1", 0xDD0000, "Simple", "Island", "Default", "hedgewars")</code> |
854 <code language="lua"> AddTeam("team 1", 0xDD0000, "Simple", "Island", "Default", "hedgewars")</code> |
855 |
855 |
856 ==== <tt>!DismissTeam(teamname)</tt> ==== |
856 ==== <tt>!DismissTeam(teamname)</tt> ==== |
857 Removes the team with the given team name from the game. |
857 Removes the team with the given team name from the game. |
858 |
858 |
859 ==== <tt>!GetClanColor(clan)</tt> ==== |
859 ==== <tt>!GetClanColor(clan)</tt> ==== |
918 == File system functions == |
918 == File system functions == |
919 === <tt>!HedgewarsScriptLoad(scriptPath)</tt> === |
919 === <tt>!HedgewarsScriptLoad(scriptPath)</tt> === |
920 Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. |
920 Loads a script (i.e. a [LuaLibraries library]) from the specified `scriptPath`. The root directory is here Hedgewars’ data directory. |
921 |
921 |
922 Example: |
922 Example: |
923 {{{ |
923 <code language="lua"> |
924 HedgewarsScriptLoad("/Scripts/Locale.lua") -- loads locale library |
924 HedgewarsScriptLoad("/Scripts/Locale.lua") -- loads locale library |
925 }}} |
925 </code> |
926 |
926 |
927 === <tt>!GetDataPath()</tt> === |
927 === <tt>!GetDataPath()</tt> === |
928 |
928 |
929 <blockquote>Returns the path to the data directory, used when adding libraries. |
929 <blockquote>Returns the path to the data directory, used when adding libraries. |
930 </blockquote> |
930 </blockquote> |
942 |
942 |
943 <blockquote>Exposes the uIO SendStat to the lua scripts. Use it to produce custom stat pages. |
943 <blockquote>Exposes the uIO SendStat to the lua scripts. Use it to produce custom stat pages. |
944 |
944 |
945 <b>Examples:</b> |
945 <b>Examples:</b> |
946 |
946 |
947 <code lang="lua"> |
947 <code language="lua"> |
948 -- will automatically change the health icon to a star |
948 -- will automatically change the health icon to a star |
949 SendStat(siGraphTitle,'Custom Graph Title') |
949 SendStat(siGraphTitle,'Custom Graph Title') |
950 SendStat(siGameResult,'Winner is Team A!') |
950 SendStat(siGameResult,'Winner is Team A!') |
951 SendStat(siCustomAchievement,'This is a custom mesasge posted in the Details section!') |
951 SendStat(siCustomAchievement,'This is a custom mesasge posted in the Details section!') |
952 -- Changes the word kill to Point, call it just before sending kills/score for each hog |
952 -- Changes the word kill to Point, call it just before sending kills/score for each hog |