|
12 | 12 | #include "items.h" |
13 | 13 | #include "lua/metadoc.hpp" |
14 | 14 | #include "player.h" |
| 15 | +#include "sound_effect_enums.h" |
15 | 16 |
|
16 | 17 | namespace devilution { |
17 | 18 | namespace { |
@@ -111,13 +112,52 @@ void InitPlayerUserType(sol::state_view &lua) |
111 | 112 | LuaSetDocReadonlyProperty(playerType, "maxMana", "number", |
112 | 113 | "Maximum mana (readonly)", |
113 | 114 | [](Player &player) { return player._pMaxMana >> 6; }); |
| 115 | + LuaSetDocReadonlyProperty(playerType, "isMyPlayer", "boolean", |
| 116 | + "Whether this is the locally controlled player (readonly)", |
| 117 | + [](const Player &player) { return &player == MyPlayer; }); |
| 118 | + LuaSetDocReadonlyProperty(playerType, "level", "integer", |
| 119 | + "Current dungeon level the player is on (readonly)", |
| 120 | + [](const Player &player) { return static_cast<int>(player.plrlevel); }); |
| 121 | + LuaSetDocFn(playerType, "isOnLevel", "(level: integer) -> boolean", |
| 122 | + "Returns true if the player is on the given dungeon level", |
| 123 | + [](const Player &player, int level) { |
| 124 | + return player.isOnLevel(static_cast<uint8_t>(level)); |
| 125 | + }); |
| 126 | + LuaSetDocFn(playerType, "say", "(speechId: HeroSpeech) -> void", |
| 127 | + "Makes the player character say the given speech line", |
| 128 | + [](Player &player, HeroSpeech speechId) { |
| 129 | + player.Say(speechId); |
| 130 | + }); |
| 131 | +} |
| 132 | + |
| 133 | +void RegisterHeroSpeechEnum(sol::state_view &lua) |
| 134 | +{ |
| 135 | + lua.new_enum<HeroSpeech>("HeroSpeech", |
| 136 | + { |
| 137 | + { "ICantUseThisYet", HeroSpeech::ICantUseThisYet }, |
| 138 | + { "ThatWontWorkHere", HeroSpeech::ThatWontWorkHere }, |
| 139 | + { "ThatWontWork", HeroSpeech::ThatWontWork }, |
| 140 | + { "VengeanceIsMine", HeroSpeech::VengeanceIsMine }, |
| 141 | + { "JustWhatIWasLookingFor", HeroSpeech::JustWhatIWasLookingFor }, |
| 142 | + { "ICantCarryAnymore", HeroSpeech::ICantCarryAnymore }, |
| 143 | + { "IHaveNoRoom", HeroSpeech::IHaveNoRoom }, |
| 144 | + { "ItsTooBig", HeroSpeech::ItsTooBig }, |
| 145 | + { "ItsTooHeavy", HeroSpeech::ItsTooHeavy }, |
| 146 | + { "No", HeroSpeech::No }, |
| 147 | + { "Yes", HeroSpeech::Yes }, |
| 148 | + { "Die", HeroSpeech::Die }, |
| 149 | + { "TimeToDie", HeroSpeech::TimeToDie }, |
| 150 | + { "OhTooEasy", HeroSpeech::OhTooEasy }, |
| 151 | + }); |
114 | 152 | } |
115 | 153 | } // namespace |
116 | 154 |
|
117 | 155 | sol::table LuaPlayerModule(sol::state_view &lua) |
118 | 156 | { |
119 | 157 | InitPlayerUserType(lua); |
| 158 | + RegisterHeroSpeechEnum(lua); |
120 | 159 | sol::table table = lua.create_table(); |
| 160 | + table["HeroSpeech"] = lua["HeroSpeech"]; |
121 | 161 | LuaSetDocFn(table, "self", "()", |
122 | 162 | "The current player", |
123 | 163 | []() { |
|
0 commit comments