437 <code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
437 <code language="lua"> local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player |
438 SetGearPosition(player, 1500, 1000)</code> |
438 SetGearPosition(player, 1500, 1000)</code> |
439 == Functions to get gear properties == |
439 == Functions to get gear properties == |
440 |
440 |
441 === <tt>!GetGearType(gearUid)</tt> === |
441 === <tt>!GetGearType(gearUid)</tt> === |
442 This function returns one of [GearTypes Gear Types] for the specified gear. |
442 This function returns the [GearTypes gear type] for the specified gear. |
443 |
443 |
444 === <tt>!GetGearPosition(gearUid)</tt> === |
444 === <tt>!GetGearPosition(gearUid)</tt> === |
445 Returns x,y coordinates for the specified gear. |
445 Returns x,y coordinates for the specified gear. Not to be confused with `GetGearPos`. |
446 |
446 |
447 === <tt>!GetGearRadius(gearUid)</tt> === |
447 === <tt>!GetGearRadius(gearUid)</tt> === |
448 Returns radius for the specified gear. |
448 Returns radius for the specified gear. |
449 |
449 |
450 === <tt>!GetGearVelocity(gearUid)</tt> === |
450 === <tt>!GetGearVelocity(gearUid)</tt> === |
535 Returns the message of the gear. This is a bitmask built out of flags seen in [GearMessages]. |
535 Returns the message of the gear. This is a bitmask built out of flags seen in [GearMessages]. |
536 |
536 |
537 === <tt>!GetTag(gearUid)</tt> === |
537 === <tt>!GetTag(gearUid)</tt> === |
538 Returns the tag of the specified gear (by `gearUid`). |
538 Returns the tag of the specified gear (by `gearUid`). |
539 |
539 |
540 A “tag” of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for gtBall gears, it specifies the ball color, for gtAirAttack gears (airplane) it specifies the direction of the plane, etc. `tag` has to be an integer. |
540 The `Tag` of a gear is just another arbitrary variable to hold the gear's state. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. The returned value will be an integer. |
541 |
541 |
542 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
542 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
543 |
543 |
544 <code language="lua"> |
544 <code language="lua"> |
545 -- This adds a ball (the one from the ballgun) at (123, 456): |
545 -- This adds a ball (the one from the ballgun) at (123, 456): |
553 |
553 |
554 === <tt>!GetFollowGear()</tt> === |
554 === <tt>!GetFollowGear()</tt> === |
555 Returns the uid of the gear that is currently being followed. |
555 Returns the uid of the gear that is currently being followed. |
556 |
556 |
557 === <tt>!GetTimer(gearUid)</tt> === |
557 === <tt>!GetTimer(gearUid)</tt> === |
558 Returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or rcplane time. |
558 Returns the timer of the gear. This is for example the time it takes for watermelon, mine, etc. to explode. This is also the time used to specify the blowtorch or RC plane time. See [GearTypes] for a full list. |
559 |
559 |
560 === <tt>!GetHealth(gearUid)</tt> === |
560 === <tt>!GetHealth(gearUid)</tt> === |
561 Returns the health of the gear. |
561 Returns the health of the gear. Depending on the gear type, the gear's “health” can also refer to other things, see [GearTypes] for a full list. |
562 |
562 |
563 === <tt>!GetHogLevel(gearUid)</tt> === |
563 === <tt>!GetHogLevel(gearUid)</tt> === |
564 Returns the bot level ranging from `0` to `5`. `1` is the strongest bot level and `5` is the weakest one. `0` is for human player. |
564 Returns the bot level ranging from `0` to `5`. `1` is the strongest bot level and `5` is the weakest one. `0` is for human player. |
565 |
565 |
566 === <tt>!GetGearPos(gearUid)</tt> === |
566 === <tt>!GetGearPos(gearUid)</tt> === |
567 Get pos of specified gear. |
567 Get the `Pos` value of the specified gear. `Pos` is just another arbitrary value to hold the state of the gear, such as `Tag` and `Health`, the meaning depends on the gear type. See [GearTypes] for the conrete meaning of a gear's `Pos` value. |
|
568 |
|
569 *Important*: Pos is *not* related to the gear's position, use `GetGearPosition` for that. |
568 |
570 |
569 === <tt>!GetGearValues(gearUid)</tt> (0.9.22) === |
571 === <tt>!GetGearValues(gearUid)</tt> (0.9.22) === |
570 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. |
572 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. |
571 |
573 |
572 This is returned (all variables are integers): |
574 This is returned (all variables are integers): |
721 Example: |
723 Example: |
722 |
724 |
723 <code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
725 <code language="lua"> HogTurnLeft(CurrentHedgehog, true) -- turns CurrentHedgehog left |
724 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
726 HogTurnLeft(CurrentHedgehog, false) -- turns CurrentHedgehog right</code> |
725 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
727 === <tt>!SetGearPosition(gearUid, x, y)</tt> === |
726 Places the specified gear exactly at the position (`x`,`y`). |
728 Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. |
727 |
729 |
728 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
730 === <tt>!SetGearVelocity(gearUid, dx, dy)</tt> === |
729 Gives the specified gear the velocity of `dx`, `dy`. |
731 Gives the specified gear the velocity of `dx`, `dy`. |
730 |
732 |
731 === <tt>!SetFlightTime(gearUid, flighttime)</tt> === |
733 === <tt>!SetFlightTime(gearUid, flighttime)</tt> === |
753 |
755 |
754 *Note:* The effectiveness of this function may be limited due to problems with `gfPerHogAmmo` in Lua scripting. |
756 *Note:* The effectiveness of this function may be limited due to problems with `gfPerHogAmmo` in Lua scripting. |
755 |
757 |
756 |
758 |
757 === <tt>!SetHealth(gearUid, health)</tt> === |
759 === <tt>!SetHealth(gearUid, health)</tt> === |
758 Sets the health of the specified gear. |
760 Sets the health of the specified gear. The “health” of a gear can refer to many things, depending on the gear type. |
759 This can be used for purposes other than killing hedgehogs. |
761 |
760 |
762 Use cases: |
761 For example: |
763 |
762 |
764 * Setting the health of a hedgehog (`gtHedgehog`) to 99 |
763 * Starting the RC Plane 10 shots |
765 * Starting the RC Plane (`gtRCPlane`) with 10 bombs |
764 * Starting Flying Saucer (`gtJetpack`) with only 50% fuel. |
766 * Starting flying saucer (`gtJetpack`) with only 50% fuel |
765 * Setting all the mines to duds. |
767 * Setting all the mines (`gtMine`) to duds |
766 * (And more!) |
768 * And more! |
|
769 |
|
770 See [GearTypes] for a full description. |
767 |
771 |
768 <code language="lua"> function onGearAdd(gear) |
772 <code language="lua"> function onGearAdd(gear) |
|
773 if (GetGearType(gear) == gtHedgehog) then |
|
774 -- Set hedgehog health to 99 |
|
775 SetHealth(gear, 99) |
|
776 end |
769 if (GetGearType(gear) == gtRCPlaane) then |
777 if (GetGearType(gear) == gtRCPlaane) then |
|
778 -- Give the plane 10 bombs |
770 SetHealth(gear, 10) |
779 SetHealth(gear, 10) |
771 end |
780 end |
772 if (GetGearType(gear) == gtJetpack) then |
781 if (GetGearType(gear) == gtJetpack) then |
|
782 -- Set fuel to 50% only |
773 SetHealth(gear, 1000) |
783 SetHealth(gear, 1000) |
774 end |
784 end |
775 if (GetGearType(gear) == gtMine) then |
785 if (GetGearType(gear) == gtMine) then |
|
786 -- Turn mine into dud |
776 SetHealth(gear, 0) |
787 SetHealth(gear, 0) |
777 end |
788 end |
778 end</code> |
789 end</code> |
779 |
790 |
780 |
791 |
855 |
866 |
856 === <tt>!SetGearMessage(gearUid, message)</tt> === |
867 === <tt>!SetGearMessage(gearUid, message)</tt> === |
857 Sets the gear messages of the specified gear. `message` is a bitmask built out of flags seen in [GearMessages]. |
868 Sets the gear messages of the specified gear. `message` is a bitmask built out of flags seen in [GearMessages]. |
858 |
869 |
859 === <tt>!SetTag(gearUid, tag)</tt> === |
870 === <tt>!SetTag(gearUid, tag)</tt> === |
860 Sets the tag of the specified gear (by `gearUid`). A “tag” of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for gtBall gears, it specifies the ball color, for gtAirAttack gears (airplane) it specifies the direction of the plane, etc. `tag` has to be an integer. |
871 Sets the `Tag` value of the specified gear (by `gearUid`). The `Tag` value of a gear is simply an extra variable to modify misc. things. The meaning of a tag depends on the gear type. For example, for `gtBall` gears, it specifies the ball color, for `gtAirAttack` gears (airplane) it specifies the direction of the plane, etc. See [GearTypes] for a full list. `tag` has to be an integer. |
861 |
872 |
862 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
873 Note that the word “tag” here does _not_ refer to the name and health tags you see above hedgehogs, this is something different. |
863 |
874 |
864 <code language="lua"> |
875 <code language="lua"> |
865 -- This adds a ball (the one from the ballgun) at (123, 456): |
876 -- This adds a ball (the one from the ballgun) at (123, 456): |
869 </code> |
880 </code> |
870 |
881 |
871 The meaning of tags are described in [GearTypes]. |
882 The meaning of tags are described in [GearTypes]. |
872 |
883 |
873 === <tt>!SetTimer(gearUid, timer)</tt> === |
884 === <tt>!SetTimer(gearUid, timer)</tt> === |
874 Sets the timer of the specified gear. Also see `GetTimer` |
885 Sets the timer of the specified gear. Also see `GetTimer`. |
875 |
886 |
876 === <tt>!SetHogLevel(gearUid, level)</tt> === |
887 === <tt>!SetHogLevel(gearUid, level)</tt> === |
877 Sets the bot level from 0 to 5. `0` means human player. |
888 Sets the bot level from 0 to 5. `0` means human player. |
878 |
889 |
879 === <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> === |
890 === <tt>!SetGearPos(gearUid, value) (0.9.18-dev)</tt> === |
880 Set pos of specified gear to specified value. |
891 Sets the `Pos` value (not the position!) of the specified gear to specified value. See `GetGearPos` for more information. |
881 |
|
882 |
892 |
883 == Gameplay functions == |
893 == Gameplay functions == |
884 |
894 |
885 === `GameFlags` functions === |
895 === `GameFlags` functions === |
886 |
896 |